Skip to content

Commit

Permalink
feat: add "nonce" into the OAuth and OIDC tokens, for some apps requi…
Browse files Browse the repository at this point in the history
…re "nonce" to integrate (casdoor#2522)
  • Loading branch information
NexZhu authored Dec 1, 2023
1 parent a5f9f61 commit badfe34
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion controllers/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ func (c *ApiController) HandleLoggedIn(application *object.Application, user *ob
resp = &Response{Status: "error", Msg: fmt.Sprintf("error: grant_type: %s is not supported in this application", form.Type), Data: ""}
} else {
scope := c.Input().Get("scope")
token, _ := object.GetTokenByUser(application, user, scope, c.Ctx.Request.Host)
nonce := c.Input().Get("nonce")
token, _ := object.GetTokenByUser(application, user, scope, nonce, c.Ctx.Request.Host)
resp = tokenToResponse(token)
}
} else if form.Type == ResponseTypeSaml { // saml flow
Expand Down
4 changes: 2 additions & 2 deletions object/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,13 +754,13 @@ func GetClientCredentialsToken(application *Application, clientSecret string, sc

// GetTokenByUser
// Implicit flow
func GetTokenByUser(application *Application, user *User, scope string, host string) (*Token, error) {
func GetTokenByUser(application *Application, user *User, scope string, nonce string, host string) (*Token, error) {
err := ExtendUserWithRolesAndPermissions(user)
if err != nil {
return nil, err
}

accessToken, refreshToken, tokenName, err := generateJwtToken(application, user, "", scope, host)
accessToken, refreshToken, tokenName, err := generateJwtToken(application, user, nonce, scope, host)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit badfe34

Please sign in to comment.