Skip to content

Commit 307c6f7

Browse files
committed
fix: refresh token login method claim
1 parent bbc6394 commit 307c6f7

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

server/handlers/token.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func TokenHandler() gin.HandlerFunc {
167167
return
168168
}
169169
userID = claims["sub"].(string)
170-
loginMethod := claims["login_method"]
170+
claimLoginMethod := claims["login_method"]
171171
rolesInterface := claims["roles"].([]interface{})
172172
scopeInterface := claims["scope"].([]interface{})
173173
for _, v := range rolesInterface {
@@ -178,9 +178,11 @@ func TokenHandler() gin.HandlerFunc {
178178
}
179179

180180
sessionKey = userID
181-
if loginMethod != nil && loginMethod != "" {
182-
sessionKey = loginMethod.(string) + ":" + sessionKey
181+
if claimLoginMethod != nil && claimLoginMethod != "" {
182+
sessionKey = claimLoginMethod.(string) + ":" + sessionKey
183+
loginMethod = claimLoginMethod.(string)
183184
}
185+
184186
// remove older refresh token and rotate it for security
185187
go memorystore.Provider.DeleteUserSession(sessionKey, claims["nonce"].(string))
186188
}
@@ -213,6 +215,7 @@ func TokenHandler() gin.HandlerFunc {
213215
})
214216
return
215217
}
218+
216219
memorystore.Provider.SetUserSession(sessionKey, constants.TokenTypeSessionToken+"_"+authToken.FingerPrint, authToken.FingerPrintHash)
217220
memorystore.Provider.SetUserSession(sessionKey, constants.TokenTypeAccessToken+"_"+authToken.FingerPrint, authToken.AccessToken.Token)
218221
cookie.SetSession(gc, authToken.FingerPrintHash)

server/token/auth_token.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ func ValidateRefreshToken(gc *gin.Context, refreshToken string) (map[string]inte
256256
if loginMethod != nil && loginMethod != "" {
257257
sessionKey = loginMethod.(string) + ":" + userID
258258
}
259-
260259
token, err := memorystore.Provider.GetUserSession(sessionKey, constants.TokenTypeRefreshToken+"_"+nonce)
261260
if nonce == "" || err != nil {
262261
return res, fmt.Errorf(`unauthorized`)

0 commit comments

Comments
 (0)