fix(desktop): Entra sign-in offers passkeys in the preview browser #30018
main fromrefs/pull/30018/head·opened View on GitHubProblem#
Entra sign-in hides the passkey option in the desktop preview browser. The request User-Agent contains an Electron/<version> token, and Entra then stops offering passkeys even though the embedded Chromium supports WebAuthn and platform authenticators (Windows Hello, and 1Password as Windows plugin passkey provider). Details and measurements are in https://git.cafe/pingdotgg/t3code/issues/30014.
Change#
BrowserSession registers a webRequest.onBeforeSendHeaders listener, scoped to login.microsoftonline.com, login.microsoft.com and login.live.com, that removes the Electron/<version> token from the User-Agent request header. Nothing else changes:
navigator.userAgentand every other site keep Electron's native User-Agent, so the Turnstile fix from https://git.cafe/pingdotgg/t3code/pulls/7110 is unaffected.- The request headers object is copied, not mutated.
- The fix is host-scoped on purpose; a global rewrite is what https://git.cafe/pingdotgg/t3code/pulls/7110 removed.
Scope and approval#
This is a behavior change, so it needs maintainer direction. https://git.cafe/pingdotgg/t3code/issues/30014 is the bug report; it has not been triaged yet, so there is no maintainer approval to link at the time of writing. I opened this as a small, host-scoped change so the direction can be judged against concrete code, and I will rework or close it if the maintainers prefer a different approach (for example a per-profile setting, as discussed in https://git.cafe/pingdotgg/t3code/issues/22444).
Verification#
vp test run src/preview/BrowserSession.test.tsinapps/desktop: 10 of 10 pass, including two new tests: one for the token stripping (with and without a token present) and one that the listener is registered for exactly the three Microsoft hosts, handlesUser-Agentanduser-agentheader keys, and leaves the original headers object untouched.vp fmt --checkandvp linton the two changed files, plus the pre-commitknip:check.- Manual A/B test on Windows 11 in a dev build (Electron 44.10.0, same build, same account, 1Password as passkey provider), with the rewrite toggled off and on:
- rewrite off: Entra shows no passkey option
- rewrite on: Entra shows the passkey option and sign-in works
navigator.userAgentin the page was identical in both runs.
What I could not check:
- I did not capture the outgoing header on the wire; the effect is inferred from the behavior change.
- I do not know whether
Electron/is the only trigger Entra looks at, or whether the app token matters too. - Only Windows was tested. macOS and Linux were not.
I also asked Microsoft whether this Entra behavior is intended: https://learn.microsoft.com/en-us/answers/questions/6059339/entra-sign-in-does-not-offer-passkeys-when-the-use
Closes https://git.cafe/pingdotgg/t3code/issues/30014
Model and harness: Claude Sonnet 5.5 via Claude Code.
🤖 Generated with Claude Code
Fixes pingdotgg/t3code#30014
- 1
- 2
Pushed05f3eeb
Thanks for this. Main has the change since #45049.
Compared your BrowserSession.ts and BrowserSession.test.ts diff with the merged change: main now removes Electron/ for all preview requests, including all three Microsoft sign-in hosts your patch covers, and keeps page and worker identities consistent.
Closing as superseded.
juliusmarminge closed this
Sign in to join this conversation.
Windows 11 proof: Entra offers a passkey with this change, not without it#
Run by me on a real Windows 11 machine, which is the case the automated pipeline could not cover.
Environment
A/B
login.microsoftonline.com05f3eebb4f, merged with currentmain), recording BRecording A (without the rewrite):
https://github.com/user-attachments/assets/4824949f-a849-4b4d-9201-110d689dcf87
Recording B (with this branch):
https://github.com/user-attachments/assets/ddcbecb3-087b-49a4-beca-539dab358eef
Recording B goes from the account picker straight to the passkey page, so it does not show the method list itself; recording A shows that list without a passkey entry. In recording B the sign-in then completes: after the passkey dialog the preview browser lands on Microsoft Copilot (
copilot.cloud.microsoft), signed in.Not verified: macOS and Linux authenticators, and whether
Electron/is the only token Entra looks at.I also pushed
05f3eebb4fto this branch: it merges currentmainto clear the conflict, andisTeamsUrlbecomesisElectronTokenStrippedUrl. The intent is unchanged:Electron/<version>is removed from theUser-Agentrequest header only for Teams and the three Microsoft sign-in hosts (login.microsoftonline.com,login.microsoft.com,login.live.com), inside the single sharedonBeforeSendHeaderslistener onmain.navigator.userAgentand all other hosts keep the native value.