mirror of
https://github.com/minio/minio.git
synced 2025-01-23 20:53:18 -05:00
GCS gateway to return error in getBucketPolicy, when no policy is set (#5117)
Return NoSuchBucketPolicy error when there is no policy set. Fixes minio/mint#199
This commit is contained in:
parent
bc8b936d4b
commit
95d97c2d6d
@ -1060,7 +1060,6 @@ func (l *gcsGateway) GetBucketPolicies(bucket string) (policy.BucketAccessPolicy
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return policy.BucketAccessPolicy{}, gcsToObjectError(traceError(err), bucket)
|
return policy.BucketAccessPolicy{}, gcsToObjectError(traceError(err), bucket)
|
||||||
}
|
}
|
||||||
|
|
||||||
policyInfo := policy.BucketAccessPolicy{Version: "2012-10-17"}
|
policyInfo := policy.BucketAccessPolicy{Version: "2012-10-17"}
|
||||||
for _, r := range rules {
|
for _, r := range rules {
|
||||||
if r.Entity != storage.AllUsers || r.Role == storage.RoleOwner {
|
if r.Entity != storage.AllUsers || r.Role == storage.RoleOwner {
|
||||||
@ -1073,7 +1072,10 @@ func (l *gcsGateway) GetBucketPolicies(bucket string) (policy.BucketAccessPolicy
|
|||||||
policyInfo.Statements = policy.SetPolicy(policyInfo.Statements, policy.BucketPolicyWriteOnly, bucket, "")
|
policyInfo.Statements = policy.SetPolicy(policyInfo.Statements, policy.BucketPolicyWriteOnly, bucket, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Return NoSuchBucketPolicy error, when policy is not set
|
||||||
|
if len(policyInfo.Statements) == 0 {
|
||||||
|
return policy.BucketAccessPolicy{}, gcsToObjectError(traceError(PolicyNotFound{}), bucket)
|
||||||
|
}
|
||||||
return policyInfo, nil
|
return policyInfo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user