aboutsummaryrefslogtreecommitdiff
path: root/weed/s3api
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-09-14 23:06:44 -0700
committerchrislu <chris.lu@gmail.com>2022-09-14 23:06:44 -0700
commit21c058790010aa9224568248f2d9bf9c324b6747 (patch)
treeef2e2a1693c0563f8e44c099d1fee929f40863ff /weed/s3api
parentc8645fd2323d97164489e0429ed140f84002e61e (diff)
downloadseaweedfs-21c058790010aa9224568248f2d9bf9c324b6747.tar.xz
seaweedfs-21c058790010aa9224568248f2d9bf9c324b6747.zip
go fmt
Diffstat (limited to 'weed/s3api')
-rw-r--r--weed/s3api/auth_credentials_subscribe.go4
-rw-r--r--weed/s3api/auth_signature_v2.go3
-rw-r--r--weed/s3api/auth_signature_v4.go34
-rw-r--r--weed/s3api/chunked_reader_v4.go6
-rw-r--r--weed/s3api/policy/post-policy.go11
-rw-r--r--weed/s3api/s3api_object_multipart_handlers.go2
6 files changed, 31 insertions, 29 deletions
diff --git a/weed/s3api/auth_credentials_subscribe.go b/weed/s3api/auth_credentials_subscribe.go
index 37e5a9023..f6b5b3d80 100644
--- a/weed/s3api/auth_credentials_subscribe.go
+++ b/weed/s3api/auth_credentials_subscribe.go
@@ -42,7 +42,7 @@ func (s3a *S3ApiServer) subscribeMetaEvents(clientName string, prefix string, la
})
}
-//reload iam config
+// reload iam config
func (s3a *S3ApiServer) onIamConfigUpdate(dir, filename string, content []byte) error {
if dir == filer.IamConfigDirectory && filename == filer.IamIdentityFile {
if err := s3a.iam.LoadS3ApiConfigurationFromBytes(content); err != nil {
@@ -53,7 +53,7 @@ func (s3a *S3ApiServer) onIamConfigUpdate(dir, filename string, content []byte)
return nil
}
-//reload circuit breaker config
+// reload circuit breaker config
func (s3a *S3ApiServer) onCircuitBreakerConfigUpdate(dir, filename string, content []byte) error {
if dir == s3_constants.CircuitBreakerConfigDir && filename == s3_constants.CircuitBreakerConfigFile {
if err := s3a.cb.LoadS3ApiConfigurationFromBytes(content); err != nil {
diff --git a/weed/s3api/auth_signature_v2.go b/weed/s3api/auth_signature_v2.go
index e57ed51db..a30cec5e8 100644
--- a/weed/s3api/auth_signature_v2.go
+++ b/weed/s3api/auth_signature_v2.go
@@ -174,7 +174,8 @@ func (iam *IdentityAccessManagement) doesSignV2Match(r *http.Request) (*Identity
}
// doesPresignV2SignatureMatch - Verify query headers with presigned signature
-// - http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html#RESTAuthenticationQueryStringAuth
+// - http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html#RESTAuthenticationQueryStringAuth
+//
// returns ErrNone if matches. S3 errors otherwise.
func (iam *IdentityAccessManagement) doesPresignV2SignatureMatch(r *http.Request) (*Identity, s3err.ErrorCode) {
diff --git a/weed/s3api/auth_signature_v4.go b/weed/s3api/auth_signature_v4.go
index e7020e9ed..bd78f471d 100644
--- a/weed/s3api/auth_signature_v4.go
+++ b/weed/s3api/auth_signature_v4.go
@@ -198,9 +198,8 @@ func (c credentialHeader) getScope() string {
}, "/")
}
-// Authorization: algorithm Credential=accessKeyID/credScope, \
-// SignedHeaders=signedHeaders, Signature=signature
-//
+// Authorization: algorithm Credential=accessKeyID/credScope, \
+// SignedHeaders=signedHeaders, Signature=signature
func parseSignV4(v4Auth string) (sv signValues, aec s3err.ErrorCode) {
// Replace all spaced strings, some clients can send spaced
// parameters and some won't. So we pro-actively remove any spaces
@@ -310,7 +309,8 @@ func parseSignature(signElement string) (string, s3err.ErrorCode) {
}
// doesPolicySignatureMatch - Verify query headers with post policy
-// - http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-HTTPPOSTConstructPolicy.html
+// - http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-HTTPPOSTConstructPolicy.html
+//
// returns ErrNone if the signature matches.
func (iam *IdentityAccessManagement) doesPolicySignatureV4Match(formValues http.Header) s3err.ErrorCode {
@@ -341,7 +341,7 @@ func (iam *IdentityAccessManagement) doesPolicySignatureV4Match(formValues http.
}
// check query headers with presigned signature
-// - http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html
+// - http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html
func (iam *IdentityAccessManagement) doesPresignedSignatureMatch(hashedPayload string, r *http.Request) (*Identity, s3err.ErrorCode) {
// Copy request
@@ -476,12 +476,12 @@ type preSignValues struct {
// Parses signature version '4' query string of the following form.
//
-// querystring = X-Amz-Algorithm=algorithm
-// querystring += &X-Amz-Credential= urlencode(accessKey + '/' + credential_scope)
-// querystring += &X-Amz-Date=date
-// querystring += &X-Amz-Expires=timeout interval
-// querystring += &X-Amz-SignedHeaders=signed_headers
-// querystring += &X-Amz-Signature=signature
+// querystring = X-Amz-Algorithm=algorithm
+// querystring += &X-Amz-Credential= urlencode(accessKey + '/' + credential_scope)
+// querystring += &X-Amz-Date=date
+// querystring += &X-Amz-Expires=timeout interval
+// querystring += &X-Amz-SignedHeaders=signed_headers
+// querystring += &X-Amz-Signature=signature
//
// verifies if any of the necessary query params are missing in the presigned request.
func doesV4PresignParamsExist(query url.Values) s3err.ErrorCode {
@@ -636,13 +636,13 @@ func getScope(t time.Time, region string) string {
// getCanonicalRequest generate a canonical request of style
//
// canonicalRequest =
-// <HTTPMethod>\n
-// <CanonicalURI>\n
-// <CanonicalQueryString>\n
-// <CanonicalHeaders>\n
-// <SignedHeaders>\n
-// <HashedPayload>
//
+// <HTTPMethod>\n
+// <CanonicalURI>\n
+// <CanonicalQueryString>\n
+// <CanonicalHeaders>\n
+// <SignedHeaders>\n
+// <HashedPayload>
func getCanonicalRequest(extractedSignedHeaders http.Header, payload, queryStr, urlPath, method string) string {
rawQuery := strings.Replace(queryStr, "+", "%20", -1)
encodedPath := encodePath(urlPath)
diff --git a/weed/s3api/chunked_reader_v4.go b/weed/s3api/chunked_reader_v4.go
index ed7b5d0e1..c8c823907 100644
--- a/weed/s3api/chunked_reader_v4.go
+++ b/weed/s3api/chunked_reader_v4.go
@@ -55,7 +55,8 @@ func getChunkSignature(secretKey string, seedSignature string, region string, da
}
// calculateSeedSignature - Calculate seed signature in accordance with
-// - http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-streaming.html
+// - http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-streaming.html
+//
// returns signature, error otherwise if the signature mismatches or any other
// error while parsing and validating.
func (iam *IdentityAccessManagement) calculateSeedSignature(r *http.Request) (cred *Credential, signature string, region string, date time.Time, errCode s3err.ErrorCode) {
@@ -372,7 +373,8 @@ const s3ChunkSignatureStr = ";chunk-signature="
// parses3ChunkExtension removes any s3 specific chunk-extension from buf.
// For example,
-// "10000;chunk-signature=..." => "10000", "chunk-signature=..."
+//
+// "10000;chunk-signature=..." => "10000", "chunk-signature=..."
func parseS3ChunkExtension(buf []byte) ([]byte, []byte) {
buf = trimTrailingWhitespace(buf)
semi := bytes.Index(buf, []byte(s3ChunkSignatureStr))
diff --git a/weed/s3api/policy/post-policy.go b/weed/s3api/policy/post-policy.go
index 40e1b99ba..64b696ac8 100644
--- a/weed/s3api/policy/post-policy.go
+++ b/weed/s3api/policy/post-policy.go
@@ -34,12 +34,11 @@ const expirationDateFormat = "2006-01-02T15:04:05.999Z"
//
// Example:
//
-// policyCondition {
-// matchType: "$eq",
-// key: "$Content-Type",
-// value: "image/png",
-// }
-//
+// policyCondition {
+// matchType: "$eq",
+// key: "$Content-Type",
+// value: "image/png",
+// }
type policyCondition struct {
matchType string
condition string
diff --git a/weed/s3api/s3api_object_multipart_handlers.go b/weed/s3api/s3api_object_multipart_handlers.go
index 898f5c16b..96000310c 100644
--- a/weed/s3api/s3api_object_multipart_handlers.go
+++ b/weed/s3api/s3api_object_multipart_handlers.go
@@ -281,7 +281,7 @@ func (s3a *S3ApiServer) generateUploadID(object string) string {
return fmt.Sprintf("%x", h.Sum(nil))
}
-//Check object name and uploadID when processing multipart uploading
+// Check object name and uploadID when processing multipart uploading
func (s3a *S3ApiServer) checkUploadId(object string, id string) error {
hash := s3a.generateUploadID(object)