From dc99f4a7a375abaf30ee24a98d10a56c8298ec94 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 12 May 2022 10:46:20 -0700 Subject: [PATCH] allow bucket to be listed when GetBucketLocation is enabled (#14903) currently, we allowed buckets to be listed from the API call if and when the user has ListObject() permission at the global level, this is okay to be extended to GetBucketLocation() as well since GetBucketLocation() is a "read" call and allowing "reads" on a bucket has an implicit assumption that ListBuckets() should be allowed. This makes discoverability of access for read-only users becomes easier or users with specific restrictions on their policies. --- cmd/admin-handlers-users.go | 13 +++++++++++++ cmd/bucket-handlers.go | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/cmd/admin-handlers-users.go b/cmd/admin-handlers-users.go index 43de2bdb8..c1873cc15 100644 --- a/cmd/admin-handlers-users.go +++ b/cmd/admin-handlers-users.go @@ -1105,6 +1105,19 @@ func (a adminAPIHandlers) AccountInfoHandler(w http.ResponseWriter, r *http.Requ rd = true } + if globalIAMSys.IsAllowed(iampolicy.Args{ + AccountName: cred.AccessKey, + Groups: cred.Groups, + Action: iampolicy.GetBucketLocationAction, + BucketName: bucketName, + ConditionValues: getConditionValues(r, "", cred.AccessKey, claims), + IsOwner: owner, + ObjectName: "", + Claims: claims, + }) { + rd = true + } + if globalIAMSys.IsAllowed(iampolicy.Args{ AccountName: cred.AccessKey, Groups: cred.Groups, diff --git a/cmd/bucket-handlers.go b/cmd/bucket-handlers.go index 60e3c09f3..9800e1671 100644 --- a/cmd/bucket-handlers.go +++ b/cmd/bucket-handlers.go @@ -364,6 +364,18 @@ func (api objectAPIHandlers) ListBucketsHandler(w http.ResponseWriter, r *http.R }) { bucketsInfo[n] = bucketInfo n++ + } else if globalIAMSys.IsAllowed(iampolicy.Args{ + AccountName: cred.AccessKey, + Groups: cred.Groups, + Action: iampolicy.GetBucketLocationAction, + BucketName: bucketInfo.Name, + ConditionValues: getConditionValues(r, "", cred.AccessKey, cred.Claims), + IsOwner: owner, + ObjectName: "", + Claims: cred.Claims, + }) { + bucketsInfo[n] = bucketInfo + n++ } } bucketsInfo = bucketsInfo[:n]