fix(keystone): panic if request with an invalid token

service report nil pointer panic if request with an invalid token string
This commit is contained in:
Qiu Jian
2020-12-16 16:43:24 +08:00
parent 7b5b8ccd69
commit 0eaf20da26
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)