diff options
| author | LHHDZ <changlin.shi@ly.com> | 2022-10-02 10:18:00 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-01 19:18:00 -0700 |
| commit | e9584d96615870176d9fd5317b31695e87ff7b7e (patch) | |
| tree | 279e2eaca22ac6847c9cfcc946ccd6d9f1eb5329 /weed/s3api/s3api_acp.go | |
| parent | 6fa3d0cc463fd866828ee071d295eab4eb725f4b (diff) | |
| download | seaweedfs-e9584d96615870176d9fd5317b31695e87ff7b7e.tar.xz seaweedfs-e9584d96615870176d9fd5317b31695e87ff7b7e.zip | |
add ownership rest apis (#3765)
Diffstat (limited to 'weed/s3api/s3api_acp.go')
| -rw-r--r-- | weed/s3api/s3api_acp.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/weed/s3api/s3api_acp.go b/weed/s3api/s3api_acp.go new file mode 100644 index 000000000..0a79990f5 --- /dev/null +++ b/weed/s3api/s3api_acp.go @@ -0,0 +1,28 @@ +package s3api + +import ( + "github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants" + "github.com/seaweedfs/seaweedfs/weed/s3api/s3err" + "net/http" +) + +func getAccountId(r *http.Request) string { + id := r.Header.Get(s3_constants.AmzAccountId) + if len(id) == 0 { + return AccountAnonymous.Id + } else { + return id + } +} + +func (s3a *S3ApiServer) checkAccessByOwnership(r *http.Request, bucket string) s3err.ErrorCode { + metadata, errCode := s3a.bucketRegistry.GetBucketMetadata(bucket) + if errCode != s3err.ErrNone { + return errCode + } + accountId := getAccountId(r) + if accountId == AccountAdmin.Id || accountId == *metadata.Owner.ID { + return s3err.ErrNone + } + return s3err.ErrAccessDenied +} |
