Skip to main content

Passkeys and WebAuthn: passwordless login on your site

Security · · 5 min read

What a passkey is

A passkey is a key pair instead of a password. The private key is created on the visitor's device and stays there (in a phone, a laptop, a hardware token), while the site keeps only the public one. At login the site sends a random string, the device signs it with the private key, and the site verifies the signature with the public key. The secret that could be stolen from the server or coaxed out of a person simply does not exist in this scheme.

The technical basis is the browser interface WebAuthn. It helps to know the exact status here: the version in force is WebAuthn Level 2, while Level 3 is published on the W3C site as a Candidate Recommendation Snapshot of 26 May 2026 — that is, not yet a recommendation. You can build on it today, but the claim that passkeys are fully standardised would be inaccurate.

How this differs from a 2FA code

A code from an app or an email is a second factor on top of a password, and it can be handed to a fraudster. A passkey removes the very object of the theft.

PropertyPassword and codePasskey
What the server storesA password hash and a code secretOnly the public key
A leak of the site databaseHashes can be crackedThe public key is useless
PhishingThe code is typed on a fake pageThe signature is bound to the site address
GuessingPossible, needs limitsThere is nothing to guess

The phishing row is the important one. The device signs the data together with the address of the site that asked for it. On a page with a lookalike domain the signature will not fit, and the person does not need to spot the difference in the address: the browser does it for them.

Two kinds of keys, and where they live

  • Synced passkeys. Kept in the platform keychain and available on every device of one account. Convenient, and they survive a lost phone, but the trust moves to the keychain.
  • Device-bound keys. They never leave the carrier — a hardware token or one particular machine. Stricter, but losing the carrier means losing access.

For a server control panel it is reasonable to allow both kinds, and to require a device-bound key for anything involving money.

What the site side needs

Do not write the cryptography yourself: signature verification, format parsing and the rules for storing counters are exactly where an invisible mistake is easy to make. Take a ready library for your language and store in the database precisely what it asks for: the credential identifier, the public key, the counter and the link to the user.

-- the minimum set of fields
CREATE TABLE user_passkeys (
  id            BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  user_id       BIGINT UNSIGNED NOT NULL,
  credential_id VARBINARY(255) NOT NULL,
  public_key    BLOB NOT NULL,
  sign_count    BIGINT UNSIGNED NOT NULL DEFAULT 0,
  created_at    DATETIME NOT NULL,
  UNIQUE KEY (credential_id),
  KEY (user_id)
);

Two requirements cannot be worked around: the site runs over HTTPS, and the value the signature is checked against comes from the server configuration, not from the request. Take the address from the data the browser sent and the check loses its meaning — the binding to the address is exactly what gives protection from phishing.

Registration and login in the browser

On the page side these are two calls. The random string must come from the server and be single-use:

// registering a new key
const cred = await navigator.credentials.create({ publicKey: optionsFromServer });

// logging in
const assertion = await navigator.credentials.get({ publicKey: challengeFromServer });

The response goes to the server, and the library verifies the signature and the address. If the check fails, the login must not fall back to the password silently: that turns the protection into an optional extra.

A lost device: the real question of adoption

The scheme breaks not on cryptography but on account recovery. If the fallback path is an email, then the strength of the whole system equals the strength of that mailbox, and phishing returns through it. A workable order:

  1. Require at least two keys at registration: the phone and a second carrier.
  2. Issue single-use recovery codes once, and show them only at creation time.
  3. Show the person a list of their keys with the date of last use, and let them remove keys one by one.
  4. Make a reset through support depend on verifying identity, not on the request arriving.

What a passkey does not do

It protects the login, not the session: a cookie stolen after login is still a stolen cookie. It does not remove the need for rate limiting and login logging. And it settles nothing on the server side where you yourself arrive over SSH — that has its own instrument, a hardware key for SSH, covered in SSH key on a FIDO2 token. If a passkey does not fit yet, the ordinary two-factor scheme remains: two-factor authentication for SSH and web panels.

Was this article helpful?
Back to Knowledge Base Ask Support