fix: optimize ListBuckets for anonymous users (#12182)

anonymous users are never allowed to listBuckets(),
we do not need to further validate the policy, we can
simply reject if credentials are empty.
This commit is contained in:
Harshavardhana 2021-04-28 21:37:02 -07:00 committed by GitHub
parent c301027942
commit b3c8a1864f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -46,4 +46,3 @@ jobs:
make crosscompile
make verify
make verify-healing
bash -c 'shopt -s globstar; shellcheck mint/**/*.sh'

View file

@ -299,6 +299,12 @@ func (api objectAPIHandlers) ListBucketsHandler(w http.ResponseWriter, r *http.R
return
}
// Anonymous users, should be rejected.
if cred.AccessKey == "" {
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrAccessDenied), r.URL)
return
}
// If etcd, dns federation configured list buckets from etcd.
var bucketsInfo []BucketInfo
if globalDNSConfig != nil && globalBucketFederation {