Browse Source

Merge branch '1_bucket_write' into 10_acl_merged

# Conflicts:
#	weed/s3api/s3api_acp.go
#	weed/s3api/s3api_bucket_handlers.go
pull/4090/head
changlin.shi 2 years ago
parent
commit
4c280c06dc
  1. 19
      weed/s3api/s3api_acp.go
  2. 7
      weed/s3api/s3api_bucket_handlers.go

19
weed/s3api/s3api_acp.go

@ -358,3 +358,22 @@ func (s3a *S3ApiServer) checkAccessForWriteObject(r *http.Request, bucket, objec
func getObjectEntry(s3a *S3ApiServer, bucket, object string) (*filer_pb.Entry, error) { func getObjectEntry(s3a *S3ApiServer, bucket, object string) (*filer_pb.Entry, error) {
return s3a.getEntry(util.Join(s3a.option.BucketsPath, bucket), object) return s3a.getEntry(util.Join(s3a.option.BucketsPath, bucket), object)
} }
func (s3a *S3ApiServer) ExtractBucketAcp(r *http.Request) (owner string, grants []*s3.Grant, errCode s3err.ErrorCode) {
accountId := s3acl.GetAccountId(r)
ownership := s3_constants.DefaultOwnershipForCreate
if ownership == s3_constants.OwnershipBucketOwnerEnforced {
return accountId, []*s3.Grant{
{
Permission: &s3_constants.PermissionFullControl,
Grantee: &s3.Grantee{
Type: &s3_constants.GrantTypeCanonicalUser,
ID: &accountId,
},
},
}, s3err.ErrNone
} else {
return s3acl.ParseAndValidateAclHeadersOrElseDefault(r, s3a.accountManager, ownership, accountId, accountId, false)
}
}

7
weed/s3api/s3api_bucket_handlers.go

@ -123,6 +123,12 @@ func (s3a *S3ApiServer) PutBucketHandler(w http.ResponseWriter, r *http.Request)
} }
} }
acpOwner, acpGrants, errCode := s3a.ExtractBucketAcp(r)
if errCode != s3err.ErrNone {
s3err.WriteErrorResponse(w, r, errCode)
return
}
fn := func(entry *filer_pb.Entry) { fn := func(entry *filer_pb.Entry) {
if identityId := r.Header.Get(s3_constants.AmzIdentityId); identityId != "" { if identityId := r.Header.Get(s3_constants.AmzIdentityId); identityId != "" {
if entry.Extended == nil { if entry.Extended == nil {
@ -130,6 +136,7 @@ func (s3a *S3ApiServer) PutBucketHandler(w http.ResponseWriter, r *http.Request)
} }
entry.Extended[s3_constants.AmzIdentityId] = []byte(identityId) entry.Extended[s3_constants.AmzIdentityId] = []byte(identityId)
} }
s3acl.AssembleEntryWithAcp(entry, acpOwner, acpGrants)
} }
// create the folder for bucket, but lazily create actual collection // create the folder for bucket, but lazily create actual collection

Loading…
Cancel
Save