mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 10:06:14 +00:00
Add ObjectNode provides S3-compatibile APIs. Fusion Storage interface expose two interface (POSIX and S3-compatible) for file operation. Signed-off-by: Mofei Zhang <mofei2816@gmail.com>
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
// Package s3 provides ...
|
|
package objectnode
|
|
|
|
import "net/http"
|
|
|
|
//https://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html#ConstructingTheAuthenticationHeader
|
|
|
|
type AuthType string
|
|
|
|
const (
|
|
SignatrueV2 AuthType = "signature_v2"
|
|
SignatrueV4 = "signature_v4"
|
|
PresignedV2 = "presigned_v2"
|
|
PresignedV4 = "presigned_v4"
|
|
)
|
|
|
|
type RequestAuthInfo struct {
|
|
authType AuthType
|
|
accessKey string
|
|
}
|
|
|
|
func parseRequestAuthInfo(r *http.Request) *RequestAuthInfo {
|
|
auth := new(RequestAuthInfo)
|
|
if isSignaturedV2(r) {
|
|
auth.authType = SignatrueV2
|
|
ai, _ := parseRequestAuthInfoV2(r)
|
|
if ai != nil {
|
|
auth.accessKey = ai.accessKeyId
|
|
}
|
|
} else if isSignaturedV4(r) {
|
|
auth.authType = SignatrueV4
|
|
ai, _ := parseRequestV4(r)
|
|
if ai != nil {
|
|
auth.accessKey = ai.Credential.AccessKey
|
|
}
|
|
} else if isPresignedSignaturedV2(r) {
|
|
auth.authType = PresignedV2
|
|
ai, _ := parsePresignedV2AuthInfo(r)
|
|
if ai != nil {
|
|
auth.accessKey = ai.accessKeyId
|
|
}
|
|
} else if isPresignedSignaturedV4(r) {
|
|
auth.authType = PresignedV4
|
|
ai, _ := parseRequestV4(r)
|
|
if ai != nil {
|
|
auth.accessKey = ai.Credential.AccessKey
|
|
}
|
|
}
|
|
|
|
return auth
|
|
}
|