|
@ -24,6 +24,10 @@ import ( |
|
|
"google.golang.org/grpc" |
|
|
"google.golang.org/grpc" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
const ( |
|
|
|
|
|
BucketPathTpl = "/{object:[a-z0-9][a-z0-9-]+[a-z0-9]}" |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
type S3ApiServerOption struct { |
|
|
type S3ApiServerOption struct { |
|
|
Filer pb.ServerAddress |
|
|
Filer pb.ServerAddress |
|
|
Port int |
|
|
Port int |
|
@ -163,55 +167,55 @@ func (s3a *S3ApiServer) registerRouter(router *mux.Router) { |
|
|
// objects with query
|
|
|
// objects with query
|
|
|
|
|
|
|
|
|
// CopyObjectPart
|
|
|
// CopyObjectPart
|
|
|
bucket.Methods(http.MethodPut).Path("/{object:.+}").HeadersRegexp("X-Amz-Copy-Source", `.*?(\/|%2F).*?`).HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.CopyObjectPartHandler, ACTION_WRITE)), "PUT")).Queries("partNumber", "{partNumber:[0-9]+}", "uploadId", "{uploadId:.*}") |
|
|
|
|
|
|
|
|
bucket.Methods(http.MethodPut).Path(BucketPathTpl).HeadersRegexp("X-Amz-Copy-Source", `.*?(\/|%2F).*?`).HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.CopyObjectPartHandler, ACTION_WRITE)), "PUT")).Queries("partNumber", "{partNumber:[0-9]+}", "uploadId", "{uploadId:.*}") |
|
|
// PutObjectPart
|
|
|
// PutObjectPart
|
|
|
bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.PutObjectPartHandler, ACTION_WRITE)), "PUT")).Queries("partNumber", "{partNumber:[0-9]+}", "uploadId", "{uploadId:.*}") |
|
|
|
|
|
|
|
|
bucket.Methods(http.MethodPut).Path(BucketPathTpl).HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.PutObjectPartHandler, ACTION_WRITE)), "PUT")).Queries("partNumber", "{partNumber:[0-9]+}", "uploadId", "{uploadId:.*}") |
|
|
// CompleteMultipartUpload
|
|
|
// CompleteMultipartUpload
|
|
|
bucket.Methods(http.MethodPost).Path("/{object:.+}").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.CompleteMultipartUploadHandler, ACTION_WRITE)), "POST")).Queries("uploadId", "{uploadId:.*}") |
|
|
|
|
|
|
|
|
bucket.Methods(http.MethodPost).Path(BucketPathTpl).HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.CompleteMultipartUploadHandler, ACTION_WRITE)), "POST")).Queries("uploadId", "{uploadId:.*}") |
|
|
// NewMultipartUpload
|
|
|
// NewMultipartUpload
|
|
|
bucket.Methods(http.MethodPost).Path("/{object:.+}").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.NewMultipartUploadHandler, ACTION_WRITE)), "POST")).Queries("uploads", "") |
|
|
|
|
|
|
|
|
bucket.Methods(http.MethodPost).Path(BucketPathTpl).HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.NewMultipartUploadHandler, ACTION_WRITE)), "POST")).Queries("uploads", "") |
|
|
// AbortMultipartUpload
|
|
|
// AbortMultipartUpload
|
|
|
bucket.Methods(http.MethodDelete).Path("/{object:.+}").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.AbortMultipartUploadHandler, ACTION_WRITE)), "DELETE")).Queries("uploadId", "{uploadId:.*}") |
|
|
|
|
|
|
|
|
bucket.Methods(http.MethodDelete).Path(BucketPathTpl).HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.AbortMultipartUploadHandler, ACTION_WRITE)), "DELETE")).Queries("uploadId", "{uploadId:.*}") |
|
|
// ListObjectParts
|
|
|
// ListObjectParts
|
|
|
bucket.Methods(http.MethodGet).Path("/{object:.+}").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.ListObjectPartsHandler, ACTION_READ)), "GET")).Queries("uploadId", "{uploadId:.*}") |
|
|
|
|
|
|
|
|
bucket.Methods(http.MethodGet).Path(BucketPathTpl).HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.ListObjectPartsHandler, ACTION_READ)), "GET")).Queries("uploadId", "{uploadId:.*}") |
|
|
// ListMultipartUploads
|
|
|
// ListMultipartUploads
|
|
|
bucket.Methods(http.MethodGet).HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.ListMultipartUploadsHandler, ACTION_READ)), "GET")).Queries("uploads", "") |
|
|
bucket.Methods(http.MethodGet).HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.ListMultipartUploadsHandler, ACTION_READ)), "GET")).Queries("uploads", "") |
|
|
|
|
|
|
|
|
// GetObjectTagging
|
|
|
// GetObjectTagging
|
|
|
bucket.Methods(http.MethodGet).Path("/{object:.+}").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.GetObjectTaggingHandler, ACTION_READ)), "GET")).Queries("tagging", "") |
|
|
|
|
|
|
|
|
bucket.Methods(http.MethodGet).Path(BucketPathTpl).HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.GetObjectTaggingHandler, ACTION_READ)), "GET")).Queries("tagging", "") |
|
|
// PutObjectTagging
|
|
|
// PutObjectTagging
|
|
|
bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.PutObjectTaggingHandler, ACTION_TAGGING)), "PUT")).Queries("tagging", "") |
|
|
|
|
|
|
|
|
bucket.Methods(http.MethodPut).Path(BucketPathTpl).HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.PutObjectTaggingHandler, ACTION_TAGGING)), "PUT")).Queries("tagging", "") |
|
|
// DeleteObjectTagging
|
|
|
// DeleteObjectTagging
|
|
|
bucket.Methods(http.MethodDelete).Path("/{object:.+}").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.DeleteObjectTaggingHandler, ACTION_TAGGING)), "DELETE")).Queries("tagging", "") |
|
|
|
|
|
|
|
|
bucket.Methods(http.MethodDelete).Path(BucketPathTpl).HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.DeleteObjectTaggingHandler, ACTION_TAGGING)), "DELETE")).Queries("tagging", "") |
|
|
|
|
|
|
|
|
// PutObjectACL
|
|
|
// PutObjectACL
|
|
|
bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.PutObjectAclHandler, ACTION_WRITE_ACP)), "PUT")).Queries("acl", "") |
|
|
|
|
|
|
|
|
bucket.Methods(http.MethodPut).Path(BucketPathTpl).HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.PutObjectAclHandler, ACTION_WRITE_ACP)), "PUT")).Queries("acl", "") |
|
|
// PutObjectRetention
|
|
|
// PutObjectRetention
|
|
|
bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.PutObjectRetentionHandler, ACTION_WRITE)), "PUT")).Queries("retention", "") |
|
|
|
|
|
|
|
|
bucket.Methods(http.MethodPut).Path(BucketPathTpl).HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.PutObjectRetentionHandler, ACTION_WRITE)), "PUT")).Queries("retention", "") |
|
|
// PutObjectLegalHold
|
|
|
// PutObjectLegalHold
|
|
|
bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.PutObjectLegalHoldHandler, ACTION_WRITE)), "PUT")).Queries("legal-hold", "") |
|
|
|
|
|
|
|
|
bucket.Methods(http.MethodPut).Path(BucketPathTpl).HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.PutObjectLegalHoldHandler, ACTION_WRITE)), "PUT")).Queries("legal-hold", "") |
|
|
// PutObjectLockConfiguration
|
|
|
// PutObjectLockConfiguration
|
|
|
bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.PutObjectLockConfigurationHandler, ACTION_WRITE)), "PUT")).Queries("object-lock", "") |
|
|
|
|
|
|
|
|
bucket.Methods(http.MethodPut).Path(BucketPathTpl).HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.PutObjectLockConfigurationHandler, ACTION_WRITE)), "PUT")).Queries("object-lock", "") |
|
|
|
|
|
|
|
|
// GetObjectACL
|
|
|
// GetObjectACL
|
|
|
bucket.Methods(http.MethodGet).Path("/{object:.+}").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.GetObjectAclHandler, ACTION_READ_ACP)), "GET")).Queries("acl", "") |
|
|
|
|
|
|
|
|
bucket.Methods(http.MethodGet).Path(BucketPathTpl).HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.GetObjectAclHandler, ACTION_READ_ACP)), "GET")).Queries("acl", "") |
|
|
|
|
|
|
|
|
// objects with query
|
|
|
// objects with query
|
|
|
|
|
|
|
|
|
// raw objects
|
|
|
// raw objects
|
|
|
|
|
|
|
|
|
// HeadObject
|
|
|
// HeadObject
|
|
|
bucket.Methods(http.MethodHead).Path("/{object:.+}").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.HeadObjectHandler, ACTION_READ)), "GET")) |
|
|
|
|
|
|
|
|
bucket.Methods(http.MethodHead).Path(BucketPathTpl).HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.HeadObjectHandler, ACTION_READ)), "GET")) |
|
|
|
|
|
|
|
|
// GetObject, but directory listing is not supported
|
|
|
// GetObject, but directory listing is not supported
|
|
|
bucket.Methods(http.MethodGet).Path("/{object:.+}").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.GetObjectHandler, ACTION_READ)), "GET")) |
|
|
|
|
|
|
|
|
bucket.Methods(http.MethodGet).Path(BucketPathTpl).HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.GetObjectHandler, ACTION_READ)), "GET")) |
|
|
|
|
|
|
|
|
// CopyObject
|
|
|
// CopyObject
|
|
|
bucket.Methods(http.MethodPut).Path("/{object:.+}").HeadersRegexp("X-Amz-Copy-Source", ".*?(\\/|%2F).*?").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.CopyObjectHandler, ACTION_WRITE)), "COPY")) |
|
|
|
|
|
|
|
|
bucket.Methods(http.MethodPut).Path(BucketPathTpl).HeadersRegexp("X-Amz-Copy-Source", ".*?(\\/|%2F).*?").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.CopyObjectHandler, ACTION_WRITE)), "COPY")) |
|
|
// PutObject
|
|
|
// PutObject
|
|
|
bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.PutObjectHandler, ACTION_WRITE)), "PUT")) |
|
|
|
|
|
|
|
|
bucket.Methods(http.MethodPut).Path(BucketPathTpl).HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.PutObjectHandler, ACTION_WRITE)), "PUT")) |
|
|
// DeleteObject
|
|
|
// DeleteObject
|
|
|
bucket.Methods(http.MethodDelete).Path("/{object:.+}").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.DeleteObjectHandler, ACTION_WRITE)), "DELETE")) |
|
|
|
|
|
|
|
|
bucket.Methods(http.MethodDelete).Path(BucketPathTpl).HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.DeleteObjectHandler, ACTION_WRITE)), "DELETE")) |
|
|
|
|
|
|
|
|
// raw objects
|
|
|
// raw objects
|
|
|
|
|
|
|
|
|