From badfe34755179c9f6e820d1d7f883da7d7ad17b0 Mon Sep 17 00:00:00 2001 From: Nex Zhu <4370605+NexZhu@users.noreply.github.com> Date: Fri, 1 Dec 2023 18:29:39 +0800 Subject: [PATCH] feat: add "nonce" into the OAuth and OIDC tokens, for some apps require "nonce" to integrate (#2522) --- controllers/auth.go | 3 ++- object/token.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/controllers/auth.go b/controllers/auth.go index e6d3fa4ba051..31e932ad120d 100644 --- a/controllers/auth.go +++ b/controllers/auth.go @@ -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 diff --git a/object/token.go b/object/token.go index 0675e3e43739..986b40e75743 100644 --- a/object/token.go +++ b/object/token.go @@ -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 }