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#1528alisade wants to merge 1 commit intoVersent:masterVersent/saml2aws:masterfrom alisade:fix/skip-parseawsaccounts-when-role-arn-setalisade/saml2aws:fix/skip-parseawsaccounts-when-role-arn-setCopy head branch name to clipboard
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
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.
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.
Summary
role_arnis set in the IdP account,ParseAWSRoleshas already extracted bothRoleARNandPrincipalARNfrom the SAML assertion — so the subsequent HTTP POST insideParseAWSAccountsis only used to fetch human-readable account names for the interactive picker, which is never shown in this case.signin.aws.amazon.com/samlendpoint now responds to certain SAML POSTs with a small JavaScripthashArgsinterstitial page instead of the legacyfieldset > div.saml-accountHTML thatExtractAWSAccountsscrapes, soExtractAWSAccountsreturns an empty slice andresolveRoleerrors withNo accounts available.despite the SAML assertion being valid and containing the configured role.RoleARNshort-circuit ahead ofParseAWSAccountsso anyRoleARN-configured account skips the unnecessary round-trip. The interactive multi-role picker path (noRoleARN, multiple roles in the assertion) is unchanged.Repro
provider = Browser, a valid Okta AWS tile URL, androle_arnmatching one of the roles returned in the SAML assertion (against an AWS account whose sign-in portal returns the new JS interstitial).saml2aws --skip-prompt -a <account> loginFailed to assume role. Please check whether you are permitted to assume the given role for the AWS service.: No accounts available.AssumeRoleWithSAMLreturns the expected credentials.The captured AWS response body in the failing case is roughly:
i.e. a JS-driven redirect rather than the legacy account selector HTML, which
ExtractAWSAccountshas no selectors for.Test plan
saml2aws --skip-prompt -a <commercial-Okta-account> login— succeeds, STS returns expected credentials.ParseAWSAccountsHTTP call.go build ./...clean.