ruby-passkeys / warden-webauthn

A Warden Strategy for WebAuthn
MIT License
19 stars 3 forks source link

`authenticator_selection` should require discoverable credentials; with optional hooks to customize by implementors #7

Closed tcannonfodder closed 1 year ago

tcannonfodder commented 1 year ago

Currently, the authenticator_selection does not require that discoverable credentials be used.

This can be changed by updating the authenticator_selection to have resident_key: "required"

For example, this is where we'd change it in the RegistrationHelpers: https://github.com/ruby-passkeys/warden-webauthn/blob/main/lib/warden/webauthn/registration_helpers.rb#L11

authenticator_selection: { resident_key: "required", user_verification: "required" }

By default, warden-webauthn should explicitly require that the credentials must be discoverable:

Passkeys are primarily driven by the use of discoverable credentials. Discoverable credentials are a mechanism provided by the WebAuthn specification that allows for seamless authentication without the user having to provide either a username or password. In fact, WebAuthn credentials are determined to be passkeys based on their “discoverability”. ... It’s important in our context of passkeys to focus primarily on discoverable credentials; a WebAuthn credential is not considered a passkey unless it’s discoverable. https://developers.yubico.com/Passkeys/Passkey_concepts/Discoverable_vs_non-discoverable_credentials.html

This detail, and the desire to have the gem as secure by default, means that the resident_key should be required. Some problems with non-discoverable credentials are:

However, there is this caveat in the Yubico documentation:

Supporting non-discoverable credential flows is important for two distinct reasons:

While supporting this edge case is not something we want to implement in this gem, we should make it possible for an implementor to write their own strategy that does support it, for the cases where this truly is a need for their implementation. So we should make sure:

Note

"Discoverable Credentials" were previously known as "Resident Credentials", see: https://www.w3.org/TR/webauthn-2/#discoverable-credential

This is cleaning up a discussion that's been spread across a number of issues & PRs, pinging @heliocola: