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

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

Open
cjerdonek opened this issue Jun 15, 2024 · 3 comments

Comments

@cjerdonek
Copy link

cjerdonek commented Jun 15, 2024

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 cjerdonek changed the title Browser initially focused on URL bar rather than username field when using Google Apps provider Browser initially focused on URL bar rather than username field when using Browser provider with Google Apps URL Jun 16, 2024
@cjerdonek
Copy link
Author

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:

var getSAMLResponse = func(page playwright.Page, loginDetails *creds.LoginDetails, client *Client) (string, error) {
var data string
var dataErr error
logger.WithField("URL", loginDetails.URL).Info("opening browser")
signin_re, err := signinRegex()
if err != nil {
return "", err
}
page.OnRequest(func(request playwright.Request) {
if signin_re.Match([]byte(request.URL())) {
data, dataErr = request.PostData()
}
})
if _, err := page.Goto(loginDetails.URL); err != nil {
return "", err
}
if client.BrowserAutoFill {
err := autoFill(page, loginDetails)
if err != nil {
logger.Error("error when auto filling", err)
}
}

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:

var autoFill = func(page playwright.Page, loginDetails *creds.LoginDetails) error {
passwordField := page.Locator("input[type='password']")

@mapkon
Copy link
Contributor

mapkon commented Jun 24, 2024

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

@cjerdonek
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants