Add TokenFormat to application.

This commit is contained in:
Gucheng Wang
2021-12-18 16:16:34 +08:00
parent cb625b3fa2
commit 95f2a3b311
4 changed files with 19 additions and 0 deletions

View File

@ -39,6 +39,7 @@ type Application struct {
ClientId string `xorm:"varchar(100)" json:"clientId"`
ClientSecret string `xorm:"varchar(100)" json:"clientSecret"`
RedirectUris []string `xorm:"varchar(1000)" json:"redirectUris"`
TokenFormat string `xorm:"varchar(100)" json:"tokenFormat"`
ExpireInHours int `json:"expireInHours"`
SignupUrl string `xorm:"varchar(200)" json:"signupUrl"`
SigninUrl string `xorm:"varchar(200)" json:"signinUrl"`

View File

@ -55,6 +55,10 @@ func generateJwtToken(application *Application, user *User, nonce string) (strin
},
}
if application.TokenFormat == "JWT-Empty" {
claims.User = User{}
}
token := jwt.NewWithClaims(jwt.SigningMethodRS256, claims)
// Use "token_jwt_key.key" as RSA private key