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

Browser initially focused on URL bar rather than username field when using Browser provider with Google Apps URL #1295

Open cjerdonek opened 2 weeks ago

cjerdonek commented 2 weeks ago

Hi, when using the "Google Apps" provider on a Mac as described here with SAML2AWS_IDP_PROVIDER=Browser, when the browser opens and one starts typing, the text goes into the URL bar rather than the "Email or phone" field. As this is an auth flow, it would be more convenient if the "Email or phone" field started out with the focus.

One thing that seems odd to me is that the cursor starts out blinking in the "Email or phone" field, making it look like that field already has focus. (When tabbing through, that cursor is blinking only when that field has focus.) However, the URL bar is also highlighted when starting out, making it look like the URL bar also has focus.

See below for a screenshot (note the highlighted URL bar and cursor in the "blinking" stage):

screenshot_saml2aws
cjerdonek commented 2 weeks ago

I see that Playwright / playwright-go has a Locator.focus() API. It could be used in the following part of saml2aws's code e.g. if the --browser-autofill option isn't provided and/or if a username isn't given: https://github.com/Versent/saml2aws/blob/e65a82694db8e5f4871974907adf86fe462be9c3/pkg/provider/browser/browser.go#L158-L183

saml2aws's browser package's autoFill() function already has code to look for a password element (but not for a username field specifically), so the package could do something similar to look for a username field prior to focusing: https://github.com/Versent/saml2aws/blob/e65a82694db8e5f4871974907adf86fe462be9c3/pkg/provider/browser/browser.go#L205-L206

mapkon commented 6 days ago

Hello @cjerdonek thank you for raising this issue. Could you please submit a PR?

cjerdonek commented 5 days ago

@mapkon Sure, I can probably put something together within the next few weeks, given that you're interested. Thanks!