Versent / saml2aws

CLI tool which enables you to login and retrieve AWS temporary credentials using a SAML IDP
https://github.com/Versent/saml2aws
MIT License
2.04k stars 556 forks source link

Challenge selection fix #1286

Open aaronthebaron opened 3 weeks ago

aaronthebaron commented 3 weeks ago

@edwardrf I don't know if this helps you at all, but in this branch I put some basic work into fixing the issue you're running into with change of selection.

When you enter googleapps.go:83 you're failing out to the bottom at googleapps.go:449

Instead, I think we need to catch the error and try to look at this selection page, so in this branch I added a new function and an if block to try and catch your new selection page.

The new selection page is the html that is added to tests in this PR. I think the key is figuring out which of this attributes needs to be passed to the page:

<div class="mimsib SmR8" jsname="EBHGs" data-challengeid=11 data-action=selectchallenge data-accountrecovery="false" data-challengetype="39">

edwardrf commented 3 weeks ago

Thanks @aaronthebaron, I did took a look at the page and tried to select the one-time code method, but it seems it always ends up sending me to the SMS challenge page. I'll have to circle back to see what could be the reason. Code change here: https://github.com/edwardrf/saml2aws/commit/864417090e7dd537036519431c6bfb8836e1ad92

aaronthebaron commented 3 weeks ago

@edwardrf Thanks for taking a swing at it. I fixed captcha's today and will take a look at your changes on Monday if you don't beat me to it.

codecov-commenter commented 3 weeks ago

Codecov Report

Attention: Patch coverage is 0% with 22 lines in your changes missing coverage. Please review.

Project coverage is 42.05%. Comparing base (99d6fe4) to head (b1b7256). Report is 9 commits behind head on master.

Files Patch % Lines
pkg/provider/googleapps/googleapps.go 0.00% 22 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1286 +/- ## ========================================== - Coverage 42.19% 42.05% -0.15% ========================================== Files 54 54 Lines 6456 6478 +22 ========================================== Hits 2724 2724 - Misses 3283 3305 +22 Partials 449 449 ``` | [Flag](https://app.codecov.io/gh/Versent/saml2aws/pull/1286/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Versent) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/Versent/saml2aws/pull/1286/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Versent) | `42.05% <0.00%> (-0.15%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Versent#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

aaronthebaron commented 2 weeks ago

@edwardrf I think I see what's happening with your code. I think two elements are required, a challengeId and a challengeType. You have one but not the other.

The types also appear to be in the HTML

<div class="mimsib SmR8 RDPZE" jsname="EBHGs" data-challengeid=10 data-action=selectchallenge data-challengeunavailable="true" data-accountrecovery="false" data-challengetype="2">

So it seems like you are on the right track?