add s3 signature tests and prepare implementation of STREAMING-UNSIGNED-PAYLOAD-TRAILER (#6525)

* add tests for s3 signature

* add test for newSignV4ChunkedReader.Read()

* add glog import
This commit is contained in:
Tom Crasset
2025-02-07 19:54:31 +01:00
committed by GitHub
parent e8d8bfcccc
commit a7b964af96
7 changed files with 208 additions and 8 deletions

View File

@@ -29,6 +29,7 @@ import (
"net/http"
"time"
"github.com/seaweedfs/seaweedfs/weed/glog"
"github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants"
"github.com/seaweedfs/seaweedfs/weed/s3api/s3err"
@@ -54,14 +55,21 @@ func (iam *IdentityAccessManagement) calculateSeedSignature(r *http.Request) (cr
return nil, "", "", time.Time{}, errCode
}
// Payload streaming.
payload := streamingContentSHA256
contentSha256Header := req.Header.Get("X-Amz-Content-Sha256")
switch contentSha256Header {
// Payload for STREAMING signature should be 'STREAMING-AWS4-HMAC-SHA256-PAYLOAD'
if payload != req.Header.Get("X-Amz-Content-Sha256") {
case streamingContentSHA256:
glog.V(3).Infof("streaming content sha256")
case streamingUnsignedPayload:
glog.V(3).Infof("streaming unsigned payload")
default:
return nil, "", "", time.Time{}, s3err.ErrContentSHA256Mismatch
}
// Payload streaming.
payload := contentSha256Header
// Extract all the signed headers along with its values.
extractedSignedHeaders, errCode := extractSignedHeaders(signV4Values.SignedHeaders, r)
if errCode != s3err.ErrNone {