saml2aws icon indicating copy to clipboard operation
saml2aws copied to clipboard

Unable to use `Firefox` as browser type

Open rmasclef opened this issue 7 months ago • 3 comments

Hey, Thank you for your work !

It looks like there is an issue using Firefox as browserType.

OBSERVED BEHAVIOR

Firefox is launched, but no page shows up. After 2 to 3s firefox closes itself.

Here is a video showing the behavior

HOW TO REPRODUCE

system

firefox 121.0.1 (64-bit)
sonoma 14.2.1 (23C71) on macbookpro m3 max

saml2aws config:

[default]
name                 = default
app_id               =
url                  = https://accounts.google.com/AccountChooser/signinchooser?...
provider             = Browser
mfa                  = Auto
aws_urn              = urn:amazon:webservices
aws_session_duration = 43200
aws_profile          = whatever
download_browser_driver = true

cmde:

SAML2AWS_BROWSER_TYPE=firefox  SAML2AWS_BROWSER_EXECUTABLE_PATH=/opt/homebrew/bin/firefox  saml2aws login

output:

SAML2AWS_BROWSER_TYPE=firefox  SAML2AWS_BROWSER_EXECUTABLE_PATH=/Applications/Firefox.app/Contents/MacOS/firefox saml2aws --verbose login
DEBU[0000] Running                                       command=login
DEBU[0000] Check if creds exist.                         command=login
DEBU[0000] Expand                                        name=/Users/rmasclef/.aws/credentials pkg=awsconfig
DEBU[0000] resolveSymlink                                name=/Users/rmasclef/.aws/credentials pkg=awsconfig
DEBU[0000] ensureConfigExists                            filename=/Users/rmasclef/.aws/credentials pkg=awsconfig
Using IdP Account default to access Browser https://accounts.google.com/AccountChooser/signinchooser?continue=https%3A%2F%2Faccounts.google.com%2Fo%2Fsaml2%2Finitsso%3Fidpid%3DC04hk6d4h%26spid%3D573628210997%26forceauthn%3Dfalse%26from_login%3D1%26as%3DjVuni5VWJF_D1Ro7vKDp24fsh3Sqwxuue6E-TohK2OU&ltmpl=popup&btmpl=authsub&scc=1&oauth=1&flowName=GlifWebSignIn&flowEntry=AccountChooser
DEBU[0000] Get credentials                               helper=osxkeychain serverURL="https://accounts.google.com/AccountChooser/signinchooser?continue=https%3A%2F%2Faccounts.google.com%2Fo%2Fsaml2%2Finitsso%3Fidpid%3DC04hk6d4h%26spid%3D573628210997%26forceauthn%3Dfalse%26from_login%3D1%26as%3DjVuni5VWJF_D1Ro7vKDp24fsh3Sqwxuue6E-TohK2OU&ltmpl=popup&btmpl=authsub&scc=1&oauth=1&flowName=GlifWebSignIn&flowEntry=AccountChooser"
DEBU[0000] Get credentials                               helper=osxkeychain user=
To use saved password just hit enter.
? Username
? Password

