-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Check for xdg-open availability on Linux for browser auth #2254
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
base: main
Are you sure you want to change the base?
Check for xdg-open availability on Linux for browser auth #2254
Conversation
Enhanced LinuxSessionManager.GetWebBrowserAvailable() to check for browser launcher availability (xdg-open, gnome-open, etc.) in addition to checking for desktop session. This matches MSAL's behavior and fixes the scenario where GCM reports "browser not available" even though MSAL can successfully launch a browser using xdg-open (e.g., in SSH sessions without X11 forwarding but with xdg-open available). The IsDesktopSession property remains unchanged and focused on detecting X11/Wayland desktop environments. Only the IsWebBrowserAvailable check has been enhanced. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Move shell execute handler check to top with early return if handler exists (with WSL session 0 exception). This makes the logic flow more clearly and avoids redundant checks between WSL and non-WSL paths. Logic now: - If handler exists (xdg-open, wslview, etc.): return true (early exit) * Exception: WSL session 0 returns false - If no handler and WSL: return false - If no handler and non-WSL: fall back to IsDesktopSession check
Refactored GetWebBrowserAvailable() to be much more readable: - Define all boolean properties upfront (hasHandler, isWsl, etc.) - Single return statement expressing the complete logic clearly - No nested conditionals or multiple return paths Logic: (hasHandler && !isWslSession0) || (isDesktopSession && !isWsl && !hasHandler)
|
@mjcheetham return of The presence of The problem here is HOW to detect if any |
|
Next debatable design; none of the listed open tools in BrowserUtils.cs guarantee there IS a usable browser installed (same issue in the linked MSAL proxy lookup). So in a proper desktop session, valid programs would rather be If possible, detection of WSL-interop or other redirect condition is independent from availability of local browsers. |
|
The primary issue we are hitting is that out the box - GCM does not work anymore on remote WaveSpace VMs for Msft devs using Linux VMs through VSCode remote tunnel. GCM falls back to device code, and the device code flow no longer passes conditional access and we are totally blocked. The VSCode remote tunnel sets up a AzureAuth does this, and so does the Azure CLI. |
|
@kyle-rader-msft based on your description, the presence of a Based on that assumption my personal preference would be to just add code path for using this variable at the beginning of But @mjcheetham (or other maintainers) will have to decide if this may be a more robust approach. |
|
The code for xdg-open has nice examples for:
There is also a good default selection of actual web browsers for UI and command line. |
Summary
Check for browser launcher availability (xdg-open, gnome-open, etc.) in addition to checking for desktop session presence to gate web auth flow.
Problem
GCM currently only checks for
DISPLAYorWAYLAND_DISPLAYenvironment variables to determine if browser-based authentication is available on Linux. However, MSAL checks forxdg-openavailability in addition to display environment variables. This creates a mismatch where GCM reports "browser not available" even though MSAL can successfully launch a browser usingxdg-open.Real-World BLocker: WaveSpace VMs
This fix isimportant for WaveSpace VMs and similar environments where:
DISPLAYenvironment variable)xdg-openis available and can launch the host system's browser (this is setup by VSCode remote tunnels)Solution
Modified
LinuxSessionManager.GetWebBrowserAvailable()to returntrueif:DISPLAY/WAYLAND_DISPLAY), ORxdg-openis available (new behavior)This matches MSAL's browser detection logic and ensures GCM, AzureAuth and MSAL behave consistently.
Behavior Changes
Testing
🤖 Generated with Claude Code