# Passkey sign-in for customers

> Let customers sign in with a passkey alone, with nothing to type and nothing to phish, and decide what a customer without one is asked for.

A passkey is the best sign-in for a customer: nothing to remember, nothing to type, and nothing a fake site can
capture. Every realm signs a customer in with a passkey alone, from the first day, bound to your realm's own domain.
Customers who haven't added one yet sign in with a password and a second step, and add a passkey once they're in.

## Before you begin

- **Privilege:** `RealmOwner` in the customer realm to change passkey and sign-in settings. Customers need no
  privilege to add or remove their own passkeys.
- **Where:** settings through the API; customers add and remove passkeys on their account page or through the API.
- **A host name for the realm,** such as `foobar.cvyuh.com`. A realm created with one has passkeys from the start.

## How it works

Every new realm signs customers in this way:

1. **A passkey, if they have one.** It signs the customer in on its own. A customer with no passkey, or a name the
   realm doesn't hold, makes this step stand aside, so the next page reveals nothing about which it was.
2. **Otherwise, a password,** then **a code from an authenticator app**, which a new realm requires. A customer with
   no app is walked through setting one up the first time.

Customers add a passkey from their account page: it confirms it's still them, then registers the passkey. Within 10
minutes of signing in, the confirmation stands aside; after that, they confirm with their authenticator app or a
passkey they already hold. Right after a fresh sign-in, the browser can offer to make one quietly. With their first
factor, the realm shows them a set of one-time recovery codes, once.

Passkeys are bound to the realm's **relying party ID**, `rpId`. A realm created with a host name, such as
`foobar.cvyuh.com`, has that host as its `rpId`, so passkeys work from the start.

## Set it up

As a realm administrator, with your session in `$CVYUH_SESSION` (see [Call the API](/develop/api/)).

1. **Check the passkey domain,** and set the name customers see when their device asks to save one:

   ```sh
   curl -X PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/webauthnSettings/webauthnSettings \
     -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
     -H "Content-Type: application/json" \
     -d '{ "rpId": "foobar.cvyuh.com", "rpName": "Example" }'
   ```

   Choose `rpId` once: changing it later orphans every passkey the realm holds.

2. **Decide whether customers without a passkey need a second step.** Requiring it (`twoFactorMandatory: true`, the
   default in a new realm) asks every password sign-in for an authenticator-app code. Turning it off lets a customer
   who has no app skip setting one up, for `twoFactorSkipDays` at a time:

   ```sh
   curl -X PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/authSettings/authSettings \
     -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
     -H "Content-Type: application/json" \
     -d '{ "twoFactorMandatory": false, "twoFactorSkipDays": 30 }'
   ```

   A customer who signs in with a passkey is never asked for a second step either way.

## What customers see

- **Adding a passkey.** On their account page they choose to add one. Their device shows its own prompt, naming your
  `rpName` and their sign-in name, and asks for a fingerprint, a face or the device PIN. On a computer without a
  passkey of its own, the browser offers to save it on a phone, by a QR code the phone scans.
- **Signing in with one.** They type their sign-in name, and the device asks them to confirm with a fingerprint, face
  or PIN. That's the whole sign-in. A passkey kept on their phone works from a computer the same way, by a QR code.
- **When it fails.** A passkey that doesn't verify, or a prompt the customer cancels, shows "That passkey did not
  work. Try again." After three tries (`attemptsPerLogin`), the sign-in fails and they start again. A customer whose passkey keeps failing
  signs in with their password and authenticator app instead.

## Limits and defaults

| Setting | Default | Range |
|---|---|---|
| `rpId` | The host name the realm was created with | One of the realm's host names, or a domain they sit under that no other realm's host names share |
| `userVerification` | `preferred` | `required` shuts out security keys without a PIN or biometric |
| `residentKey` | `required` | Passkeys are kept on the device, so the customer picks theirs without typing more |
| `timeoutSeconds` | `300` | `300` to `600` |
| `attemptsPerLogin` | `3` | `1` or more |
| `twoFactorMandatory` | `true` in a new realm | |
| `twoFactorSkipDays` | `30` | `0` makes a skip permanent |
| `relatedOrigins` | none | At most five domains |

## Troubleshooting

| Symptom | Cause | Fix |
|---|---|---|
| No passkey prompt; customers go straight to a password | The realm has no `rpId`, or the customer has no passkey yet | Set `rpId`; customers add a passkey from their account page |
| Passkeys stopped working for everyone | `rpId` was changed | Set it back. Passkeys made under the old `rpId` work only there |
| The prompt never appears inside your mobile app | The sign-in is in an embedded web view, which often can't reach the device's passkeys | Open the sign-in in the system browser (`ASWebAuthenticationSession` on iOS, Custom Tabs on Android) |
| A passkey from one brand isn't offered on another | Each realm has its own `rpId` | Expected: see [A realm per brand](../../realms/brand-realms/) |
| A customer can't add a new passkey | They hold a passkey the realm has turned off | They remove it from their account page, then add the new one |

## FAQ

- **A customer has a new phone.** A synced passkey, one kept in their Apple, Google or password-manager account,
  arrives on the new phone by itself. A passkey kept on the old device alone doesn't: they sign in with their
  password and authenticator app, then add a passkey on the new phone.
- **A customer lost their device.** They sign in with their password and authenticator app, remove the lost passkey
  from their account page or through [Self-service](/directory/users/self-service/), and add a new one. Recovery codes
  don't stand in for a lost passkey today; they stand in for a lost authenticator app.
- **Which browsers work?** Current versions of the major browsers on Windows, macOS, iOS, Android and Linux, and
  security keys that keep passkeys on the key.
- **Does it work in a web view?** Embedded web views usually can't; open the sign-in in the system browser.

## Audit records

Each passkey sign-in is a `LOGIN` or `LOGIN_FAILED` record on the customer's
[audit trail](/audit-reports/audit-trail/what-is-recorded/), with the passkey step's result. A passkey added or
removed is a change to the customer's factors, and a change to `webauthnSettings` or `authSettings` is in
[Change history](/audit-reports/audit-trail/change-history/).

## Good to know

- **Attestation is limited.** The realm accepts `none` and self-attested `packed` statements only, and doesn't check
  an authenticator's maker against a trust chain.
- **One realm, one domain.** Passkeys made for one brand's realm don't work in another's; see
  [A realm per brand](../../realms/brand-realms/).
- **A lock stops passkeys too.** A customer whose account is locked can't sign in with a passkey until the lock ends;
  see [Protect customer sign-in](../protect-customer-sign-in/).

## Coming next

Passkeys offered as the customer types their name, and a recovery code for a lost passkey, are on
[What's next for authentication](/workforce-identity/authentication/whats-next/).

## Related

- [Sign-in methods](/workforce-identity/authentication/sign-in-methods/): every setting for passkeys.
- [Sign-in chains](/workforce-identity/authentication/sign-in-chains/): the chains every realm starts with.
- [Self-service](/directory/users/self-service/): customers list and remove their own factors.
- [Protect customer sign-in](../protect-customer-sign-in/): lockout and passkeys on a public sign-in.
