Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(login): skip ParseAWSAccounts when RoleARN is configured#1528

Open
alisade wants to merge 1 commit into
Versent:masterVersent/saml2aws:masterfrom
alisade:fix/skip-parseawsaccounts-when-role-arn-setalisade/saml2aws:fix/skip-parseawsaccounts-when-role-arn-setCopy head branch name to clipboard
Open

fix(login): skip ParseAWSAccounts when RoleARN is configured#1528
alisade wants to merge 1 commit into
Versent:masterVersent/saml2aws:masterfrom
alisade:fix/skip-parseawsaccounts-when-role-arn-setalisade/saml2aws:fix/skip-parseawsaccounts-when-role-arn-setCopy head branch name to clipboard

Conversation

@alisade

@alisade alisade commented Jun 2, 2026

Copy link
Copy Markdown

Summary

  • When a role_arn is set in the IdP account, ParseAWSRoles has already extracted both RoleARN and PrincipalARN from the SAML assertion — so the subsequent HTTP POST inside ParseAWSAccounts is only used to fetch human-readable account names for the interactive picker, which is never shown in this case.
  • That step has also become a hard failure for some AWS sign-in flows: AWS's commercial signin.aws.amazon.com/saml endpoint now responds to certain SAML POSTs with a small JavaScript hashArgs interstitial page instead of the legacy fieldset > div.saml-account HTML that ExtractAWSAccounts scrapes, so ExtractAWSAccounts returns an empty slice and resolveRole errors with No accounts available. despite the SAML assertion being valid and containing the configured role.
  • This PR moves the RoleARN short-circuit ahead of ParseAWSAccounts so any RoleARN-configured account skips the unnecessary round-trip. The interactive multi-role picker path (no RoleARN, multiple roles in the assertion) is unchanged.

Repro

  1. Configure an account with provider = Browser, a valid Okta AWS tile URL, and role_arn matching one of the roles returned in the SAML assertion (against an AWS account whose sign-in portal returns the new JS interstitial).
  2. saml2aws --skip-prompt -a <account> login
  3. Before: fails with Failed to assume role. Please check whether you are permitted to assume the given role for the AWS service.: No accounts available.
  4. After: succeeds; STS AssumeRoleWithSAML returns the expected credentials.

The captured AWS response body in the failing case is roughly:

<script>
  window.location.replace(redirectUrl(window.location, "hashArgs", "oauthStart", ...).toString());
</script>

i.e. a JS-driven redirect rather than the legacy account selector HTML, which ExtractAWSAccounts has no selectors for.

Test plan

  • Manual: saml2aws --skip-prompt -a <commercial-Okta-account> login — succeeds, STS returns expected credentials.
  • Manual: GovCloud SAML flow (returns legacy account-selector HTML) still succeeds, and now skips the unnecessary ParseAWSAccounts HTTP call.
  • go build ./... clean.

When a RoleARN is set in the IdP account, the role and principal ARNs
are already populated by ParseAWSRoles from the SAML assertion, so the
HTTP POST to the AWS signin endpoint inside ParseAWSAccounts is purely
used to fetch human-readable account names for the interactive picker.
With a configured RoleARN the picker is never shown, making that
round-trip unnecessary.

It is also actively broken for some AWS sign-in flows. AWS's commercial
endpoint (signin.aws.amazon.com/saml) now responds to some SAML POSTs
with a JavaScript "hashArgs" interstitial page instead of the legacy
"fieldset > div.saml-account" HTML that ExtractAWSAccounts scrapes.
ExtractAWSAccounts then returns an empty slice and resolveRole errors
with "No accounts available." even though the SAML assertion is valid
and contains the configured role.

Move the RoleARN short-circuit ahead of the ParseAWSAccounts step so
that any RoleARN-configured account skips it. The interactive
multi-role picker path (no RoleARN, multiple roles in the assertion)
is unchanged.
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.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.