# Passkeys and security keys

A passkey is a second factor that cannot be typed, read out over the phone or sent to the wrong web site. The user's device holds a private key; at login the browser asks the device to sign a challenge of the server, and the user approves with a fingerprint, a face, a PIN, or a touch on a security key. The standard behind it is called WebAuthn.

In CrushMFT a passkey takes the place of the one-time code of [two-factor sign-in](Security-Two-Factor.md): the user gives name and password, and then the passkey.

## What counts as a passkey

| Kind | Examples |
|---|---|
| built into a device | Touch ID and Face ID on Apple devices, Windows Hello, the fingerprint of an Android phone |
| a security key | a YubiKey or a similar key on USB or NFC |
| kept by a password manager | passkeys that follow the user from device to device |

The server accepts keys with the two usual signature methods (ES256 and RS256) and does not ask the device to prove its make.

## Turning it on

| Where | Setting | What it does |
|---|---|---|
| the server: **OTP Settings** in [General Settings](Prefs-General.md#otp-settings) | **Validated Logins?** | the main switch of two-factor sign-in |
| the user, or a template: [Customizations](Users-WebInterface-Customizations.md) | **Two Factor: prompt to register a WebAuthN key (passkey) at login** | after a login, the web interface offers to register a passkey |
| | **Two Factor: remember if the user declines the WebAuthN key prompt** | a user who says no is not asked at every login |

## Registering

1. The user logs in to the web interface as usual.
2. The page offers to register a passkey. The user agrees.
3. The browser shows the device's own window: touch the key, or use fingerprint or face.
4. The server stores the public half with the account.

The offer is good for five minutes; after that the server says "WebAuthN challenge expired, try again."

A user has one second factor: a passkey **or** the secret of an authenticator app. Registering a passkey takes the place of the app.

## Logging in

After name and password, the browser asks for the passkey instead of a code. The user approves on the device, and is in.

A passkey is bound to the **address of the web site** it was registered for. That is its strength: a copy of the login page on another address gets nothing, however convincing it looks. It also means:

- a passkey registered at `files.example.com` does not work when the same server is reached as `transfer.example.org` or by its IP address;
- the address must be HTTPS with a certificate the browser accepts. Browsers do not offer passkeys on plain HTTP, except for `localhost`.

## When a device is lost

An administrator opens the user in the User Manager and presses **Clear Secret** on [the Setup tab](Users-Setup.md#a-second-factor). The user logs in with name and password and registers a new passkey.

Tell users to register a passkey that survives the loss of one device where they can: one kept by a password manager, or a second security key.

## Limits

- Passkeys are for the **web interface**. SFTP, FTP, WebDAV and the others cannot ask for one.
- Registration is not offered through a DMZ server: "WebAuthN registration is not supported in DMZ mode." Users register on a direct connection to the main server.
- It replaces the code, not the password: the login is still name, password, passkey.

## Passkey or app?

| | Passkey | Authenticator app |
|---|---|---|
| can be phished | no | yes: a code typed into a false page is as good as stolen |
| needs | a current browser and device | any phone |
| works on SFTP and FTP | no | yes |
| the user must | touch or look | read and type six digits |

For people who use the browser, offer passkeys. For accounts that also use SFTP with a second factor, the app is the one that works everywhere.
