Repository navigation
feat: support WebAuthn Touch ID platform authenticator on macOS - #51255
Conversation
nmggithub
left a comment
There was a problem hiding this comment.
Just some minor thoughts. Overall, looks good.
| * `keychainAccessGroup` string - The keychain access group that WebAuthn | ||
| credentials will be stored under. This value **must** also be present in | ||
| your app's `keychain-access-groups` code-signing entitlement, and is | ||
| typically of the form `<TEAM_ID>.<BUNDLE_ID>.webauthn`. |
There was a problem hiding this comment.
Are keychain access groups of a different form even supported on the platform level? If not, maybe we handle this formatting for the end user?
There was a problem hiding this comment.
You can name it whatever you want 🤷 Documentation here is accurate and good
| } | ||
| } |
There was a problem hiding this comment.
Silently doing nothing when there are no valid options may be an OK practice in this API's limited form. However, if the plan is to add more (and more complex) options in the future, we may want do something specifically in this no-valid-options case.
There was a problem hiding this comment.
Silently doing nothing when there are no valid options may be an OK practice in this API's limited form. However, if the plan is to add more (and more complex) options in the future, we may want do something specifically in this no-valid-options case.
🤷 left as a future problem, I think there's 0 harm in an API that no-ops on no-input. It's designed to allow N inputs in the future, no issue if N =0
| Emitted when a call to `navigator.credentials.get()` resolves multiple | ||
| discoverable WebAuthn credentials and the user must choose one. `callback` | ||
| should be called with the `credentialId` of the selected account; passing no | ||
| arguments to `callback` will cancel the request. If no listener is registered |
There was a problem hiding this comment.
What happens if the user doesn't call callback at all in their handler? Yes, this shouldn't be supported, but I am curious.
There was a problem hiding this comment.
The request pends forever 🤷
There was a problem hiding this comment.
Whelp. Maybe we can change "should" to a "must" in the documentation? I'm not picky, but just wanted to flag this edge case.
There was a problem hiding this comment.
We don't typically write docs in the imperative spec style. cc @erickzhao for thoughts
There was a problem hiding this comment.
I know we have other APIs with a similar "The request pends forever 🤷" issues, but would it be worth explicitly mentioning this behavior? It might help nudge people to be more defensive in their event handler (e.g. by adding a try {} finally { callback() } to avoid hung requests)
| Emitted when a call to `navigator.credentials.get()` resolves multiple | ||
| discoverable WebAuthn credentials and the user must choose one. `callback` | ||
| should be called with the `credentialId` of the selected account; passing no | ||
| arguments to `callback` will cancel the request. If no listener is registered |
There was a problem hiding this comment.
I know we have other APIs with a similar "The request pends forever 🤷" issues, but would it be worth explicitly mentioning this behavior? It might help nudge people to be more defensive in their event handler (e.g. by adding a try {} finally { callback() } to avoid hung requests)
4088145 to
312ead0
Compare
Adds `app.configureWebAuthn({ touchID: { keychainAccessGroup } })` to enable
the Secure Enclave platform authenticator for `navigator.credentials`.
Credentials are stored under the app-supplied keychain access group with a
per-session metadata secret that is generated on first use and persisted in
prefs.
Also introduces `ElectronAuthenticatorRequestClientDelegate` and wires it via
`ContentBrowserClient::GetWebAuthenticationRequestDelegate()` so that
discoverable-credential `get()` calls with multiple matches emit a new
`select-webauthn-account` session event instead of DCHECK-failing in the base
delegate. If no listener is registered (or the callback is invoked with no
credential), the request is cancelled with NotAllowedError rather than
silently auto-selecting.
Tests use the DevTools virtual authenticator so the account-selection flow is
exercised in CI without entitlements or real hardware.
The base AuthenticatorRequestClientDelegate::StartObserving() is a no-op, so observer() on the request handler stayed null. MakeCredentialRequestHandler:: SpecializeRequestForAuthenticator dereferences observer()->SupportsPIN() when residentKey is 'preferred', crashing with SEGV when a real FIDO2 HID key is dispatched. Override StartObserving/StopObserving to register via a ScopedObservation like ChromeAuthenticatorRequestDelegate does. Added a virtual-authenticator regression test for create() with residentKey: 'preferred'.
- Encode credentialId and userHandle as URL-safe base64 without padding so the values match PublicKeyCredential.id from navigator.credentials.get() byte-for-byte; tests now assert the equality rather than transcoding. - Cancel the pending request when the listener invokes the callback with a credentialId that does not match any account, instead of leaving the request hanging while the listener retries. The TypeError still surfaces so the misuse remains visible to the developer. - DCHECK that the Touch ID config helpers run on the UI thread, encoding the threading invariant the read-then-write metadata-secret pref relies on.
Throwing back into the listener bubbles up as an unhandled exception in the main process. Match the no-args branch exactly so the listener sees a single consistent failure mode (cancel + NotAllowedError) whether it declines deliberately or by mistake.
97521a6 to
d39475c
Compare
|
Release Notes Persisted
|
|
I have automatically backported this PR to "42-x-y", please check out #51411 |
|
I have automatically backported this PR to "41-x-y", please check out #51412 |
Summary
app.configureWebAuthn({ touchID: { keychainAccessGroup } })macOS — enables the Secure Enclave / Touch ID platform authenticator for the Web Authentication API. The app supplies the keychain access group (which must also appear in itskeychain-access-groupsentitlement); Electron generates and persists a per-partition metadata secret in prefs, mirroring Chrome'sTouchIdAuthenticatorConfigForProfile.ElectronAuthenticatorRequestClientDelegatewired throughContentBrowserClient::GetWebAuthenticationRequestDelegate()so that discoverable-credentialnavigator.credentials.get()calls with multiple matches emit a new'select-webauthn-account'session event instead of hitting the baseDCHECK(virtual_environment_). If no listener is registered (or the listener's callback is invoked with no credential) the request is cancelled withNotAllowedError— an account is never auto-selected.LAContextbiometric sheet); no Chromium Views UI. Auto-dispatch is left at the content default since only onekInternalauthenticator is enabled.Checklist
npm testpassesRelease Notes
Notes: Added
app.configureWebAuthn()to enable the Touch ID platform authenticator for WebAuthn on macOS, and aselect-webauthn-accountsession event for choosing between multiple discoverable credentials.