Skip to content

feat(#1613): STS/IAM federation: OIDC and SAML providers, AssumeRoleWithWebIdentity and AssumeRoleWithSAML - #1700

Merged
scttfrdmn merged 9 commits into
mainfrom
feat/v0134-federation
Nov 25, 2026
Merged

scttfrdmn merged 9 commits into
mainfrom
feat/v0134-federation

Conversation

@scttfrdmn

@scttfrdmn scttfrdmn commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Fixes #1706

Part of #1613. This is the STS/IAM federation slice. Still open in #1613: ListEntitiesForPolicy, UpdateUser/UpdateGroup (#1582) and login profiles (#1583), all in the follow-up PR feat/v0134-iam-extras. GetFederationToken is #1694 (v0.137.0).

  • IAM OIDC providers. Create, Get, List, Delete, UpdateOpenIDConnectProviderThumbprint, Add/RemoveClientID and Tag/Untag/ListTags. The ARN is oidc-provider/<url without https://>, and Get reports Url without its scheme, as the API reference's sample does.
    • A second provider for one URL is EntityAlreadyExists/409. More than 5 thumbprints or 100 client IDs is LimitExceeded/409.
    • Add of an existing client ID and Remove of an absent one succeed, because both pages say the operation "is idempotent". Delete of a missing provider is NoSuchEntity/404. The Delete page declares that error and makes no idempotency statement, so I did not follow the brief's assumption here.
    • Nothing is fetched. A create without ThumbprintList stores none, and OpenIdIdpCommunicationError is reachable only through POST/DELETE /v1/iam/oidc-provider-outcome (keyed by URL or *).
  • IAM SAML providers. Create, Get, List, Update, Delete and the three tag ops.
    • The metadata document is parsed (XML, or base64 XML as in the page's sample) for validUntil only.
    • SAMLProviderUUID is minted. Only private-key IDs are stored, never the key text.
    • The key and encryption refusals use the IAM SAML troubleshooting guide's wording.
  • Wiring.
    • State keys go in iam_state_keys.go.
    • Authz rows cover all 17 ARN-scoped provider operations. The two creates' ARNs are minted from Url/Name. Tags are read for aws:ResourceTag. The citation test checks each row against the vendored Service Reference.
    • GetAccountAuthorizationDetails now accepts Filter=SAMLProviderList. It selects no population, because the response has no member that could carry a provider.
  • STS AssumeRoleWithWebIdentity / AssumeRoleWithSAML (sts_federation.go), following decision 2: claims are checked, the rest is seeded.
    • Routing. parser.go resolves an unsigned request that has no other signal and carries Action=AssumeRoleWith* to sts. The AWS CLI against a built binary now works, where it used to get ServiceNotAvailable.
    • OIDC claim checks. The JWT payload is decoded and the signature is not checked.
      • iss must name a provider in the role's account. Otherwise the call answers InvalidIdentityToken "No OpenIDConnect provider found in your account for …".
      • aud must be in ClientIDList, else "Incorrect token audience".
      • exp is checked against the simulated clock. A token past it answers ExpiredTokenException "Token expired: current date/time N must be before the expiration date/time M".
    • SAML claim checks. The assertion is parsed and its signature is not checked.
      • PrincipalArn must exist.
      • The Role attribute must pair the role and the provider, in either order.
      • A NameID and a RoleSessionName must be present.
      • Every NotOnOrAfter is checked against the simulated clock. SessionNotOnOrAfter caps the session.
    • Trust policy. stsTrustDecision evaluates the role's policy with the provider ARN as the principal, for sts:AssumeRoleWithWebIdentity or sts:AssumeRoleWithSAML.
      • principalCovered now skips "AWS" entries for a provider ARN, so only a Federated entry admits one. Before this, "AWS": "<account>" would have matched by account.
      • A role with no trust policy admits no federated caller.
      • The condition keys follow AWS's default mapping: <host/path>:sub, :aud (azp when present), :oaud, :email, :amr (multivalued) and sts:RoleSessionName. SAML gets saml:aud (the Recipient), saml:iss, saml:sub, saml:sub_type, saml:doc and saml:namequalifier.
      • A refusal is AccessDenied/403 "Not authorized to perform sts:AssumeRoleWith…".
    • Seeds. POST/DELETE /v1/sts/federation-outcome is registered in the recorded control-plane group.
      • The body is {provider|"*", error, message?, count?}, where error is InvalidIdentityToken, IDPRejectedClaim or IDPCommunicationError. IDPCommunicationError applies to web identity only, the one operation that documents it.
      • count counts down per assume, so a retry loop can be shown failing and then succeeding.
      • The seed is consulted after the issuer lookup and before the audience and expiry checks.
    • Session. mintRoleSession is shared with AssumeRole. It mints an ASIA… key and the assumed-role/<role>/<session> ARN, and recordRoleLastUsed stamps the role. Responses carry SubjectFromWebIdentityToken, Audience and Provider (the token's iss, per the page), or Subject, SubjectType, Issuer, Audience and NameQualifier (AWS's SHA-1 formula).
  • CloudFormation. AWS::IAM::OIDCProvider and AWS::IAM::SAMLProvider have deploy, update-in-place and delete rows. Url and Name are Replacement. Ref/GetAtt Arn give the ARN, and SAML also exposes GetAtt SamlProviderUUID.
  • Docs. docs/reference/iam.md gains 18 rows, an "Identity providers" section and the CFN rows. docs/reference/sts.md gains two rows and "Federated assumes check claims, not signatures". The stale paragraphs (no federated assume, SAMLProviderList refused) are fixed.

The routed-operation catalog goes from 1,128 to 1,148 (IAM 79 → 97, STS 3 → 5). The wire-model snapshot was refetched for the new operations.

Provenance

Observed rather than published: the OIDC EntityAlreadyExists ("Provider with url … already exists.") and NoSuchEntity ("OpenIDConnect Provider not found for arn …") wording; the web-identity "No OpenIDConnect provider found…", "Incorrect token audience", "Token expired: …", "Not authorized to perform sts:AssumeRoleWithWebIdentity" and the thumbprint-mismatch InvalidIdentityToken. Each matches the AWS CLI's and Terraform's reported output. The SAML refusals ("RoleSessionName is required in AuthnResponse", "Not authorized to perform sts:AssumeRoleWithSAML", "Response signature invalid", "Specified provider doesn't exist.") are documented in the IAM SAML troubleshooting guide. That guide gives no code for the last one, so InvalidIdentityToken there is substrate's choice. The rest are substrate's own and say so in the CHANGELOG.

Gates run locally

  • make lint (0 issues), make test and make e2e.
  • Service Reference Drift: operation-catalog-check, docs-reference-check, docs-headings-check, operation-docs-check, authz-reference-check, cfn-schema-check, wire-model-check, scheduler-query-model-check, doc-links-check.
  • Wire Bookkeeping Drift: wire-bookkeeping-check, discarded-*, nondeterminism-check, comment-history-check, plus docs-versions and docs-counts-check.
  • SUBSTRATE_IAC=1 make iac-e2e: Terraform and CDK journeys pass.
  • VitePress build, with node_modules removed afterwards.
  • Under make test, TestSQS_ReceiveMessage_SystemAttributes failed once: a wall-clock-dependent timestamp was 3 ms off. That is pre-existing and passes on rerun.
  • Scratch Terraform check with provider 6.73.0 against a built binary: two aws_iam_openid_connect_provider resources (GitHub, EKS) plus an aws_iam_role whose assume_role_policy trusts one. Apply succeeded, the second plan -detailed-exitcode was empty (exit 0), destroy succeeded, and the server log had no warnings. The AWS CLI's sts assume-role-with-web-identity (unsigned) then returned credentials for a matching sub and AccessDenied for a non-matching one.

Review rounds

First round.

  • The trust policy is now required to name the provider, and a role's MaxSessionDuration is enforced.
  • Session policies narrow the session; they are stored on the session record.
  • Session tags and SourceIdentity are honored, gated on sts:TagSession/sts:SetSourceIdentity.
  • A SAML assertion's issuer must match the metadata entityID, and its audience must be AWS's.
  • nbf/NotBefore are checked. A token with no sub is refused, and SAML SessionDuration is no longer the API default.
  • CloudFormation applies defaults when a property is removed.

Second round.

  • Session policies reach the secondary authorization passes and the paths that fail open.
  • They are recorded on events, so a replay refuses what the live run refused, and persisted with a CloudFormation stack's creator.
  • Session tag keys that repeat regardless of case are refused.
  • AssumeRole honors Tags, TransitiveTagKeys, SourceIdentity and MaxSessionDuration, and role chaining carries them (sts: AssumeRole ignores Tags, TransitiveTagKeys and SourceIdentity, and does not check MaxSessionDuration #1706).
  • An AWS managed policy that is not bundled is accepted and not applied.

@scttfrdmn scttfrdmn added this to the v0.134.0 milestone Nov 24, 2026
@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

…ty and AssumeRoleWithSAML

- IAM: OpenID Connect providers (CRUD, thumbprints, client IDs, tags) and SAML
  providers (CRUD, metadata, encryption mode, private-key IDs, tags), with authz
  resource rows, state keys and a seedable OpenIdIdpCommunicationError.
- STS: the federated assumes check claims (issuer, audience, expiry on the
  simulated clock, the SAML Role pair) and the trust policy's Federated
  principal with the provider condition keys; IdP outcomes are seedable through
  /v1/sts/federation-outcome.
- Routing: an unsigned request with only Action=AssumeRoleWith* reaches STS.
- CloudFormation: AWS::IAM::OIDCProvider and AWS::IAM::SAMLProvider.
…ty, MaxSessionDuration, SAML issuer and audience

- Session policies (Policy, PolicyArns) on AssumeRole and the federated assumes are
  stored on the session and applied as an intersection at both authorization doors.
- Federated session tags and SourceIdentity require sts:TagSession and
  sts:SetSourceIdentity, reach aws:PrincipalTag/* and aws:SourceIdentity, and
  SourceIdentity is returned.
- DurationSeconds is bounded by the role's MaxSessionDuration; SAML SessionDuration
  is no longer the API default.
- SAML: the assertion's Issuer must be an entityID the metadata declares, and its
  Audience must be AWS's; NotBefore and nbf are checked; a token with no sub is
  refused and condition keys are published only for present claims.
- CFN: a dropped ThumbprintList clears the live list and a dropped
  AssertionEncryptionMode returns a Required provider to Allowed.
- The OIDC create seed's read error is wrapped.
…tion and replay; AssumeRole session tags, source identity and chaining

- Session policies narrow the EC2/ELB tag-on-create, S3 copy-source and S3
  create-side-effect passes, and still apply when the role's policies cannot be read.
- Events record the caller's session (policies, tags, transitive keys, source
  identity) and replay rebuilds the caller from it; a CloudFormation stack persists
  its creator's session so updates, deletes and rollbacks stay narrowed.
- Session tag keys repeating regardless of case are refused (InvalidParameterValue),
  and tag merges run in key order.
- AssumeRole honors Tags, TransitiveTagKeys, SourceIdentity and MaxSessionDuration;
  role chaining carries transitive tags and the source identity.
- An unbundled AWS managed PolicyArns entry is accepted and not applied.
…ies, full-context session checks, presigned principals

- An AWS managed session policy substrate does not bundle allows nothing instead of
  being dropped (follow-up #1712 vendors the documents).
- When identity policies cannot be read, the session policy is decided through the
  same contexts and secondary passes as a resolved request.
- AssumeRole re-checks the 50-tag limit on inherited plus passed tags and refuses a
  TransitiveTagKeys entry naming no tag; the federated assumes refuse the same.
- Presigned URLs and S3 POST-policy uploads resolve their signer from X-Amz-Credential.
- A CloudFormation creator's tags are its entity's own under its session's.
…credentials only without signature verification; case-insensitive transitive tag keys

Under VerifySignatures only a SigV4 Authorization header names the caller,
since nothing else is verified; verifying the other forms is #1713. With
verification off, SigV2 headers and AWSAccessKeyId query and form fields
resolve their signer too. TransitiveTagKeys match tags regardless of case in
AssumeRole chaining and federated claims; the SAML refusal says assertion.
@scttfrdmn
scttfrdmn merged commit 1b9c19f into main Nov 25, 2026
22 of 23 checks passed
@scttfrdmn
scttfrdmn deleted the feat/v0134-federation branch November 25, 2026 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sts: AssumeRole ignores Tags, TransitiveTagKeys and SourceIdentity, and does not check MaxSessionDuration

1 participant