Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add force to selectchallenge when MFA is enabled #235

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion aws_google_auth/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,17 @@ def do_login(self):

self.session.headers['Referer'] = sess.url

if "selectchallenge/" in sess.url:
if "challenge/" in sess.url:
form = response_page.find('form', {'id': 'challenge'})

payload = {}
for tag in form.find_all('input'):
if tag.get('name') is None:
continue

payload[tag.get('name')] = tag.get('value')

sess = self.post(self.base_url + "/signin/selectchallenge", data=payload)
sess = self.handle_selectchallenge(sess)

# Was there an MFA challenge?
Expand Down Expand Up @@ -840,6 +850,8 @@ def handle_selectchallenge(self, sess):
challenges.append(['YubiKey', i.attrs.get("data-challengeentry")])
elif "challenge/az/" in action:
challenges.append(['Google Prompt', i.attrs.get("data-challengeentry")])
elif "challenge/dp/" in action:
challenges.append(['Dual Prompt', i.attrs.get("data-challengeentry")])

print('Choose MFA method from available:')
for i, mfa in enumerate(challenges, start=1):
Expand Down Expand Up @@ -872,3 +884,4 @@ def handle_selectchallenge(self, sess):
# POST to google with the chosen challenge
return self.post(
self.base_url + challenge_form.get('action'), data=payload)