|
|
@ -39,15 +39,6 @@ func (api CloudStorageAPI) GetObjectHandler(w http.ResponseWriter, req *http.Req |
|
|
|
bucket = vars["bucket"] |
|
|
|
bucket = vars["bucket"] |
|
|
|
object = vars["object"] |
|
|
|
object = vars["object"] |
|
|
|
|
|
|
|
|
|
|
|
if !api.Anonymous { |
|
|
|
|
|
|
|
if isRequestRequiresACLCheck(req) { |
|
|
|
|
|
|
|
if api.Filesystem.IsPrivateBucket(bucket) { |
|
|
|
|
|
|
|
writeErrorResponse(w, req, AccessDenied, req.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
metadata, err := api.Filesystem.GetObjectMetadata(bucket, object) |
|
|
|
metadata, err := api.Filesystem.GetObjectMetadata(bucket, object) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
errorIf(err.Trace(), "GetObject failed.", nil) |
|
|
|
errorIf(err.Trace(), "GetObject failed.", nil) |
|
|
@ -87,15 +78,6 @@ func (api CloudStorageAPI) HeadObjectHandler(w http.ResponseWriter, req *http.Re |
|
|
|
bucket = vars["bucket"] |
|
|
|
bucket = vars["bucket"] |
|
|
|
object = vars["object"] |
|
|
|
object = vars["object"] |
|
|
|
|
|
|
|
|
|
|
|
if !api.Anonymous { |
|
|
|
|
|
|
|
if isRequestRequiresACLCheck(req) { |
|
|
|
|
|
|
|
if api.Filesystem.IsPrivateBucket(bucket) { |
|
|
|
|
|
|
|
writeErrorResponse(w, req, AccessDenied, req.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
metadata, err := api.Filesystem.GetObjectMetadata(bucket, object) |
|
|
|
metadata, err := api.Filesystem.GetObjectMetadata(bucket, object) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
switch err.ToGoError().(type) { |
|
|
|
switch err.ToGoError().(type) { |
|
|
@ -125,15 +107,6 @@ func (api CloudStorageAPI) PutObjectHandler(w http.ResponseWriter, req *http.Req |
|
|
|
bucket = vars["bucket"] |
|
|
|
bucket = vars["bucket"] |
|
|
|
object = vars["object"] |
|
|
|
object = vars["object"] |
|
|
|
|
|
|
|
|
|
|
|
if !api.Anonymous { |
|
|
|
|
|
|
|
if isRequestRequiresACLCheck(req) { |
|
|
|
|
|
|
|
if api.Filesystem.IsPrivateBucket(bucket) || api.Filesystem.IsReadOnlyBucket(bucket) { |
|
|
|
|
|
|
|
writeErrorResponse(w, req, AccessDenied, req.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// get Content-MD5 sent by client and verify if valid
|
|
|
|
// get Content-MD5 sent by client and verify if valid
|
|
|
|
md5 := req.Header.Get("Content-MD5") |
|
|
|
md5 := req.Header.Get("Content-MD5") |
|
|
|
if !isValidMD5(md5) { |
|
|
|
if !isValidMD5(md5) { |
|
|
@ -153,26 +126,24 @@ func (api CloudStorageAPI) PutObjectHandler(w http.ResponseWriter, req *http.Req |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var signature *fs.Signature |
|
|
|
var signature *fs.Signature |
|
|
|
if !api.Anonymous { |
|
|
|
if isRequestSignatureV4(req) { |
|
|
|
if isRequestSignatureV4(req) { |
|
|
|
// Init signature V4 verification
|
|
|
|
// Init signature V4 verification
|
|
|
|
var err *probe.Error |
|
|
|
var err *probe.Error |
|
|
|
signature, err = initSignatureV4(req) |
|
|
|
signature, err = initSignatureV4(req) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
switch err.ToGoError() { |
|
|
|
switch err.ToGoError() { |
|
|
|
case errInvalidRegion: |
|
|
|
case errInvalidRegion: |
|
|
|
errorIf(err.Trace(), "Unknown region in authorization header.", nil) |
|
|
|
errorIf(err.Trace(), "Unknown region in authorization header.", nil) |
|
|
|
writeErrorResponse(w, req, AuthorizationHeaderMalformed, req.URL.Path) |
|
|
|
writeErrorResponse(w, req, AuthorizationHeaderMalformed, req.URL.Path) |
|
|
|
return |
|
|
|
return |
|
|
|
case errAccessKeyIDInvalid: |
|
|
|
case errAccessKeyIDInvalid: |
|
|
|
errorIf(err.Trace(), "Invalid access key id.", nil) |
|
|
|
errorIf(err.Trace(), "Invalid access key id.", nil) |
|
|
|
writeErrorResponse(w, req, InvalidAccessKeyID, req.URL.Path) |
|
|
|
writeErrorResponse(w, req, InvalidAccessKeyID, req.URL.Path) |
|
|
|
return |
|
|
|
return |
|
|
|
default: |
|
|
|
default: |
|
|
|
errorIf(err.Trace(), "Initializing signature v4 failed.", nil) |
|
|
|
errorIf(err.Trace(), "Initializing signature v4 failed.", nil) |
|
|
|
writeErrorResponse(w, req, InternalError, req.URL.Path) |
|
|
|
writeErrorResponse(w, req, InternalError, req.URL.Path) |
|
|
|
return |
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -219,14 +190,6 @@ func (api CloudStorageAPI) NewMultipartUploadHandler(w http.ResponseWriter, req |
|
|
|
bucket = vars["bucket"] |
|
|
|
bucket = vars["bucket"] |
|
|
|
object = vars["object"] |
|
|
|
object = vars["object"] |
|
|
|
|
|
|
|
|
|
|
|
if !api.Anonymous { |
|
|
|
|
|
|
|
// Unauthorized multipart uploads are not supported
|
|
|
|
|
|
|
|
if isRequestRequiresACLCheck(req) { |
|
|
|
|
|
|
|
writeErrorResponse(w, req, AccessDenied, req.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uploadID, err := api.Filesystem.NewMultipartUpload(bucket, object) |
|
|
|
uploadID, err := api.Filesystem.NewMultipartUpload(bucket, object) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
errorIf(err.Trace(), "NewMultipartUpload failed.", nil) |
|
|
|
errorIf(err.Trace(), "NewMultipartUpload failed.", nil) |
|
|
@ -261,13 +224,6 @@ func (api CloudStorageAPI) PutObjectPartHandler(w http.ResponseWriter, req *http |
|
|
|
bucket := vars["bucket"] |
|
|
|
bucket := vars["bucket"] |
|
|
|
object := vars["object"] |
|
|
|
object := vars["object"] |
|
|
|
|
|
|
|
|
|
|
|
if !api.Anonymous { |
|
|
|
|
|
|
|
if isRequestRequiresACLCheck(req) { |
|
|
|
|
|
|
|
writeErrorResponse(w, req, AccessDenied, req.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// get Content-MD5 sent by client and verify if valid
|
|
|
|
// get Content-MD5 sent by client and verify if valid
|
|
|
|
md5 := req.Header.Get("Content-MD5") |
|
|
|
md5 := req.Header.Get("Content-MD5") |
|
|
|
if !isValidMD5(md5) { |
|
|
|
if !isValidMD5(md5) { |
|
|
@ -302,26 +258,24 @@ func (api CloudStorageAPI) PutObjectPartHandler(w http.ResponseWriter, req *http |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var signature *fs.Signature |
|
|
|
var signature *fs.Signature |
|
|
|
if !api.Anonymous { |
|
|
|
if isRequestSignatureV4(req) { |
|
|
|
if isRequestSignatureV4(req) { |
|
|
|
// Init signature V4 verification
|
|
|
|
// Init signature V4 verification
|
|
|
|
var err *probe.Error |
|
|
|
var err *probe.Error |
|
|
|
signature, err = initSignatureV4(req) |
|
|
|
signature, err = initSignatureV4(req) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
switch err.ToGoError() { |
|
|
|
switch err.ToGoError() { |
|
|
|
case errInvalidRegion: |
|
|
|
case errInvalidRegion: |
|
|
|
errorIf(err.Trace(), "Unknown region in authorization header.", nil) |
|
|
|
errorIf(err.Trace(), "Unknown region in authorization header.", nil) |
|
|
|
writeErrorResponse(w, req, AuthorizationHeaderMalformed, req.URL.Path) |
|
|
|
writeErrorResponse(w, req, AuthorizationHeaderMalformed, req.URL.Path) |
|
|
|
return |
|
|
|
return |
|
|
|
case errAccessKeyIDInvalid: |
|
|
|
case errAccessKeyIDInvalid: |
|
|
|
errorIf(err.Trace(), "Invalid access key id.", nil) |
|
|
|
errorIf(err.Trace(), "Invalid access key id.", nil) |
|
|
|
writeErrorResponse(w, req, InvalidAccessKeyID, req.URL.Path) |
|
|
|
writeErrorResponse(w, req, InvalidAccessKeyID, req.URL.Path) |
|
|
|
return |
|
|
|
return |
|
|
|
default: |
|
|
|
default: |
|
|
|
errorIf(err.Trace(), "Initializing signature v4 failed.", nil) |
|
|
|
errorIf(err.Trace(), "Initializing signature v4 failed.", nil) |
|
|
|
writeErrorResponse(w, req, InternalError, req.URL.Path) |
|
|
|
writeErrorResponse(w, req, InternalError, req.URL.Path) |
|
|
|
return |
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -361,13 +315,6 @@ func (api CloudStorageAPI) AbortMultipartUploadHandler(w http.ResponseWriter, re |
|
|
|
bucket := vars["bucket"] |
|
|
|
bucket := vars["bucket"] |
|
|
|
object := vars["object"] |
|
|
|
object := vars["object"] |
|
|
|
|
|
|
|
|
|
|
|
if !api.Anonymous { |
|
|
|
|
|
|
|
if isRequestRequiresACLCheck(req) { |
|
|
|
|
|
|
|
writeErrorResponse(w, req, AccessDenied, req.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
objectResourcesMetadata := getObjectResources(req.URL.Query()) |
|
|
|
objectResourcesMetadata := getObjectResources(req.URL.Query()) |
|
|
|
err := api.Filesystem.AbortMultipartUpload(bucket, object, objectResourcesMetadata.UploadID) |
|
|
|
err := api.Filesystem.AbortMultipartUpload(bucket, object, objectResourcesMetadata.UploadID) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
@ -397,13 +344,6 @@ func (api CloudStorageAPI) ListObjectPartsHandler(w http.ResponseWriter, req *ht |
|
|
|
bucket := vars["bucket"] |
|
|
|
bucket := vars["bucket"] |
|
|
|
object := vars["object"] |
|
|
|
object := vars["object"] |
|
|
|
|
|
|
|
|
|
|
|
if !api.Anonymous { |
|
|
|
|
|
|
|
if isRequestRequiresACLCheck(req) { |
|
|
|
|
|
|
|
writeErrorResponse(w, req, AccessDenied, req.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
objectResourcesMetadata := getObjectResources(req.URL.Query()) |
|
|
|
objectResourcesMetadata := getObjectResources(req.URL.Query()) |
|
|
|
if objectResourcesMetadata.PartNumberMarker < 0 { |
|
|
|
if objectResourcesMetadata.PartNumberMarker < 0 { |
|
|
|
writeErrorResponse(w, req, InvalidPartNumberMarker, req.URL.Path) |
|
|
|
writeErrorResponse(w, req, InvalidPartNumberMarker, req.URL.Path) |
|
|
@ -450,35 +390,26 @@ func (api CloudStorageAPI) CompleteMultipartUploadHandler(w http.ResponseWriter, |
|
|
|
bucket := vars["bucket"] |
|
|
|
bucket := vars["bucket"] |
|
|
|
object := vars["object"] |
|
|
|
object := vars["object"] |
|
|
|
|
|
|
|
|
|
|
|
if !api.Anonymous { |
|
|
|
|
|
|
|
if isRequestRequiresACLCheck(req) { |
|
|
|
|
|
|
|
writeErrorResponse(w, req, AccessDenied, req.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
objectResourcesMetadata := getObjectResources(req.URL.Query()) |
|
|
|
objectResourcesMetadata := getObjectResources(req.URL.Query()) |
|
|
|
var signature *fs.Signature |
|
|
|
var signature *fs.Signature |
|
|
|
if !api.Anonymous { |
|
|
|
if isRequestSignatureV4(req) { |
|
|
|
if isRequestSignatureV4(req) { |
|
|
|
// Init signature V4 verification
|
|
|
|
// Init signature V4 verification
|
|
|
|
var err *probe.Error |
|
|
|
var err *probe.Error |
|
|
|
signature, err = initSignatureV4(req) |
|
|
|
signature, err = initSignatureV4(req) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
switch err.ToGoError() { |
|
|
|
switch err.ToGoError() { |
|
|
|
case errInvalidRegion: |
|
|
|
case errInvalidRegion: |
|
|
|
errorIf(err.Trace(), "Unknown region in authorization header.", nil) |
|
|
|
errorIf(err.Trace(), "Unknown region in authorization header.", nil) |
|
|
|
writeErrorResponse(w, req, AuthorizationHeaderMalformed, req.URL.Path) |
|
|
|
writeErrorResponse(w, req, AuthorizationHeaderMalformed, req.URL.Path) |
|
|
|
return |
|
|
|
return |
|
|
|
case errAccessKeyIDInvalid: |
|
|
|
case errAccessKeyIDInvalid: |
|
|
|
errorIf(err.Trace(), "Invalid access key id.", nil) |
|
|
|
errorIf(err.Trace(), "Invalid access key id.", nil) |
|
|
|
writeErrorResponse(w, req, InvalidAccessKeyID, req.URL.Path) |
|
|
|
writeErrorResponse(w, req, InvalidAccessKeyID, req.URL.Path) |
|
|
|
return |
|
|
|
return |
|
|
|
default: |
|
|
|
default: |
|
|
|
errorIf(err.Trace(), "Initializing signature v4 failed.", nil) |
|
|
|
errorIf(err.Trace(), "Initializing signature v4 failed.", nil) |
|
|
|
writeErrorResponse(w, req, InternalError, req.URL.Path) |
|
|
|
writeErrorResponse(w, req, InternalError, req.URL.Path) |
|
|
|
return |
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -528,15 +459,6 @@ func (api CloudStorageAPI) DeleteObjectHandler(w http.ResponseWriter, req *http. |
|
|
|
bucket := vars["bucket"] |
|
|
|
bucket := vars["bucket"] |
|
|
|
object := vars["object"] |
|
|
|
object := vars["object"] |
|
|
|
|
|
|
|
|
|
|
|
if !api.Anonymous { |
|
|
|
|
|
|
|
if isRequestRequiresACLCheck(req) { |
|
|
|
|
|
|
|
if api.Filesystem.IsPrivateBucket(bucket) || api.Filesystem.IsReadOnlyBucket(bucket) { |
|
|
|
|
|
|
|
writeErrorResponse(w, req, AccessDenied, req.URL.Path) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
err := api.Filesystem.DeleteObject(bucket, object) |
|
|
|
err := api.Filesystem.DeleteObject(bucket, object) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
errorIf(err.Trace(), "DeleteObject failed.", nil) |
|
|
|
errorIf(err.Trace(), "DeleteObject failed.", nil) |
|
|
|