DEBU[0001] building provider                             command=login idpAccount="account {\n  URL: https://accounts.google.com/AccountChooser/signinchooser?continue=https%3A%2F%2Faccounts.google.com%2Fo%2Fsaml2%2Finitsso%3Fidpid%3DC04hk6d4h%26spid%3D573628210997%26forceauthn%3Dfalse%26from_login%3D1%26as%3DjVuni5VWJF_D1Ro7vKDp24fsh3Sqwxuue6E-TohK2OU&ltmpl=popup&btmpl=authsub&scc=1&oauth=1&flowName=GlifWebSignIn&flowEntry=AccountChooser\n  Username: \n  Provider: Browser\n  MFA: Auto\n  SkipVerify: false\n  AmazonWebservicesURN: urn:amazon:webservices\n  SessionDuration: 43200\n  Profile: rzc-google\n  RoleARN: \n  Region: \n}"
Authenticating as  ...
INFO[0002] Setting browser type: firefox                 provider=browser
INFO[0002] Setting browser executable path: /Applications/Firefox.app/Contents/MacOS/firefox  provider=browser
could not send message: Browser closed.
==================== Browser output: ====================
<launching> /Applications/Firefox.app/Contents/MacOS/firefox -no-remote -wait-for-browser -foreground -profile /var/folders/km/qbnnqyrs6g92mrrqstg2gk8r0000gn/T/playwright_firefoxdev_profile-Vu72Hh -juggler-pipe -silent
<launched> pid=27368
[pid=27368] <process did exit: exitCode=0, signal=null>
[pid=27368] starting temporary directories cleanup
=========================== logs ===========================
<launching> /Applications/Firefox.app/Contents/MacOS/firefox -no-remote -wait-for-browser -foreground -profile /var/folders/km/qbnnqyrs6g92mrrqstg2gk8r0000gn/T/playwright_firefoxdev_profile-Vu72Hh -juggler-pipe -silent
<launched> pid=27368
[pid=27368] <process did exit: exitCode=0, signal=null>
[pid=27368] starting temporary directories cleanup
============================================================
Error authenticating to IdP.
github.com/versent/saml2aws/v2/cmd/saml2aws/commands.Login
	github.com/versent/saml2aws/v2/cmd/saml2aws/commands/login.go:109
main.main
	github.com/versent/saml2aws/v2/cmd/saml2aws/main.go:195
runtime.main
	runtime/proc.go:267
runtime.goexit
	runtime/asm_arm64.s:1197

NOTES

I launched saml2aws on Golang using step by step debug mode and here is the error message that is not logged by saml2aws occuring here : https://github.com/Versent/saml2aws/blob/master/pkg/provider/browser/browser.go#L109

TargetClosedError: Target page, context or browser has been closed
Browser logs:

<launching> /opt/homebrew/bin/firefox -no-remote -wait-for-browser -foreground -profile /var/folders/km/qbnnqyrs6g92mrrqstg2gk8r0000gn/T/playwright_firefoxdev_profile-rKSlWy -juggler-pipe -silent
<launched> pid=27235
[pid=27235] <process did exit: exitCode=0, signal=null>
[pid=27235] starting temporary directories cleanup
    at DispatcherConnection.dispatch (/Users/rmasclef/Library/Caches/ms-playwright-go/1.40.1/package/lib/server/dispatchers/dispatcher.js:364:15)

I genuinely don't know how to dig more at this stage 😬

Let me know if I can help on anything 👍

rmasclef avatar Jan 19 '24 17:01 rmasclef

It appears that this is a recurring issue, probably related to timeouts:

  • https://github.com/microsoft/playwright/issues/21875
  • https://github.com/microsoft/playwright/issues/13038

Would you be able to play-around with timeouts as suggested here to see if it fixes the underlying issue?

mapkon avatar Jan 23 '24 03:01 mapkon

hey !! I'm really sorry for the delay, I did not check my notifications until today 😨

I'll check and let you know 🙏

rmasclef avatar Feb 23 '24 14:02 rmasclef

I'm having this same issue with any custom browser executable. Whether I use existing firefox or vivaldi (chromium) the window starts to open and then closes with:

INFO[0000] Setting browser executable path: /Applications/Vivaldi.app/Contents/MacOS/Vivaldi  provider=browser
Error authenticating to IdP.: could not send message: Page closed

If I just use the chromium version that downloads by default with --download-browser-driver it works just fine.

timharris777 avatar Mar 12 '24 20:03 timharris777

hey ! Just a quick heads-up to tell that I still did not took the time to play with the timeouts as suggested.

rmasclef avatar Jul 09 '24 08:07 rmasclef

if I add this code to handle browser timeout

Screenshot 2024-08-25 at 16 05 31

I get the following error

Screenshot 2024-08-25 at 16 07 25

Maybe this is not the option you want me to check @mapkon ?

rmasclef avatar Aug 25 '24 14:08 rmasclef

here is what I have in console :

Screenshot 2024-08-25 at 16 09 27

rmasclef avatar Aug 25 '24 14:08 rmasclef