Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

s3: allow bucket ownership controls when auth is off (#12121)

Jay Hemnani5c14e566bc65
diff --git a/weed/s3api/auth_account_collapse_test.go b/weed/s3api/auth_account_collapse_test.go
index b2b741a7c2..a48f78f072 100644
--- a/weed/s3api/auth_account_collapse_test.go
+++ b/weed/s3api/auth_account_collapse_test.go
@@ -68,6 +68,21 @@ func TestCheckAccessByOwnershipDeniesNonOwner(t *testing.T) {
assert.Equal(t, s3err.ErrNone, s3a.checkAccessByOwnership(owner, "b"), "the actual owner is still allowed")
}
+// With auth off nobody has an account id, so the owner check must not deny:
+// GetBucketOwnershipControls and friends answered AccessDenied to every caller.
+func TestCheckAccessByOwnershipAllowsWhenAuthDisabled(t *testing.T) {
+ adminOwner := AccountAdmin.Id
+ s3a := &S3ApiServer{
+ bucketRegistry: NewBucketRegistry(nil),
+ iam: &IdentityAccessManagement{},
+ }
+ require.False(t, s3a.iam.isEnabled())
+ s3a.bucketRegistry.setMetadataCache(&BucketMetaData{Name: "b", Owner: &s3.Owner{ID: &adminOwner}})
+
+ req := httptest.NewRequest(http.MethodGet, "/b?ownershipControls=", nil)
+ assert.Equal(t, s3err.ErrNone, s3a.checkAccessByOwnership(req, "b"))
+}
+
// An account-less identity's synthesized account must be registered in the
// account lookup so its id resolves to a display name. Otherwise ACL grantee
// validation and owner display report the id as "not exists" — the regression
diff --git a/weed/s3api/s3api_acp.go b/weed/s3api/s3api_acp.go
index 44a5f77452..bd72ed420b 100644
--- a/weed/s3api/s3api_acp.go
+++ b/weed/s3api/s3api_acp.go
@@ -21,6 +21,10 @@ func (s3a *S3ApiServer) checkAccessByOwnership(r *http.Request, bucket string) s
if errCode != s3err.ErrNone {
return errCode
}
+ // Without auth there is no owner to compare against.
+ if s3a.iam != nil && !s3a.iam.isEnabled() {
+ return s3err.ErrNone
+ }
// Admin by capability, not account id: account-less identities share the "admin" id.
if s3a.isUserAdmin(r) {
return s3err.ErrNone