mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-04 11:07:35 +01:00
s3api: per-bucket Block Public Access (BlockPublicAcls, IgnorePublicAcls) (#12381)
* s3api: store and serve a bucket's PublicAccessBlock configuration PutPublicAccessBlock, GetPublicAccessBlock and DeletePublicAccessBlock answered NotImplemented. Store the configuration in the bucket entry's extended attributes next to the ownership controls, carry it in the cached BucketConfig, and answer Get on an unset bucket with NoSuchPublicAccessBlockConfiguration like S3 does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: refuse public ACLs when a bucket blocks them With BlockPublicAcls set, a PutObject, CopyObject, CreateMultipartUpload, POST Object, PutObjectAcl or PutBucketAcl whose canned ACL or grants name the AllUsers or AuthenticatedUsers group is refused with AccessDenied. Private and account grants keep working, so clients that send x-amz-acl: private on every upload are unaffected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: ignore public ACL grants for anonymous reads under IgnorePublicAcls A bucket with IgnorePublicAcls no longer lets an AllUsers grant on the bucket or on an object answer an anonymous read or listing. Bucket policies and identity permissions are unaffected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: reject PublicAccessBlock bodies with unknown elements A misspelled element such as BlockPublicAcl was ignored, so the request succeeded and stored the flag as false. Answer MalformedXML instead, and store the configuration without the request's namespace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: fail closed when a bucket's public access block cannot be read A stored PublicAccessBlock that does not parse now blocks and ignores public ACLs instead of acting as if none were set. PutBucketAcl and POST Object return the bucket lookup error rather than skipping the BlockPublicAcls check when the bucket config cannot be loaded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: test BlockPublicAcls on copy, multipart initiate and a PUT-then-GET Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: keep stored public access block bytes on unrelated bucket updates An unreadable stored configuration was replaced with the in-memory all-true fallback whenever another bucket setting was updated, losing the original value. Write the key only when the update changes the public access block. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ca4ce2c581
commit
b0c6297041
16 files changed
+555
-10
No files matched your search
@@ -288,6 +288,38 @@ func TestAnonymousObjectACLLegacyOwnership(t *testing.T) {
|
||||
require.Equal(t, 200, rr.Code, rr.Body.String())
|
||||
}
|
||||
|
||||
func TestAnonymousObjectACLIgnorePublicAcls(t *testing.T) {
|
||||
publicBucket := &filer_pb.Entry{Name: "b", IsDirectory: true, Extended: map[string][]byte{
|
||||
s3_constants.ExtAmzAclKey: anonymousReadGrant("READ"),
|
||||
}}
|
||||
ignoring := proto.Clone(publicBucket).(*filer_pb.Entry)
|
||||
ignoring.Extended[s3_constants.ExtPublicAccessBlockKey] = []byte(`<PublicAccessBlockConfiguration><IgnorePublicAcls>true</IgnorePublicAcls></PublicAccessBlockConfiguration>`)
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
bucket *filer_pb.Entry
|
||||
acl []byte
|
||||
want int
|
||||
}{
|
||||
{"public object", publicBucket, anonymousReadGrant("READ"), 200},
|
||||
{"public object ignored", ignoring, anonymousReadGrant("READ"), 403},
|
||||
{"public bucket", publicBucket, nil, 200},
|
||||
{"public bucket ignored", ignoring, nil, 403},
|
||||
} {
|
||||
for _, method := range []string{http.MethodGet, http.MethodHead} {
|
||||
t.Run(tc.name+"/"+method, func(t *testing.T) {
|
||||
s3a, f := newAnonymousReadTestServer(t)
|
||||
s3a.bucketConfigCache.Set("b", s3a.newBucketConfigFromEntry("b", tc.bucket))
|
||||
f.entries["/buckets/b/o"] = anonymousReadEntry(tc.acl)
|
||||
rr := serveAnonymousRead(s3a, method, "o", "", nil)
|
||||
require.Equal(t, tc.want, rr.Code, rr.Body.String())
|
||||
if tc.want == 403 {
|
||||
require.NotContains(t, rr.Body.String(), "hello world")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAnonymousObjectACLConfiguredIdentity(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
|
||||
Reference in new issue
Block a user