aboutsummaryrefslogtreecommitdiff
path: root/weed/s3api/auth_credentials.go
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-05-30 22:57:41 -0700
committerchrislu <chris.lu@gmail.com>2022-05-30 22:57:41 -0700
commit27732ecfa4dcbe6d02af350244c53a3cb200a010 (patch)
tree09a90f52d976de50726eacb5616b59f374400b0b /weed/s3api/auth_credentials.go
parentf4a6da6cb276f1891b01097670b044fd4ee6139d (diff)
downloadseaweedfs-27732ecfa4dcbe6d02af350244c53a3cb200a010.tar.xz
seaweedfs-27732ecfa4dcbe6d02af350244c53a3cb200a010.zip
move s3 related constants from package http to s3_constants
Diffstat (limited to 'weed/s3api/auth_credentials.go')
-rw-r--r--weed/s3api/auth_credentials.go31
1 files changed, 15 insertions, 16 deletions
diff --git a/weed/s3api/auth_credentials.go b/weed/s3api/auth_credentials.go
index 3ab1df336..757e3ddd9 100644
--- a/weed/s3api/auth_credentials.go
+++ b/weed/s3api/auth_credentials.go
@@ -12,7 +12,6 @@ import (
"github.com/chrislusf/seaweedfs/weed/pb"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/pb/iam_pb"
- xhttp "github.com/chrislusf/seaweedfs/weed/s3api/http"
"github.com/chrislusf/seaweedfs/weed/s3api/s3_constants"
"github.com/chrislusf/seaweedfs/weed/s3api/s3err"
)
@@ -186,11 +185,11 @@ func (iam *IdentityAccessManagement) Auth(f http.HandlerFunc, action Action) htt
identity, errCode := iam.authRequest(r, action)
if errCode == s3err.ErrNone {
if identity != nil && identity.Name != "" {
- r.Header.Set(xhttp.AmzIdentityId, identity.Name)
+ r.Header.Set(s3_constants.AmzIdentityId, identity.Name)
if identity.isAdmin() {
- r.Header.Set(xhttp.AmzIsAdmin, "true")
- } else if _, ok := r.Header[xhttp.AmzIsAdmin]; ok {
- r.Header.Del(xhttp.AmzIsAdmin)
+ r.Header.Set(s3_constants.AmzIsAdmin, "true")
+ } else if _, ok := r.Header[s3_constants.AmzIsAdmin]; ok {
+ r.Header.Del(s3_constants.AmzIsAdmin)
}
}
f(w, r)
@@ -211,7 +210,7 @@ func (iam *IdentityAccessManagement) authRequest(r *http.Request, action Action)
return identity, s3err.ErrNone
case authTypeUnknown:
glog.V(3).Infof("unknown auth type")
- r.Header.Set(xhttp.AmzAuthType, "Unknown")
+ r.Header.Set(s3_constants.AmzAuthType, "Unknown")
return identity, s3err.ErrAccessDenied
case authTypePresignedV2, authTypeSignedV2:
glog.V(3).Infof("v2 auth type")
@@ -223,17 +222,17 @@ func (iam *IdentityAccessManagement) authRequest(r *http.Request, action Action)
authType = "SigV4"
case authTypePostPolicy:
glog.V(3).Infof("post policy auth type")
- r.Header.Set(xhttp.AmzAuthType, "PostPolicy")
+ r.Header.Set(s3_constants.AmzAuthType, "PostPolicy")
return identity, s3err.ErrNone
case authTypeJWT:
glog.V(3).Infof("jwt auth type")
- r.Header.Set(xhttp.AmzAuthType, "Jwt")
+ r.Header.Set(s3_constants.AmzAuthType, "Jwt")
return identity, s3err.ErrNotImplemented
case authTypeAnonymous:
authType = "Anonymous"
identity, found = iam.lookupAnonymous()
if !found {
- r.Header.Set(xhttp.AmzAuthType, authType)
+ r.Header.Set(s3_constants.AmzAuthType, authType)
return identity, s3err.ErrAccessDenied
}
default:
@@ -241,7 +240,7 @@ func (iam *IdentityAccessManagement) authRequest(r *http.Request, action Action)
}
if len(authType) > 0 {
- r.Header.Set(xhttp.AmzAuthType, authType)
+ r.Header.Set(s3_constants.AmzAuthType, authType)
}
if s3Err != s3err.ErrNone {
return identity, s3Err
@@ -249,7 +248,7 @@ func (iam *IdentityAccessManagement) authRequest(r *http.Request, action Action)
glog.V(3).Infof("user name: %v actions: %v, action: %v", identity.Name, identity.Actions, action)
- bucket, object := xhttp.GetBucketAndObject(r)
+ bucket, object := s3_constants.GetBucketAndObject(r)
if !identity.canDo(action, bucket, object) {
return identity, s3err.ErrAccessDenied
@@ -269,7 +268,7 @@ func (iam *IdentityAccessManagement) authUser(r *http.Request) (*Identity, s3err
return identity, s3err.ErrNone
case authTypeUnknown:
glog.V(3).Infof("unknown auth type")
- r.Header.Set(xhttp.AmzAuthType, "Unknown")
+ r.Header.Set(s3_constants.AmzAuthType, "Unknown")
return identity, s3err.ErrAccessDenied
case authTypePresignedV2, authTypeSignedV2:
glog.V(3).Infof("v2 auth type")
@@ -281,17 +280,17 @@ func (iam *IdentityAccessManagement) authUser(r *http.Request) (*Identity, s3err
authType = "SigV4"
case authTypePostPolicy:
glog.V(3).Infof("post policy auth type")
- r.Header.Set(xhttp.AmzAuthType, "PostPolicy")
+ r.Header.Set(s3_constants.AmzAuthType, "PostPolicy")
return identity, s3err.ErrNone
case authTypeJWT:
glog.V(3).Infof("jwt auth type")
- r.Header.Set(xhttp.AmzAuthType, "Jwt")
+ r.Header.Set(s3_constants.AmzAuthType, "Jwt")
return identity, s3err.ErrNotImplemented
case authTypeAnonymous:
authType = "Anonymous"
identity, found = iam.lookupAnonymous()
if !found {
- r.Header.Set(xhttp.AmzAuthType, authType)
+ r.Header.Set(s3_constants.AmzAuthType, authType)
return identity, s3err.ErrAccessDenied
}
default:
@@ -299,7 +298,7 @@ func (iam *IdentityAccessManagement) authUser(r *http.Request) (*Identity, s3err
}
if len(authType) > 0 {
- r.Header.Set(xhttp.AmzAuthType, authType)
+ r.Header.Set(s3_constants.AmzAuthType, authType)
}
glog.V(3).Infof("auth error: %v", s3Err)