feat(provision): MSAL browser auth for headless Linux via wslview shim#259
Merged
Conversation
szymonos
force-pushed
the
feat/msal-browser-auth
branch
from
July 23, 2026 16:17
d6b3b0c to
a372dca
Compare
There was a problem hiding this comment.
Pull request overview
Adds a wslview shim and related profile tweaks to enable MSAL/MSAL.NET interactive browser auth-code flows on headless Linux environments (notably WSL/devcontainers), avoiding device-code auth that is blocked by Conditional Access. Also documents an MSAL redirect-port collision diagnosis lesson learned.
Changes:
- Add
.assets/config/bin/wslviewshim that prints the MSAL auth URL to the controlling terminal (CTRL+Click flow) instead of attempting to open a GUI browser. - Update
.assets/provision/setup_profile_user.ps1to conditionally install the shim (when no earlier MSAL opener exists), disable WAM in devcontainers, and persist a devcontainer IPv6 loopback workaround. - Add a postmortem entry in
design/lessons.mdcovering fixed reply-port (8400) collisions causing “Working…” hangs.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| design/lessons.md | Adds a new lessons-learned entry documenting an MSAL/Az reply-port collision diagnosis and remediation. |
| .assets/provision/setup_profile_user.ps1 | Conditionally installs a wslview shim for MSAL, disables WAM in containers, and adds a devcontainer IPv6 loopback environment fix to the PowerShell profile. |
| .assets/config/bin/wslview | New Bash shim that prints the MSAL auth URL to the controlling terminal so interactive login can proceed without a browser opener. |
szymonos
force-pushed
the
feat/msal-browser-auth
branch
from
July 23, 2026 16:48
a372dca to
2e09fcf
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
.assets/provision/setup_profile_user.ps1:101
- WAM can be disabled even if the wslview shim was not installed (e.g., shim source missing due to CWD mismatch or install failure). That leaves a headless environment with no opener and WAM disabled, breaking interactive auth. Gate WAM disable on the shim actually being present.
if ($headlessNoOpener -and (Get-Module Az.Accounts -ListAvailable)) {
szymonos
force-pushed
the
feat/msal-browser-auth
branch
3 times, most recently
from
July 23, 2026 17:42
3f597f4 to
792db77
Compare
szymonos
force-pushed
the
feat/msal-browser-auth
branch
from
July 23, 2026 17:52
792db77 to
730d4ad
Compare
…p_gh_repos A failed git clone (network/DNS/outage) left `cloned` false, so the "all repos already cloned" summary printed even when a repo was actually missing. Only clone when the dir is absent, and track real failures separately so the success message is suppressed on genuine errors. Co-Authored-By: Claude <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
wslviewshim (.assets/config/bin/wslview) that MSAL.NET execs as its last-resort browser opener on headless Linux (WSL, devcontainers, SSH VMs). Instead of opening a browser it prints the sign-in URL for CTRL+Click, keeping MSAL's localhost redirect listener alive — soConnect-AzAccount/Connect-MgGraphuse the browser auth-code flow instead of device code (which the Entra Conditional Access policy blocks).$headlessNoOpener(Linux AND no real MSAL opener AND no genuinewslviewon PATH) — desktop Linux with a realxdg-open/browser is left untouched.wslviewis a binary name hardcoded in MSAL.NET (NetCorePlatformProxy.cs), not a wslu dependency, so wslu's 2025-03 archival doesn't affect it.EnableLoginByWamin the orchestrators (linux_setup.sh,wsl_setup.ps1), right after the Az modules are installed under theazscope. This is deliberately not gated on$headlessNoOpener: the WAM broker (msalruntime.so) is non-functional on all Linux, so interactive Az login must always fall through to the browser flow there. It must run after Az install becauseSet-AzConfigneedsAz.Accounts— the earlier attempt (insetup_profile_user.ps1, which runs before Az install to trust PSGallery) silently no-op'd on fresh setups. Idempotent: skips the write when already off.DOTNET_SYSTEM_NET_DISABLEIPV6=1in the profile for containers (MSAL binds the redirect listener on IPv6 but VS Code forwards IPv4).setup_gh_repos.shcrashed on rerun (cloned: unbound variableunderset -u) — the flag was only assigned on a successful clone. Initializecloned=falseand test the value.design/lessons.mdpostmortems: (1) MSAL's fixed reply port (8400) shadowed by a Windows-side listener; (2) a provisioning step gated on a not-yet-installed module silently no-ops (the WAM bug).Test plan
make lint-diff— all pre-commit hooks greenwsl.exe -- pwsh -creparse (avoids$false, which expands to empty across that boundary — used a truthy guard + numeric0)setup_gh_repos.shrerun path (all repos cloned) no longer tripsset -uConnect-AzAccountfrom a fresh WSL distro provisioned by this branch — browser flow completes, no device code,Get-AzConfig -EnableLoginByWamshowsFalse/CurrentUser🤖 Generated with Claude Code