Repository navigation
fix(sts): GetCallerIdentity reports the caller's unique ID, not their name (#805) - #810
Merged
Merged
Conversation
… name (#805) AWS's identifiers reference documents three forms for UserId and names GetCallerIdentity as the way to read one: AIDA… for an IAM user, AROA…:<role-session-name> for an assumed role, and the account ID for the account root. Substrate reported the friendly name, and 'worker/sess1' for a session — the ARN's last two segments, which is no documented shape. Principal.UserID has held the right value since #771 and publishes aws:userid from it, so the two surfaces disagreed as well as diverging from AWS. Prefer the recorded value per #745; fall back to the entity's own UserId/RoleId for a credential minted before #771, rebuilding the role-id:session pairing for a session. Closes #805
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #805.
AWS's identifiers reference
documents three forms for
GetCallerIdentity'sUserId, and names that operation as the way toread one:
AIDA…for an IAM user,AROA…:<role-session-name>for an assumed role, and theaccount ID for the account root. Substrate reported the caller's friendly name —
alice, andworker/sess1for a session, which is the ARN's last two segments and not a shape AWS producesanywhere. A consumer asserting on
UserId, or splitting an assumed-role ID on:to recover thesession name, read a value it could not have got from AWS.
It also disagreed with substrate's own
aws:userid, which has published the right value fromPrincipal.UserIDsince #771 and was simply not read here. Both surfaces now come from that onerecorded field, so a policy conditioned on
aws:useridand a test asserting onUserIdcannotdisagree about who the caller is.
What it does
Principal.UserID, per iam: policy variables are compared literally, so a negated ${aws:username} is more permissive than on AWS #745's record-don't-derive rule:resolvePrincipalcopies it offthe access key's or the session's own record, so the common path performs no lookup.
UserId/RoleIdfor a credential minted before iam: produce aws:userid and aws:PrincipalTag/, the two caller keys still without a producer #771, whoserecord has the field empty — one state read on an operation that is not hot. For an assumed role
the documented
{role-id}:{session-name}pairing is rebuilt from the role's record plus thesession name the ARN carries, which is the same string
assumeRolecomposes today.reports the account ID (AWS's own third form), and a principal that resolves to no IAM entity
reports its friendly name. That last case is substrate's choice rather than AWS's — every caller
on AWS has a unique ID — and the reasoning is recorded on the function: a name identifies the
caller, where an empty member could not be told from a bug.
Also tightens the
UserIdassertion #801 deliberately left loose (NotContains "/") to assertthe
AIDA…form, which is what its comment said was waiting on this issue.Verification
Fail-before, pass-after — five of the eight new cases fail on
main, and the three that pass arepinning behaviour this deliberately does not change:
Live against a real
awsCLI, all three documented forms in one run — and the user'sUserIdagrees with what
iam get-userreports for her, which is a consistency AWS has too:Full gate green:
gofmt/go build/go vet/golangci-lint(0 issues),make teston Go 1.27 and1.26.6,
make coverage(emulator 83.6%, total 83.0% — unchanged),make docs-reference docs-reference-check docs-versions authz-reference-check,npm --prefix docs run build, andgo vet -C test/e2e ./... && go test -C test/e2e ./.... Patch coverage measured at 100% locally.Compatibility
UserIdchanges value from a friendly name to the documented unique ID. A test assertingUserId == "alice"must now assert theAIDA…form or read it fromGetUser.Arn,Accountand the response shape do not move, and the account-root answer is unchanged.
Notes
entityUniqueIDreads one key for both fields because a record is a user or a role, andiamEntityKeyalready keys them apart by kind.p.state == nilguard I had written into that read: no other operation in this pluginchecks it, and an unreachable branch is worse than following the local convention.
docs/services.mdgains a short table of the three forms under the STS section, since this is avalue consumers assert on.