← blog · December 1, 2026

Moving to Passkeys: Choosing the RP ID, User Verification, Synced Keys and Account Recovery

Adding passkeys is more than two browser calls. The RP ID decision you cannot undo, the UV flag the server must read, the zero counter of synced keys and the recovery flow that quietly reduces passkey security to email.

Adding passkey support looks easy at first: two calls in the browser and a verification library on the server. The hard part is not those two calls but the decisions around them. Which domain the credentials bind to, whether user verification is mandatory, how synced keys behave with the signature counter, how many keys a user may have, and above all how someone who lost their key gets back into the account. Get one of these wrong and either the login screen breaks or the phishing resistance you paid for leaks out through a side door.

What a passkey actually is

A passkey is a WebAuthn public key credential that can also carry the user identity (a discoverable credential). The private key stays on the device or in the platform's password manager; the server only stores the public key. Phishing resistance comes from one place: the browser writes the page's real origin into the signed data and only lets the credential be used on pages that belong to the relying party ID (RP ID) chosen at registration. No matter how convinced the user is by a lookalike domain, the browser will not hand the key over.

In practice there are two kinds:

  • Synced passkeys live in the platform password manager and are copied to the user's other devices. They are hard to lose, but the key is not bound to a single piece of hardware.
  • Device-bound passkeys live on a security key or in one device's secure enclave and never leave it. They suit high-privilege accounts, and losing one hurts more.

For consumer applications, accepting synced passkeys is the right default. Requiring device-bound keys makes sense for a narrow group such as administrators; imposing it on everyone multiplies support load.

The decision you cannot undo: the RP ID

Every credential is bound to an RP ID when it is created. The RP ID can be the page's host or a registrable parent of it. A page served from login.example.com may choose example.com, and then the same passkey also works on app.example.com.

Two traps follow. The first is choosing the narrowest subdomain and later moving the login page to another subdomain: existing credentials no longer show up, and users have to register from scratch. The second is a rebrand to an entirely different domain. Some browsers support allowing related origins through a file published under /.well-known/webauthn, but do not assume every browser will. The safest path is to pick the long-lived registrable domain as the RP ID from day one.

Registration options

The registration options the server generates typically look like this:

{
  "rp": { "id": "example.com", "name": "Example" },
  "user": {
    "id": "<random 32 bytes, base64url>",
    "name": "[email protected]",
    "displayName": "Alice"
  },
  "challenge": "<server-generated random value, base64url>",
  "pubKeyCredParams": [
    { "type": "public-key", "alg": -7 },
    { "type": "public-key", "alg": -257 }
  ],
  "authenticatorSelection": {
    "residentKey": "required",
    "userVerification": "preferred"
  },
  "excludeCredentials": [
    { "type": "public-key", "id": "<an existing credential of this user>" }
  ],
  "attestation": "none",
  "timeout": 300000
}

Each field is there for a reason.

user.id is the field most often filled in wrong. It should not be an email address or a sequential database id. Make it a random value of at most 64 bytes with no personal data in it, and keep it stable when the user changes their email. The authenticator stores it and returns it at sign-in, and you use it to find the account.

alg: -7 is ES256 and -257 is RS256. ES256 is supported almost everywhere; keeping RS256 in the list is needed for some older platform authenticators.

residentKey: "required" is what makes username-less sign-in possible. Without it some authenticators create a credential that cannot be found without a username, and autofill sign-in does not work.

excludeCredentials prevents registering the same authenticator twice. Skip it and a user's list fills up with three passkeys from the same phone, with no way to tell which one is safe to delete.

attestation: "none" is the right choice for consumer apps. Attestation, which proves the make and model of the authenticator, only makes sense in enterprise settings that mandate specific hardware. Synced passkeys mostly do not provide it anyway, and asking for it only produces errors.

User verification: read the flag on the server

userVerification passes a request to the client; it is not a guarantee. If the authenticator collected a PIN or biometric, it sets the UV flag in the authenticator data of the response. If a passkey replaces both password and second factor for you, the server must check that flag and treat the sign-in as single-factor when it is not set. Writing "required" in the options and never looking at the flag in the response is a common mistake; the check means nothing unless it happens on the server.

Sign-in through autofill

The best experience is the browser offering the passkey when the user focuses the username field. Give the field the right autocomplete value and start a conditional request when the page loads:

<input type="text" name="username" autocomplete="username webauthn">
if (window.PublicKeyCredential &&
    await PublicKeyCredential.isConditionalMediationAvailable?.()) {
  const options = await fetch('/webauthn/login/options').then(r => r.json());
  const credential = await navigator.credentials.get({
    mediation: 'conditional',
    publicKey: decodeOptions(options)
  });
  await fetch('/webauthn/login/verify', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(encodeCredential(credential))
  });
}

decodeOptions and encodeCredential convert between base64url and binary; use the helpers your client library provides rather than writing them by hand. Leave allowCredentials empty in a conditional request, because you do not know the user yet.

Verifying and storing on the server

Do not write CBOR parsing, signature verification and flag handling yourself. Mature libraries exist: SimpleWebAuthn for JavaScript, go-webauthn for Go, py_webauthn for Python, webauthn4j for Java. The library does the work, but what you feed it matters:

  • Challenge: at least 16 random bytes generated on the server, bound to the session, short-lived and single-use. A challenge that is not deleted after verification opens the door to replay.
  • Expected origin and RP ID: taken from a fixed allow list, never derived from the request's Host header.
  • What to store: credential id (binary, uniquely indexed), public key, signature counter, transports, the backup eligibility and backup state flags, creation and last-used time, and a name the user chose.

The signature counter trap

The specification suggests suspecting a cloned authenticator when the counter fails to increase. Most synced passkeys, however, always send zero. When both the stored and the received value are zero, skip the check. An implementation that rejects sign-in outright when the counter goes backwards locks out users who switch devices; recording it and raising a warning is healthier than refusing.

The real weak link: account recovery

However strong the passkey, if the "I lost my passkey" path is a link sent by email, the account is exactly as secure as the email account. Attackers do not fight the passkey; they use the recovery flow.

A workable approach:

  1. Nudge users to add a second passkey. Asking for a second registration from another device or a security key right after the first one removes most of the need for recovery.
  2. Issue single-use recovery codes and store them hashed, like passwords.
  3. Open a restricted session after recovery: allow registering a new passkey, put sensitive actions such as changing the email or payment details behind a waiting period, and notify the account owner.
  4. Notify the user whenever a passkey is added or removed. An attacker's first move is to add their own key.

You do not have to remove passwords right away. During the transition, offering passkey registration to users who signed in with a password, and letting passkey holders switch the password off, balances support load and risk.

When not to rush

If most of your users sign in from shared devices, such as kiosks or call center desks, the personal-device assumption behind passkeys does not hold; a portable option like smart cards or security keys fits better. If authentication is already delegated to an identity provider, enable passkeys there rather than in each application, or you end up with credentials for the same user scattered across systems that know nothing about each other. Finally, do not ship passkeys before you have designed recovery. Recovery first, passkeys second: that order keeps the first "I lost my key" ticket from pushing the team into a hasty, weak email reset.

[ ← Back to burak.sh ]