fix: allow gateway to work with root credentials (#12655)

This commit is contained in:
Harshavardhana 2021-07-09 10:35:09 -07:00 committed by GitHub
parent b6dd9b55a7
commit b79cdc1611
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 8 deletions

View File

@ -1019,12 +1019,16 @@ func (a adminAPIHandlers) AccountInfoHandler(w http.ResponseWriter, r *http.Requ
return rd, wr
}
var dataUsageInfo madmin.DataUsageInfo
var err error
if !globalIsGateway {
// Load the latest calculated data usage
dataUsageInfo, err := loadDataUsageFromBackend(ctx, objectAPI)
dataUsageInfo, err = loadDataUsageFromBackend(ctx, objectAPI)
if err != nil {
// log the error, continue with the accounting response
logger.LogIf(ctx, err)
}
}
// If etcd, dns federation configured list buckets from etcd.
var buckets []BucketInfo

View File

@ -131,11 +131,12 @@ func checkKeyValid(accessKey string) (auth.Credentials, bool, APIErrorCode) {
var cred = globalActiveCred
if cred.AccessKey != accessKey {
// Check if the access key is part of users credentials.
var ok bool
if cred, ok = globalIAMSys.GetUser(accessKey); !ok {
ucred, ok := globalIAMSys.GetUser(accessKey)
if !ok {
return cred, false, ErrInvalidAccessKeyID
}
owner = false
owner = cred.AccessKey == ucred.ParentUser
cred = ucred
}
return cred, owner, ErrNone
}