|
|
|
@ -690,13 +690,15 @@ func getBucketAccessPolicy(objAPI ObjectLayer, bucketName string) (policy.Bucket |
|
|
|
|
policyInfo, err = layer.GetBucketPolicies(bucketName) |
|
|
|
|
case *azureObjects: |
|
|
|
|
policyInfo, err = layer.GetBucketPolicies(bucketName) |
|
|
|
|
case *gcsGateway: |
|
|
|
|
policyInfo, err = layer.GetBucketPolicies(bucketName) |
|
|
|
|
default: |
|
|
|
|
policyInfo, err = readBucketAccessPolicy(objAPI, bucketName) |
|
|
|
|
} |
|
|
|
|
return policyInfo, err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// GetBucketPolicy - get bucket policy.
|
|
|
|
|
// GetBucketPolicy - get bucket policy for the requested prefix.
|
|
|
|
|
func (web *webAPIHandlers) GetBucketPolicy(r *http.Request, args *GetBucketPolicyArgs, reply *GetBucketPolicyRep) error { |
|
|
|
|
objectAPI := web.ObjectAPI() |
|
|
|
|
if objectAPI == nil { |
|
|
|
@ -707,10 +709,13 @@ func (web *webAPIHandlers) GetBucketPolicy(r *http.Request, args *GetBucketPolic |
|
|
|
|
return toJSONError(errAuthentication) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
policyInfo, err := readBucketAccessPolicy(objectAPI, args.BucketName) |
|
|
|
|
var policyInfo, err = getBucketAccessPolicy(objectAPI, args.BucketName) |
|
|
|
|
if err != nil { |
|
|
|
|
_, ok := errorCause(err).(PolicyNotFound) |
|
|
|
|
if !ok { |
|
|
|
|
return toJSONError(err, args.BucketName) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
reply.UIVersion = browser.UIVersion |
|
|
|
|
reply.Policy = policy.GetPolicy(policyInfo.Statements, args.BucketName, args.Prefix) |
|
|
|
@ -745,8 +750,8 @@ func (web *webAPIHandlers) ListAllBucketPolicies(r *http.Request, args *ListAllB |
|
|
|
|
if !isHTTPRequestValid(r) { |
|
|
|
|
return toJSONError(errAuthentication) |
|
|
|
|
} |
|
|
|
|
var policyInfo, err = getBucketAccessPolicy(objectAPI, args.BucketName) |
|
|
|
|
|
|
|
|
|
var policyInfo, err = getBucketAccessPolicy(objectAPI, args.BucketName) |
|
|
|
|
if err != nil { |
|
|
|
|
_, ok := errorCause(err).(PolicyNotFound) |
|
|
|
|
if !ok { |
|
|
|
@ -791,7 +796,6 @@ func (web *webAPIHandlers) SetBucketPolicy(r *http.Request, args *SetBucketPolic |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var policyInfo, err = getBucketAccessPolicy(objectAPI, args.BucketName) |
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
if _, ok := errorCause(err).(PolicyNotFound); !ok { |
|
|
|
|
return toJSONError(err, args.BucketName) |
|
|
|
|