mirror of
https://github.com/floci-io/floci.git
synced 2026-11-28 16:11:48 -05:00
A role's trust policy was the one context a request is evaluated against that did not say who was calling. AssumeRolePolicyEvaluator assembled its own map and put aws:PrincipalArn into it alone, so a trust policy keyed on aws:userid, aws:PrincipalType or aws:username could not match, where every other context a request is evaluated against carries all four through CallerArns.putPrincipalKeys. The user guide puts aws:PrincipalType and aws:userid in "the request context for all requests, including anonymous requests" and aws:username in it for every IAM user, and an sts:AssumeRole request is no exception: the guide's own example of a resource-based policy tells principals apart in a Condition on aws:userid. Raised by hectorvent on the review of #5568 and left to its own PR. The evaluator now takes the caller's CallerArns in place of its two ARN strings and writes the keys through that single writer, so no second context has to be kept in step. STS passes the caller it already resolves, and a credential that resolves to no identity is the account root stand-in it already names in its denial, now with the account's own keys: the guide gives the root user the account id as its aws:userid, the type Account and no aws:username, which is what S3 and the enforcement filter already build for it. That construction had three copies and is now one factory on the record. Step Functions passes the execution role as the session it is, carrying AssumedRole as its aws:PrincipalType: it assumes that role on the state machine's behalf, so a target role's trust policy may condition on the type. It mints no session name there, and a session's aws:userid is role-id:session-name, so that key and aws:username stay absent. AssumeRolePolicyEvaluatorTest builds its callers through the record, with three cases on the keys: a condition on aws:username matching the caller and not matching the same caller carrying no keys, aws:PrincipalType and aws:userid telling a user apart from a role session, and a value the caller carries winning over the request's own copy. AssumeRoleTrustConditionsIntegrationTest signs four more AssumeRole calls end to end, over a condition on the calling user's name, on the principal type, on the root stand-in's account id, and on a session's role-id:session-name. Reverting the evaluator to aws:PrincipalArn alone fails all seven; writing the keys with putIfAbsent instead fails the precedence case alone. LambdaTaskAuthorizerTest covers the Step Functions caller from both sides, a trust condition on the principal type matching it and one on the session's own id not matching.