fix: IAM not initialized then checkKeyValid() should return 503s (#12260)

currently GetUser() returns 403 when IAM is not initialized
this can lead to applications crashing, instead return 503
so that the applications can retry and backoff.

fixes #12078
This commit is contained in:
Harshavardhana
2021-05-09 08:14:19 -07:00
committed by GitHub
parent 39d681a04a
commit 8b52d70012
4 changed files with 30 additions and 0 deletions
+6
View File
@@ -121,6 +121,12 @@ func isValidRegion(reqRegion string, confRegion string) bool {
// check if the access key is valid and recognized, additionally
// also returns if the access key is owner/admin.
func checkKeyValid(accessKey string) (auth.Credentials, bool, APIErrorCode) {
if !globalIAMSys.Initialized() && !globalIsGateway {
// Check if server has initialized, then only proceed
// to check for IAM users otherwise its okay for clients
// to retry with 503 errors when server is coming up.
return auth.Credentials{}, false, ErrServerNotInitialized
}
var owner = true
var cred = globalActiveCred
if cred.AccessKey != accessKey {