Fix IAM policy editor injecting prefix on existing policies without one

This commit is contained in:
2026-03-15 16:04:35 +08:00
parent d72e0a347e
commit df4f27ca2e

View File

@@ -482,7 +482,7 @@ class IamService:
"expires_at": record.get("expires_at"),
"access_keys": access_keys,
"policies": [
{"bucket": policy.bucket, "actions": sorted(policy.actions), "prefix": policy.prefix}
{**{"bucket": policy.bucket, "actions": sorted(policy.actions)}, **({"prefix": policy.prefix} if policy.prefix != "*" else {})}
for policy in record["policies"]
],
}
@@ -614,7 +614,7 @@ class IamService:
if not record:
raise IamError("User not found")
return [
{"bucket": p.bucket, "actions": sorted(p.actions), "prefix": p.prefix}
{**{"bucket": p.bucket, "actions": sorted(p.actions)}, **({"prefix": p.prefix} if p.prefix != "*" else {})}
for p in record["policies"]
]