Repository navigation
feat: add system passkey support on macOS via app.configureWebAuthn() - #51563
Conversation
|
@CliftonH can you rebase your PR with the latest from main? Also, looks like linting failed here: If you run |
9bc1300 to
1443c2d
Compare
Rebased, thanks for the heads-up! |
app.configureWebAuthn()
MarshallOfSound
left a comment
There was a problem hiding this comment.
The ASAuthorizationController integration itself looks right, and after digging into Chromium's device/fido/mac/icloud_keychain.mm I agree we can't reuse it — their path is gated on ProcessHasEntitlement() checking for com.apple.developer.web-browser.public-key-credential which Electron apps won't have. We should put a comment somewhere saying that though, otherwise the next person to find Chromium's iCloud Keychain code is going to wonder why we wrote our own.
Two bigger things before this lands tho:
-
The
ElectronPasskeyControllerabstraction layer doesn't buy us anything — single impl, the "other platforms" the header mentions don't exist (it's only built on mac), and it adds a translation hop in each direction plus 4 mirror structs that just shadow the FIDO types. Can we haveElectronICloudKeychainAuthenticatordriveASAuthorizationControllerdirectly and delete the controller files? Drops ~300 lines and 2 files. -
We don't override
EmbedderControlsAuthenticatorDispatchso when bothtouchIDandiCloudKeychainare configured (the docs example does exactly this 😅),FidoRequestHandlerBase::AuthenticatorAddeddispatches to both immediately and the user gets the Touch ID prompt and the Apple sheet at the same time. Thepreferenceoption is supposed to fix this butGetPasskeyPreference()is never read anywhere — so right now it's dead API. We should either wire it up or drop it.
On the API shape itself — I think we should rethink the iCloudKeychain option before this lands.
iCloudKeychain: { enabled: boolean } should just be iCloudKeychain: boolean. There's only one knob inside the object once preference moves out (see below), and a single-property object whose only property is enabled is just a boolean with extra steps. We didn't do touchID: { enabled: true, keychainAccessGroup: ... } either — touchID is { keychainAccessGroup } because the access group is the only thing it needs. Same logic.
app.configureWebAuthn({
touchID: { keychainAccessGroup: 'A1B2C3D4E5.com.example.app.webauthn' },
iCloudKeychain: true
})preference doesn't belong inside iCloudKeychain at all — it's a cross-cutting concern about which authenticator handles a given request, not a property of iCloud Keychain itself. As a static string it also can't express anything dynamic (e.g. "iCloud Keychain for create() so it syncs, but Touch ID for get() if a Touch ID credential already exists for this RP", or "ask the user"). And right now it's a no-op anyway since GetPasskeyPreference() is never read.
We should make this event-driven, same shape as select-webauthn-account. Something like a select-webauthn-authenticator event on session:
win.webContents.session.on('select-webauthn-authenticator', (event, details, callback) => {
// details: { relyingPartyId, requestType: 'create' | 'get',
// authenticators: ('touchID' | 'iCloudKeychain')[], frame }
if (details.requestType === 'create') {
callback('iCloudKeychain') // sync new credentials
} else {
callback(details.authenticators[0]) // first available
}
})If no listener is registered we pick a sensible default (probably iCloudKeychain if available, falling back to touchID, since synced is the better UX) — that keeps the zero-config path working. Calling callback() with no args cancels the request, same as select-webauthn-account.
The event also fixes the current bug where configuring both touchID and iCloudKeychain makes both prompts appear simultaneously, because we'd actually be overriding EmbedderControlsAuthenticatorDispatch and only dispatching to the one the app picks.
MarshallOfSound
left a comment
There was a problem hiding this comment.
Blocking on above review
|
Realised something else digging into the Apple docs — We should rename this before it ships. Apple's own API is "Platform Public Key Credential Provider", not "iCloud Keychain Provider", for exactly this reason. Chromium calls their version Something like app.configureWebAuthn({
touchID: { keychainAccessGroup: 'A1B2C3D4E5.com.example.app.webauthn' },
platformPasskeys: true
})This also makes the Same goes for the file names / class names ( |
caf9e90 to
fab4e55
Compare
1b45e35 to
aa2781f
Compare
app.configureWebAuthn()app.configureWebAuthn()
0d2e3fa to
004e0b0
Compare
samuelmaddock
left a comment
There was a problem hiding this comment.
Have a few minor comments, but looks great overall!
004e0b0 to
243aa32
Compare
|
For more information on signing commits, see GitHub's documentation on Telling Git about your signing key. |
243aa32 to
40ba515
Compare
- Reject requests whose clientDataJSON challenge can't be parsed instead of falling back to client_data_hash (which Apple re-hashes, breaking RP verification). Same in MakeCredential and GetAssertion. - Reject cross-origin (iframe) ceremonies rather than presenting them to the RP as same-origin, since the public API can't carry the frame origin — Apple always builds a top-level origin: https://<rpId> clientDataJSON. - Fail the ceremony when Apple's returned clientDataJSON doesn't validate, instead of forwarding Chromium's JSON and stranding a keychain credential that can never verify RP-side. - Reset objc_storage_ at the start of each operation so stale expected challenge/origin/type can't bleed across requests. - Log an actionable DevTools message on ASAuthorizationError 1004, and document the signing / provisioning-profile / associated-domain (AASA) requirements plus the origin: https://<rpId> expectedOrigin note in app.md. Co-Authored-By: Claude <[email protected]>
…check - Map excluded-credential rejections on every supported macOS version: macOS 13.5-14 surfaces them as WKErrorDomain code 8, macOS 15+ as ASAuthorizationErrorMatchedExcludedCredential (1006). Previously only 1006 was handled, so create() with a matching excludeCredentials entry returned NotAllowedError instead of the spec-required InvalidStateError on 13.5-14. Capture the error domain as a string (not a bool) to distinguish the two. - Correct the stale "1006 was added in macOS 14" comment — it is macOS 15. - Add a defense-in-depth check that the credential ID in the attested authenticator data matches ASAuthorization...Registration.credentialID, failing kAuthenticatorResponseInvalid on mismatch. Mirrors Chromium's device/fido/mac/icloud_keychain.mm. - Clarify that the isUVPAA override reports capability, not configuration: a misconfigured (unsigned / no embedded profile / no AASA) app still gets true and then fails the ceremony with error 1004. Co-Authored-By: Claude <[email protected]>
Collapse a wrapped executeJavaScript() call onto one line to match oxfmt. Co-Authored-By: Claude <[email protected]>
7bb200a to
4fa2d23
Compare
macOS 12 is no longer supported (electron#51967), so macOS 13 is the minimum deployment target and the "requires macOS 13" caveats are redundant. Remove them and the now-unreachable "below 13.0 fallback" note. Addresses review feedback from jkleinsc. Co-Authored-By: Claude <[email protected]>
|
Congrats on merging your first pull request! 🎉🎉🎉 |
|
Release Notes Persisted
|
## Summary
Bumps the Desktop app from Electron 44.10.0 to 45.4.1. Only
`apps/desktop/package.json` and the lockfile change; there are no app
code changes.
Electron 45 ships the macOS system passkey authenticator
(`app.configureWebAuthn({ platformPasskeys: true })`,
electron/electron#51563), which follow-up work on in-app browser
passkeys builds on. This PR doesn't enable it.
45.4.1 is the newest 45.x release that meets the 7-day
`minimum-release-age` policy in `apps/desktop/.npmrc`. 45.5.0 will
follow in a separate PR once it qualifies.
Part of nuphos#4902
## Breaking changes reviewed (Electron 45.0)
- **Sandboxed preloads lose `Buffer`, `setImmediate` and the
`events`/`timers`/`url` shims.** Not affected. The only window preload
belongs to the main window, which is `sandbox: false`. The guest frame
preload (`browser-preload.ts`) imports only `contextBridge`, and the
`electron-chrome-extensions` preload requires only `electron`.
- **Screen capture is reported as `display-capture` instead of
`media`.** No behavior change. The default session handler only inspects
`media`, the microphone, and grants everything else as before. The
in-app browser session still denies everything except clipboard writes.
- **`window.open()` children of unsandboxed windows get their own
process.** Not affected. The main window denies `window.open` and opens
the URL externally.
- **Workers in subframes, DevTools extension preloads, `contentTracing`,
`requestStorageAccessFor`, ASAR file descriptors, and `safeStorage`
deprecations.** Not used.
## Lockfile
The lockfile resolves `[email protected]`. Electron's own dependencies are
unchanged, but re-resolving its subtree points a few entries at
`[email protected]` and `[email protected]`, which were already in the
lockfile. No packages are added.
`node-abi` moves from 4.33.0 to 4.43.0, within `@electron/rebuild`'s
`^4.2.0` range. 4.33.0 has no ABI entry for Electron 45, so rebuilding
`node-pty` failed during packaging.
## Testing
- `tsc -b --noEmit` passes against the Electron 45 types.
- CI, including Desktop against a real backend.
- Manual smoke test on macOS (launch, in-app browser, microphone,
auto-update, helpers) against a non-production backend with a test
account. Results will be posted here.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Signed-off-by: Yuanlin Lin <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Description of Change
Adds platform passkey support to Electron on macOS via
app.configureWebAuthn(). Apps can enable Touch ID (keychain-backed credentials) and/or platform passkeys (served by any Credential Provider Extension - iCloud Keychain, 1Password, etc. - viaASAuthorizationController).When both authenticators are configured, a new
select-webauthn-authenticatorsession event lets the app choose which to dispatch, preventing the dual-prompt bug where both Touch ID and the Apple passkey sheet appear simultaneously.API
Implementation
ElectronPlatformPasskeysAuthenticator- implementsFidoAuthenticatorby drivingASAuthorizationControllerdirectly (no intermediate controller abstraction).ElectronPlatformPasskeysDiscovery- plugs into Chromium's FIDO discovery stack, creates the authenticator when macOS 13+ is available.ElectronAuthenticatorRequestClientDelegate- overridesEmbedderControlsAuthenticatorDispatchto intercept auto-dispatch when both authenticators are present. Emitsselect-webauthn-authenticatoron the session; defaults toplatformPasskeysif no listener.ElectronWebAuthenticationDelegate- stores static configuration for Touch ID keychain access group and platform passkeys enabled state.Requirements:
com.apple.developer.associated-domainsentitlement withwebcredentials:<domain>entries and a matching AASA file on the relying party's serverChecklist
npm testpassesRelease Notes
Notes: Added
app.configureWebAuthn()API to enable iCloud Keychain passkey support on macOS. When enabled,navigator.credentials.create()and.get()present Apple's native passkey UI viaASAuthorizationController.