Merge branch 'main' of https://github.com/authorizerdev/authorizer into fix/oauth-provider

This commit is contained in:
Lakhan Samani
2022-11-10 22:51:13 +05:30
28 changed files with 523 additions and 93 deletions

View File

@@ -155,6 +155,7 @@ func TokenHandler() gin.HandlerFunc {
"error": "invalid_refresh_token",
"error_description": "The refresh token is invalid",
})
return
}
claims, err := token.ValidateRefreshToken(gc, refreshToken)
@@ -164,9 +165,10 @@ func TokenHandler() gin.HandlerFunc {
"error": "unauthorized",
"error_description": err.Error(),
})
return
}
userID = claims["sub"].(string)
loginMethod := claims["login_method"]
claimLoginMethod := claims["login_method"]
rolesInterface := claims["roles"].([]interface{})
scopeInterface := claims["scope"].([]interface{})
for _, v := range rolesInterface {
@@ -177,9 +179,11 @@ func TokenHandler() gin.HandlerFunc {
}
sessionKey = userID
if loginMethod != nil && loginMethod != "" {
sessionKey = loginMethod.(string) + ":" + sessionKey
if claimLoginMethod != nil && claimLoginMethod != "" {
sessionKey = claimLoginMethod.(string) + ":" + sessionKey
loginMethod = claimLoginMethod.(string)
}
// remove older refresh token and rotate it for security
go memorystore.Provider.DeleteUserSession(sessionKey, claims["nonce"].(string))
}
@@ -213,6 +217,7 @@ func TokenHandler() gin.HandlerFunc {
})
return
}
memorystore.Provider.SetUserSession(sessionKey, constants.TokenTypeSessionToken+"_"+authToken.FingerPrint, authToken.FingerPrintHash)
memorystore.Provider.SetUserSession(sessionKey, constants.TokenTypeAccessToken+"_"+authToken.FingerPrint, authToken.AccessToken.Token)
cookie.SetSession(gc, authToken.FingerPrintHash)