Merge pull request #9452 from swordqiu/hotfix/qj-invalid-token-fetch-policy-panic

fix(keystone): panic if request with an invalid token
This commit is contained in:
Zexi Li
2020-12-16 17:57:26 +08:00
committed by GitHub
2 changed files with 4 additions and 0 deletions
+3
View File
@@ -134,6 +134,9 @@ func getMaskedLoginIp(userCred mcclient.TokenCredential) string {
}
func policyKey(userCred mcclient.TokenCredential) string {
if userCred == nil || auth.IsGuestToken(userCred) {
return auth.GUEST_TOKEN
}
keys := []string{userCred.GetProjectId()}
roles := userCred.GetRoleIds()
if len(roles) > 0 {
+1
View File
@@ -69,6 +69,7 @@ func AuthenticateWithDelayDecision(f appsrv.FilterHandler, delayDecision bool) a
httperrors.UnauthorizedError(ctx, w, "InvalidToken")
return
}
token = &GuestToken
}
}
ctx = context.WithValue(ctx, appctx.APP_CONTEXT_KEY_AUTH_TOKEN, token)