|
|
@ -52,13 +52,13 @@ func setGetRespHeaders(w http.ResponseWriter, reqParams url.Values) { |
|
|
|
// this is in keeping with the permissions sections of the docs of both:
|
|
|
|
// this is in keeping with the permissions sections of the docs of both:
|
|
|
|
// HEAD Object: http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectHEAD.html
|
|
|
|
// HEAD Object: http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectHEAD.html
|
|
|
|
// GET Object: http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectGET.html
|
|
|
|
// GET Object: http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectGET.html
|
|
|
|
func errAllowableObjectNotFound(api objectAPIHandlers, bucket string, r *http.Request) APIErrorCode { |
|
|
|
func errAllowableObjectNotFound(objAPI ObjectLayer, bucket string, r *http.Request) APIErrorCode { |
|
|
|
if getRequestAuthType(r) == authTypeAnonymous { |
|
|
|
if getRequestAuthType(r) == authTypeAnonymous { |
|
|
|
//we care about the bucket as a whole, not a particular resource
|
|
|
|
//we care about the bucket as a whole, not a particular resource
|
|
|
|
url := *r.URL |
|
|
|
url := *r.URL |
|
|
|
url.Path = "/" + bucket |
|
|
|
url.Path = "/" + bucket |
|
|
|
|
|
|
|
|
|
|
|
if s3Error := enforceBucketPolicy(api, "s3:ListBucket", bucket, &url); s3Error != ErrNone { |
|
|
|
if s3Error := enforceBucketPolicy(objAPI, "s3:ListBucket", bucket, &url); s3Error != ErrNone { |
|
|
|
return ErrAccessDenied |
|
|
|
return ErrAccessDenied |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -89,7 +89,7 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req |
|
|
|
return |
|
|
|
return |
|
|
|
case authTypeAnonymous: |
|
|
|
case authTypeAnonymous: |
|
|
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html
|
|
|
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html
|
|
|
|
if s3Error := enforceBucketPolicy(api, "s3:GetObject", bucket, r.URL); s3Error != ErrNone { |
|
|
|
if s3Error := enforceBucketPolicy(api.ObjectAPI, "s3:GetObject", bucket, r.URL); s3Error != ErrNone { |
|
|
|
writeErrorResponse(w, r, s3Error, r.URL.Path) |
|
|
|
writeErrorResponse(w, r, s3Error, r.URL.Path) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -105,7 +105,7 @@ func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Req |
|
|
|
errorIf(err, "Unable to fetch object info.") |
|
|
|
errorIf(err, "Unable to fetch object info.") |
|
|
|
apiErr := toAPIErrorCode(err) |
|
|
|
apiErr := toAPIErrorCode(err) |
|
|
|
if apiErr == ErrNoSuchKey { |
|
|
|
if apiErr == ErrNoSuchKey { |
|
|
|
apiErr = errAllowableObjectNotFound(api, bucket, r) |
|
|
|
apiErr = errAllowableObjectNotFound(api.ObjectAPI, bucket, r) |
|
|
|
} |
|
|
|
} |
|
|
|
writeErrorResponse(w, r, apiErr, r.URL.Path) |
|
|
|
writeErrorResponse(w, r, apiErr, r.URL.Path) |
|
|
|
return |
|
|
|
return |
|
|
@ -195,7 +195,7 @@ func (api objectAPIHandlers) HeadObjectHandler(w http.ResponseWriter, r *http.Re |
|
|
|
return |
|
|
|
return |
|
|
|
case authTypeAnonymous: |
|
|
|
case authTypeAnonymous: |
|
|
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html
|
|
|
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html
|
|
|
|
if s3Error := enforceBucketPolicy(api, "s3:GetObject", bucket, r.URL); s3Error != ErrNone { |
|
|
|
if s3Error := enforceBucketPolicy(api.ObjectAPI, "s3:GetObject", bucket, r.URL); s3Error != ErrNone { |
|
|
|
writeErrorResponse(w, r, s3Error, r.URL.Path) |
|
|
|
writeErrorResponse(w, r, s3Error, r.URL.Path) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -211,7 +211,7 @@ func (api objectAPIHandlers) HeadObjectHandler(w http.ResponseWriter, r *http.Re |
|
|
|
errorIf(err, "Unable to fetch object info.") |
|
|
|
errorIf(err, "Unable to fetch object info.") |
|
|
|
apiErr := toAPIErrorCode(err) |
|
|
|
apiErr := toAPIErrorCode(err) |
|
|
|
if apiErr == ErrNoSuchKey { |
|
|
|
if apiErr == ErrNoSuchKey { |
|
|
|
apiErr = errAllowableObjectNotFound(api, bucket, r) |
|
|
|
apiErr = errAllowableObjectNotFound(api.ObjectAPI, bucket, r) |
|
|
|
} |
|
|
|
} |
|
|
|
writeErrorResponse(w, r, apiErr, r.URL.Path) |
|
|
|
writeErrorResponse(w, r, apiErr, r.URL.Path) |
|
|
|
return |
|
|
|
return |
|
|
@ -245,7 +245,7 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re |
|
|
|
return |
|
|
|
return |
|
|
|
case authTypeAnonymous: |
|
|
|
case authTypeAnonymous: |
|
|
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html
|
|
|
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html
|
|
|
|
if s3Error := enforceBucketPolicy(api, "s3:PutObject", bucket, r.URL); s3Error != ErrNone { |
|
|
|
if s3Error := enforceBucketPolicy(api.ObjectAPI, "s3:PutObject", bucket, r.URL); s3Error != ErrNone { |
|
|
|
writeErrorResponse(w, r, s3Error, r.URL.Path) |
|
|
|
writeErrorResponse(w, r, s3Error, r.URL.Path) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -424,7 +424,7 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req |
|
|
|
return |
|
|
|
return |
|
|
|
case authTypeAnonymous: |
|
|
|
case authTypeAnonymous: |
|
|
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html
|
|
|
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html
|
|
|
|
if s3Error := enforceBucketPolicy(api, "s3:PutObject", bucket, r.URL); s3Error != ErrNone { |
|
|
|
if s3Error := enforceBucketPolicy(api.ObjectAPI, "s3:PutObject", bucket, r.URL); s3Error != ErrNone { |
|
|
|
writeErrorResponse(w, r, s3Error, r.URL.Path) |
|
|
|
writeErrorResponse(w, r, s3Error, r.URL.Path) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -490,7 +490,7 @@ func (api objectAPIHandlers) NewMultipartUploadHandler(w http.ResponseWriter, r |
|
|
|
return |
|
|
|
return |
|
|
|
case authTypeAnonymous: |
|
|
|
case authTypeAnonymous: |
|
|
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/mpuAndPermissions.html
|
|
|
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/mpuAndPermissions.html
|
|
|
|
if s3Error := enforceBucketPolicy(api, "s3:PutObject", bucket, r.URL); s3Error != ErrNone { |
|
|
|
if s3Error := enforceBucketPolicy(api.ObjectAPI, "s3:PutObject", bucket, r.URL); s3Error != ErrNone { |
|
|
|
writeErrorResponse(w, r, s3Error, r.URL.Path) |
|
|
|
writeErrorResponse(w, r, s3Error, r.URL.Path) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -581,7 +581,7 @@ func (api objectAPIHandlers) PutObjectPartHandler(w http.ResponseWriter, r *http |
|
|
|
return |
|
|
|
return |
|
|
|
case authTypeAnonymous: |
|
|
|
case authTypeAnonymous: |
|
|
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/mpuAndPermissions.html
|
|
|
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/mpuAndPermissions.html
|
|
|
|
if s3Error := enforceBucketPolicy(api, "s3:PutObject", bucket, r.URL); s3Error != ErrNone { |
|
|
|
if s3Error := enforceBucketPolicy(api.ObjectAPI, "s3:PutObject", bucket, r.URL); s3Error != ErrNone { |
|
|
|
writeErrorResponse(w, r, s3Error, r.URL.Path) |
|
|
|
writeErrorResponse(w, r, s3Error, r.URL.Path) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -625,7 +625,7 @@ func (api objectAPIHandlers) AbortMultipartUploadHandler(w http.ResponseWriter, |
|
|
|
return |
|
|
|
return |
|
|
|
case authTypeAnonymous: |
|
|
|
case authTypeAnonymous: |
|
|
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/mpuAndPermissions.html
|
|
|
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/mpuAndPermissions.html
|
|
|
|
if s3Error := enforceBucketPolicy(api, "s3:AbortMultipartUpload", bucket, r.URL); s3Error != ErrNone { |
|
|
|
if s3Error := enforceBucketPolicy(api.ObjectAPI, "s3:AbortMultipartUpload", bucket, r.URL); s3Error != ErrNone { |
|
|
|
writeErrorResponse(w, r, s3Error, r.URL.Path) |
|
|
|
writeErrorResponse(w, r, s3Error, r.URL.Path) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -658,7 +658,7 @@ func (api objectAPIHandlers) ListObjectPartsHandler(w http.ResponseWriter, r *ht |
|
|
|
return |
|
|
|
return |
|
|
|
case authTypeAnonymous: |
|
|
|
case authTypeAnonymous: |
|
|
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/mpuAndPermissions.html
|
|
|
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/mpuAndPermissions.html
|
|
|
|
if s3Error := enforceBucketPolicy(api, "s3:ListMultipartUploadParts", bucket, r.URL); s3Error != ErrNone { |
|
|
|
if s3Error := enforceBucketPolicy(api.ObjectAPI, "s3:ListMultipartUploadParts", bucket, r.URL); s3Error != ErrNone { |
|
|
|
writeErrorResponse(w, r, s3Error, r.URL.Path) |
|
|
|
writeErrorResponse(w, r, s3Error, r.URL.Path) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -709,7 +709,7 @@ func (api objectAPIHandlers) CompleteMultipartUploadHandler(w http.ResponseWrite |
|
|
|
return |
|
|
|
return |
|
|
|
case authTypeAnonymous: |
|
|
|
case authTypeAnonymous: |
|
|
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/mpuAndPermissions.html
|
|
|
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/mpuAndPermissions.html
|
|
|
|
if s3Error := enforceBucketPolicy(api, "s3:PutObject", bucket, r.URL); s3Error != ErrNone { |
|
|
|
if s3Error := enforceBucketPolicy(api.ObjectAPI, "s3:PutObject", bucket, r.URL); s3Error != ErrNone { |
|
|
|
writeErrorResponse(w, r, s3Error, r.URL.Path) |
|
|
|
writeErrorResponse(w, r, s3Error, r.URL.Path) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -830,7 +830,7 @@ func (api objectAPIHandlers) DeleteObjectHandler(w http.ResponseWriter, r *http. |
|
|
|
return |
|
|
|
return |
|
|
|
case authTypeAnonymous: |
|
|
|
case authTypeAnonymous: |
|
|
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html
|
|
|
|
// http://docs.aws.amazon.com/AmazonS3/latest/dev/using-with-s3-actions.html
|
|
|
|
if s3Error := enforceBucketPolicy(api, "s3:DeleteObject", bucket, r.URL); s3Error != ErrNone { |
|
|
|
if s3Error := enforceBucketPolicy(api.ObjectAPI, "s3:DeleteObject", bucket, r.URL); s3Error != ErrNone { |
|
|
|
writeErrorResponse(w, r, s3Error, r.URL.Path) |
|
|
|
writeErrorResponse(w, r, s3Error, r.URL.Path) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|