Taehyung Lim
2 weeks ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
38 additions and
42 deletions
-
weed/s3api/s3api_object_handlers_multipart.go
-
weed/s3api/s3api_object_handlers_put.go
-
weed/s3api/s3api_put_object_helper.go
|
|
@ -229,27 +229,10 @@ func (s3a *S3ApiServer) PutObjectPartHandler(w http.ResponseWriter, r *http.Requ |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
dataReader := r.Body |
|
|
|
rAuthType := getRequestAuthType(r) |
|
|
|
if s3a.iam.isEnabled() { |
|
|
|
var s3ErrCode s3err.ErrorCode |
|
|
|
switch rAuthType { |
|
|
|
case authTypeStreamingSigned, authTypeStreamingUnsigned: |
|
|
|
dataReader, s3ErrCode = s3a.iam.newChunkedReader(r) |
|
|
|
case authTypeSignedV2, authTypePresignedV2: |
|
|
|
_, s3ErrCode = s3a.iam.isReqAuthenticatedV2(r) |
|
|
|
case authTypePresigned, authTypeSigned: |
|
|
|
_, s3ErrCode = s3a.iam.reqSignatureV4Verify(r) |
|
|
|
} |
|
|
|
if s3ErrCode != s3err.ErrNone { |
|
|
|
s3err.WriteErrorResponse(w, r, s3ErrCode) |
|
|
|
return |
|
|
|
} |
|
|
|
} else { |
|
|
|
if authTypeStreamingSigned == rAuthType { |
|
|
|
s3err.WriteErrorResponse(w, r, s3err.ErrAuthNotSetup) |
|
|
|
return |
|
|
|
} |
|
|
|
dataReader, s3ErrCode := getRequestDataReader(s3a, r) |
|
|
|
if s3ErrCode != s3err.ErrNone { |
|
|
|
s3err.WriteErrorResponse(w, r, s3ErrCode) |
|
|
|
return |
|
|
|
} |
|
|
|
defer dataReader.Close() |
|
|
|
|
|
|
|
|
|
@ -47,27 +47,10 @@ func (s3a *S3ApiServer) PutObjectHandler(w http.ResponseWriter, r *http.Request) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
dataReader := r.Body |
|
|
|
rAuthType := getRequestAuthType(r) |
|
|
|
if s3a.iam.isEnabled() { |
|
|
|
var s3ErrCode s3err.ErrorCode |
|
|
|
switch rAuthType { |
|
|
|
case authTypeStreamingSigned, authTypeStreamingUnsigned: |
|
|
|
dataReader, s3ErrCode = s3a.iam.newChunkedReader(r) |
|
|
|
case authTypeSignedV2, authTypePresignedV2: |
|
|
|
_, s3ErrCode = s3a.iam.isReqAuthenticatedV2(r) |
|
|
|
case authTypePresigned, authTypeSigned: |
|
|
|
_, s3ErrCode = s3a.iam.reqSignatureV4Verify(r) |
|
|
|
} |
|
|
|
if s3ErrCode != s3err.ErrNone { |
|
|
|
s3err.WriteErrorResponse(w, r, s3ErrCode) |
|
|
|
return |
|
|
|
} |
|
|
|
} else { |
|
|
|
if authTypeStreamingSigned == rAuthType { |
|
|
|
s3err.WriteErrorResponse(w, r, s3err.ErrAuthNotSetup) |
|
|
|
return |
|
|
|
} |
|
|
|
dataReader, s3ErrCode := getRequestDataReader(s3a, r) |
|
|
|
if s3ErrCode != s3err.ErrNone { |
|
|
|
s3err.WriteErrorResponse(w, r, s3ErrCode) |
|
|
|
return |
|
|
|
} |
|
|
|
defer dataReader.Close() |
|
|
|
|
|
|
|
|
|
@ -0,0 +1,30 @@ |
|
|
|
package s3api |
|
|
|
|
|
|
|
import ( |
|
|
|
"io" |
|
|
|
"net/http" |
|
|
|
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/s3api/s3err" |
|
|
|
) |
|
|
|
|
|
|
|
func getRequestDataReader(s3a *S3ApiServer, r *http.Request) (io.ReadCloser, s3err.ErrorCode) { |
|
|
|
var s3ErrCode s3err.ErrorCode |
|
|
|
dataReader := r.Body |
|
|
|
rAuthType := getRequestAuthType(r) |
|
|
|
if s3a.iam.isEnabled() { |
|
|
|
switch rAuthType { |
|
|
|
case authTypeStreamingSigned, authTypeStreamingUnsigned: |
|
|
|
dataReader, s3ErrCode = s3a.iam.newChunkedReader(r) |
|
|
|
case authTypeSignedV2, authTypePresignedV2: |
|
|
|
_, s3ErrCode = s3a.iam.isReqAuthenticatedV2(r) |
|
|
|
case authTypePresigned, authTypeSigned: |
|
|
|
_, s3ErrCode = s3a.iam.reqSignatureV4Verify(r) |
|
|
|
} |
|
|
|
} else { |
|
|
|
if authTypeStreamingSigned == rAuthType { |
|
|
|
s3ErrCode = s3err.ErrAuthNotSetup |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return dataReader, s3ErrCode |
|
|
|
} |