|
@ -4,6 +4,7 @@ import ( |
|
|
"crypto/sha1" |
|
|
"crypto/sha1" |
|
|
"encoding/xml" |
|
|
"encoding/xml" |
|
|
"fmt" |
|
|
"fmt" |
|
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/s3api/s3account" |
|
|
"io" |
|
|
"io" |
|
|
"net/http" |
|
|
"net/http" |
|
|
"net/url" |
|
|
"net/url" |
|
@ -282,18 +283,22 @@ func (s3a *S3ApiServer) PutObjectPartHandler(w http.ResponseWriter, r *http.Requ |
|
|
if s3a.iam.isEnabled() { |
|
|
if s3a.iam.isEnabled() { |
|
|
rAuthType := getRequestAuthType(r) |
|
|
rAuthType := getRequestAuthType(r) |
|
|
var s3ErrCode s3err.ErrorCode |
|
|
var s3ErrCode s3err.ErrorCode |
|
|
|
|
|
var identity *Identity |
|
|
switch rAuthType { |
|
|
switch rAuthType { |
|
|
case authTypeStreamingSigned: |
|
|
case authTypeStreamingSigned: |
|
|
dataReader, _, s3ErrCode = s3a.iam.newSignV4ChunkedReader(r) |
|
|
|
|
|
|
|
|
dataReader, identity, s3ErrCode = s3a.iam.newSignV4ChunkedReader(r) |
|
|
case authTypeSignedV2, authTypePresignedV2: |
|
|
case authTypeSignedV2, authTypePresignedV2: |
|
|
_, s3ErrCode = s3a.iam.isReqAuthenticatedV2(r) |
|
|
|
|
|
|
|
|
identity, s3ErrCode = s3a.iam.isReqAuthenticatedV2(r) |
|
|
case authTypePresigned, authTypeSigned: |
|
|
case authTypePresigned, authTypeSigned: |
|
|
_, s3ErrCode = s3a.iam.reqSignatureV4Verify(r) |
|
|
|
|
|
|
|
|
identity, s3ErrCode = s3a.iam.reqSignatureV4Verify(r) |
|
|
} |
|
|
} |
|
|
if s3ErrCode != s3err.ErrNone { |
|
|
if s3ErrCode != s3err.ErrNone { |
|
|
s3err.WriteErrorResponse(w, r, s3ErrCode) |
|
|
s3err.WriteErrorResponse(w, r, s3ErrCode) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
if identity.AccountId != s3account.AccountAnonymous.Id { |
|
|
|
|
|
r.Header.Set(s3_constants.AmzAccountId, identity.AccountId) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
defer dataReader.Close() |
|
|
defer dataReader.Close() |
|
|
|
|
|
|
|
|