From 41ec9d77596505dae3f0de0662db061fbaf168fc Mon Sep 17 00:00:00 2001 From: 7y-9 <121850020+7y-9@users.noreply.github.com> Date: Mon, 19 Feb 2024 19:07:48 +0800 Subject: [PATCH] refactor: put the auth outside (#5313) --- weed/s3api/s3api_bucket_handlers.go | 7 ------- weed/s3api/s3api_server.go | 3 ++- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/weed/s3api/s3api_bucket_handlers.go b/weed/s3api/s3api_bucket_handlers.go index 6ae6011f2..bb3939571 100644 --- a/weed/s3api/s3api_bucket_handlers.go +++ b/weed/s3api/s3api_bucket_handlers.go @@ -123,13 +123,6 @@ func (s3a *S3ApiServer) PutBucketHandler(w http.ResponseWriter, r *http.Request) return } - if s3a.iam.isEnabled() { - if _, errCode = s3a.iam.authRequest(r, s3_constants.ACTION_ADMIN); errCode != s3err.ErrNone { - s3err.WriteErrorResponse(w, r, errCode) - return - } - } - fn := func(entry *filer_pb.Entry) { if identityId := r.Header.Get(s3_constants.AmzIdentityId); identityId != "" { if entry.Extended == nil { diff --git a/weed/s3api/s3api_server.go b/weed/s3api/s3api_server.go index 7c4918a01..1477d650f 100644 --- a/weed/s3api/s3api_server.go +++ b/weed/s3api/s3api_server.go @@ -276,7 +276,8 @@ func (s3a *S3ApiServer) registerRouter(router *mux.Router) { bucket.Methods("HEAD").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.HeadBucketHandler, ACTION_READ)), "GET")) // PutBucket - bucket.Methods("PUT").HandlerFunc(track(s3a.PutBucketHandler, "PUT")) + bucket.Methods("PUT").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.PutBucketHandler, ACTION_ADMIN)), "PUT")) + // DeleteBucket bucket.Methods("DELETE").HandlerFunc(track(s3a.iam.Auth(s3a.cb.Limit(s3a.DeleteBucketHandler, ACTION_ADMIN)), "DELETE"))