-
Notifications
You must be signed in to change notification settings - Fork 5
feat(provision): MSAL browser auth for headless Linux via wslview shim #259
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
069187b
feat(provision): MSAL browser auth for headless Linux via wslview shim
szymonos 25324b5
fix(provision): guard setup_gh_repos cloned flag for set -u on rerun
szymonos 730d4ad
docs(lessons): MSAL reply-port collision postmortem
szymonos dcde181
fix(provision): distinguish clone failure from already-cloned in setu…
szymonos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #!/usr/bin/env bash | ||
| # MSAL browser auth shim - emulate `az login` clickable-link behavior for | ||
| # Connect-AzAccount / Connect-MgGraph on headless Linux without a browser opener. | ||
| # | ||
| # Az/Graph PowerShell start the browser auth-code flow by exec'ing the first opener | ||
| # found on PATH from a list hardcoded in MSAL.NET (NetCorePlatformProxy.cs): default | ||
| # order xdg-open, gnome-open, kfmclient, microsoft-edge, wslview. `wslview` is the | ||
| # last-resort slot - reliably empty on non-desktop Linux (WSL, devcontainers, SSH | ||
| # VMs) - so filling it lets MSAL reach a browser instead of falling back to device | ||
| # code flow, now blocked by the Entra Conditional Access policy. It is only a PATH | ||
| # binary name to MSAL, not a wslu dependency (wslu archived 2025-03), so this shim | ||
| # stands regardless of wslu's status. MSAL execs `wslview <AUTH_URL>`; | ||
| # we print the URL instead so it can be CTRL+Clicked, and MSAL keeps its localhost | ||
| # listener open to catch the post-auth redirect. | ||
| # | ||
| # Caveat: the redirect only completes where the browser's localhost reaches that | ||
| # listener - native on WSL (shared loopback), but over SSH it needs the redirect | ||
| # port forwarded, and in VS Code devcontainers MSAL must bind IPv4 (see the | ||
| # DOTNET_SYSTEM_NET_DISABLEIPV6 block in setup_profile_user.ps1). | ||
| # | ||
| # Installed to ~/.local/bin/wslview by setup_profile_user.ps1, only when no real | ||
| # MSAL opener (incl. wslu's wslview on Debian-based distros) is already present. | ||
| url=$1 | ||
| # %s consumes the URL as an argument so percent-encoded chars are not reparsed. | ||
| template='\n\e[96mTo sign in, CTRL+Click (or copy) this URL and authenticate in your browser:\e[0m\n\e[4m%s\e[0m\n\n' | ||
| # Write straight to the controlling terminal - MSAL swallows child stdout/stderr; | ||
| # fall back to stdout when no tty is attached (e.g. non-interactive test runs). | ||
| printf "$template" "$url" >/dev/tty 2>/dev/null || printf "$template" "$url" | ||
| exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.