mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-06 12:07:51 +01:00
s3: register account-less identities' synthesized account so ACL/owner ids resolve (#9971)
* s3: register account-less identities' synthesized account in the lookup #9962 gave each account-less identity a distinct account id derived from its name (instead of collapsing into admin), but never registered that account in the id->account map. GetAccountNameById then returned empty for such ids, so ACL grantee validation rejected canonical grants to the caller's own account with InvalidRequest, and bucket/object owner display was dropped as 'owner is invalid'. This broke a canned PutObjectAcl by an account-less identity (e.g. TestVersionedObjectAcl with the default 'some_admin_user' identity): ValidateAndTransferGrants -> GetAccountNameById -> 'account id is not exists' -> 400 InvalidRequest. Register the synthesized account at config load so its id resolves to a display name. Add a regression test. * s3: reuse explicitly-configured account for account-less identity Address review: if an account with the same id as an account-less identity's synthesized account is explicitly configured (custom display name/email), reuse it instead of the synthesized one. Add a test.
This commit is contained in:
1 parent
1391a85a20
commit
14d247703a
2 files changed
+83
-2
No files matched your search
@@ -627,7 +627,18 @@ func (iam *IdentityAccessManagement) ReplaceS3ApiConfiguration(config *iam_pb.S3
|
||||
t.Account = &AccountAnonymous
|
||||
identityAnonymous = t
|
||||
case ident.Account == nil:
|
||||
t.Account = accountForUnscopedIdentity(t.Name)
|
||||
// Account-less identities own resources under a distinct id derived
|
||||
// from their name. Reuse an explicitly-configured account with that
|
||||
// id if one exists (preserving its display name/email); otherwise
|
||||
// synthesize one and register it so the id resolves via
|
||||
// GetAccountNameById (ACL grantee validation, owner display).
|
||||
synthesized := accountForUnscopedIdentity(t.Name)
|
||||
if existing, ok := accounts[synthesized.Id]; ok {
|
||||
t.Account = existing
|
||||
} else {
|
||||
t.Account = synthesized
|
||||
accounts[synthesized.Id] = synthesized
|
||||
}
|
||||
default:
|
||||
if account, ok := accounts[ident.Account.Id]; ok {
|
||||
t.Account = account
|
||||
@@ -846,7 +857,18 @@ func (iam *IdentityAccessManagement) MergeS3ApiConfiguration(config *iam_pb.S3Ap
|
||||
t.Account = &AccountAnonymous
|
||||
identityAnonymous = t
|
||||
case ident.Account == nil:
|
||||
t.Account = accountForUnscopedIdentity(t.Name)
|
||||
// Account-less identities own resources under a distinct id derived
|
||||
// from their name. Reuse an explicitly-configured account with that
|
||||
// id if one exists (preserving its display name/email); otherwise
|
||||
// synthesize one and register it so the id resolves via
|
||||
// GetAccountNameById (ACL grantee validation, owner display).
|
||||
synthesized := accountForUnscopedIdentity(t.Name)
|
||||
if existing, ok := accounts[synthesized.Id]; ok {
|
||||
t.Account = existing
|
||||
} else {
|
||||
t.Account = synthesized
|
||||
accounts[synthesized.Id] = synthesized
|
||||
}
|
||||
default:
|
||||
if account, ok := accounts[ident.Account.Id]; ok {
|
||||
t.Account = account
|
||||
|
||||
Reference in new issue
Block a user