Skip to content

Commit

Permalink
Fix Azure AD login when using ADFS
Browse files Browse the repository at this point in the history
  • Loading branch information
trewq34 committed Sep 6, 2022
1 parent 1bc966c commit 61f0f0c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions auther/providers/helpers/azuread.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,16 @@ async def _input_username(page, username):


async def _input_password(page, password):
input_selector = 'input[type="password"][name="passwd"]'
submit_selector = 'input[type="submit"][value="Sign in"]'
input_selector = 'input[type="password"][name="passwd"],input[type="password"][name="Password"]'
submit_selector = 'input[type="submit"][value="Sign in"],span[class=submit]'
error_selector = "#passwordError"

while True:
while password in [None, ""]:
password = getpass.getpass("Password: ")

await page.type(input_selector, password)
await page.focus(input_selector)
await page.keyboard.type(password)
await page.click(submit_selector)
await asyncio.sleep(1)

Expand Down Expand Up @@ -199,6 +200,7 @@ async def _auth(url, username=None, password=None, headless=True, stay_signed_in
while not roles:
time_diff = (during-before).seconds
if (time_diff >= 60):
await page.screenshot({'path': '/root/.aws/timeout.png'})
raise Exception('hit timeout')

page.on("request", samlHandler)
Expand All @@ -211,6 +213,10 @@ async def _auth(url, username=None, password=None, headless=True, stay_signed_in
page, 'input[type="password"][name="passwd"]'
):
await _input_password(page, password)
elif await _check_for_visible_element(
page, 'input[type="password"][name="Password"]'
):
await _input_password(page, password)
elif await _check_for_visible_element(page, 'input[name="otc"]'):
await _input_code(page, None)
elif await _check_for_visible_element(
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="auther",
version="0.0.5",
version="0.0.6-dev",
author="Kamran Ali",
author_email="[email protected]",
description="Command line tool for AWS CLI authentication",
Expand Down

0 comments on commit 61f0f0c

Please sign in to comment.