fix(425): parse NextJS data for role aliases #426
Merged
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.
Description
This PR updates the parsing in
gimme_aws_creds/aws.py
to support the new NextJS SAML login page that AWS plans to release. The changes from this PR are backwards compatible by first asserting whether the new NextJS metadata is present in the HTML response for the sign-in page. In the event this metadata is present a new approach is used to parse the JSON data for the necessary alias names. If not, the old codepath is used for parsing this data from the HTML content of the legacy page.Related Issue
Fixes #425 for new AWS SAML login page
Motivation and Context
While AWS did rollback their recent change to the SAML sign-in page, it's likely they will move forward with the new NextJS application at an, at this time, uncertain future date. Applying this fix proactively will ensure when this occurs that the aliases can be parsed from the new metadata.
How Has This Been Tested?
I've empirically tested this locally using a response I saved from the new SAML page while it was deployed earlier today. I plan to update
tests/test_aws_resolver.py
prior to merging this PR with a new test case using mock data in the new format (I still need to redact my local response of private data).Screenshots (if appropriate):
N/A
Types of changes
Checklist:
Note to maintainers:
The link to submit the Individual Contributor License Agreement in this project's CONTRIBUTING document is not working. I'd be happy to submit a CLA prior to this PR merging so long as a maintainer could point me in the right direction for that.
Additionally, as mentioned previously I don't love introducing new functionality without tests so I'm going to spend some time this afternoon mocking the new response HTML that I have locally to turn it into an additional test case prior to merging.
EDIT: I finished adding a new unit test and cleaning up the mock HTML data by creating a fixtures directory in a599592 and 531baa2 and confirmed all new and existing tests pass. This is ready for review/merge.