Skip to content

feat: support WebAuthn Touch ID platform authenticator on macOS - #51255

Merged
jkleinsc merged 7 commits into
mainfrom
sam/webauthn-touch-id
Apr 30, 2026
Merged

jkleinsc merged 7 commits into
mainfrom
sam/webauthn-touch-id

Conversation

@MarshallOfSound

Copy link
Copy Markdown
Member

Summary

  • Adds 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 its keychain-access-groups entitlement); Electron generates and persists a per-partition metadata secret in prefs, mirroring Chrome's TouchIdAuthenticatorConfigForProfile.
  • Adds ElectronAuthenticatorRequestClientDelegate wired through ContentBrowserClient::GetWebAuthenticationRequestDelegate() so that discoverable-credential navigator.credentials.get() calls with multiple matches emit a new 'select-webauthn-account' session event instead of hitting the base DCHECK(virtual_environment_). If no listener is registered (or the listener's callback is invoked with no credential) the request is cancelled with NotAllowedError — an account is never auto-selected.
  • Only OS-native prompts are shown (the LAContext biometric sheet); no Chromium Views UI. Auto-dispatch is left at the content default since only one kInternal authenticator is enabled.

Checklist

  • PR description included and stakeholders cc'd
  • npm test passes
  • tests are included
  • documentation is changed or added
  • PR release notes describe the change in a way relevant to app-developers

Release Notes

Notes: Added app.configureWebAuthn() to enable the Touch ID platform authenticator for WebAuthn on macOS, and a select-webauthn-account session event for choosing between multiple discoverable credentials.

@MarshallOfSound MarshallOfSound added the semver/minor backwards-compatible functionality label Apr 22, 2026
@codebytere
codebytere self-requested a review April 22, 2026 20:25

@nmggithub nmggithub left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor thoughts. Overall, looks good.

Comment thread docs/api/app.md
Comment on lines +1242 to +1245
* `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`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +1688 to +1689
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread docs/api/session.md Outdated
Comment on lines +645 to +648
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the user doesn't call callback at all in their handler? Yes, this shouldn't be supported, but I am curious.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The request pends forever 🤷

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whelp. Maybe we can change "should" to a "must" in the documentation? I'm not picky, but just wanted to flag this edge case.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't typically write docs in the imperative spec style. cc @erickzhao for thoughts

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@erickzhao erickzhao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API LGTM

@itsananderson itsananderson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API LGTM

Comment thread docs/api/session.md Outdated
Comment on lines +645 to +648
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@MarshallOfSound MarshallOfSound added target/41-x-y PR should also be added to the "41-x-y" branch. target/42-x-y PR should also be added to the "42-x-y" branch. labels Apr 29, 2026

@codebytere codebytere left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API LGTM

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.
@jkleinsc
jkleinsc force-pushed the sam/webauthn-touch-id branch from 97521a6 to d39475c Compare April 30, 2026 14:32
@jkleinsc
jkleinsc merged commit 00f0989 into main Apr 30, 2026
71 checks passed
@jkleinsc
jkleinsc deleted the sam/webauthn-touch-id branch April 30, 2026 16:40
@release-clerk

release-clerk Bot commented Apr 30, 2026

Copy link
Copy Markdown

Release Notes Persisted

Added app.configureWebAuthn() to enable the Touch ID platform authenticator for WebAuthn on macOS, and a select-webauthn-account session event for choosing between multiple discoverable credentials.

@trop

trop Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "42-x-y", please check out #51411

@trop

trop Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "41-x-y", please check out #51412

@trop trop Bot added in-flight/41-x-y merged/42-x-y PR was merged to the "42-x-y" branch. merged/41-x-y PR was merged to the "41-x-y" branch. and removed target/42-x-y PR should also be added to the "42-x-y" branch. target/41-x-y PR should also be added to the "41-x-y" branch. in-flight/42-x-y in-flight/41-x-y labels Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-review/approved ✅ merged/41-x-y PR was merged to the "41-x-y" branch. merged/42-x-y PR was merged to the "42-x-y" branch. semver/minor backwards-compatible functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants