mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-01 15:07:17 +08:00
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:
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user