Skip to main content

Passkeys

Let people sign in with a fingerprint, a face or a security key, and invite the ones who have a password to add a passkey.

RecipeReadyView source
Works with
JavaScript / TypeScriptReact
Standards
WebAuthn

What it shows​

  1. The setup script turns on passkey sign-in for the organization.
  2. A person signs in with a password, through the hosted page. The app invites them to add a passkey, with a link to the account page of LumoAuth.
  3. On that page the person creates the passkey. The browser asks for a fingerprint, a face, a screen lock or a security key.
  4. At the next sign-in, the hosted page offers Sign in with a passkey. One touch signs the person in, with no password and no second step.
  5. An administrator sees who has a passkey, with the lumo CLI.

The app has no WebAuthn code. The hosted pages create and check the passkey, on the domain of LumoAuth.

Before you start​

  • A public application with a redirect URI, and the origin of your app in its Allowed origins. The Starter App of a new organization accepts http://localhost:5173. Sign in through the hosted page has the steps for an application of your own.
  • A user with a password, and a device that can hold a passkey.

The setup script turns passkeys on through the Admin API. In the portal, open Sign-in settings, turn on Passkeys & biometrics under Identity methods, and click Save changes.

VariableValue
LUMOAUTH_URLThe address of LumoAuth: https://app.lumoauth.dev, or https://eu.app.lumoauth.dev for the EU region.
LUMOAUTH_ORG_IDYour organization, for example acme-corp.
LUMOAUTH_API_KEYFor the setup script only: an API key with the scopes admin:settings:read and admin:settings:write. The app has no API key.
LUMOAUTH_CLIENT_IDThe client ID of the application. A browser app has no client secret.

The setup script turns on passkey sign-in for the organization and prints the two settings that matter here. A second run changes nothing.

node sign-in/passkeys/setup.mjs
setup.mjs
// Turns on passkey sign-in for the organization, through the Admin API.
//
// node sign-in/passkeys/setup.mjs
//
// The API key needs admin:settings:read and admin:settings:write.
import { call } from '../../_lib/admin.mjs';

// The sign-in settings take a partial update: the other settings keep their values.
await call('PATCH', '/admin/settings/authentication', { passkey_enabled: true });

const settings = (await call('GET', '/admin/settings/authentication')).data;
const policy = settings.mfa_policy;
const yesNo = (flag) => (flag ? 'yes' : 'no');
console.log(`passkeys: ${settings.passkey_enabled ? 'on' : 'off'}, FIDO-certified authenticators only: ${yesNo(settings.passkeys?.require_certified_authenticator)}`);
// The MFA policy decides whether a passkey sign-in also counts as the second factor.
console.log(`a passkey counts as both factors: ${yesNo(policy.allowed_factors.includes('passkey') && policy.passwordless_passkey)}`);

Code​

Run each command from the recipes folder of the examples repository. Set the folder up once for your language. Every version below was run against a LumoAuth organization. The recipe is a small project with its own package.json. A browser with a virtual authenticator signed in with a password, added a passkey on the account page, and then signed in with the passkey alone.

sign-in/passkeys/js/src/App.jsx
// The app: sign in through the hosted page, and a link that adds a passkey.
import { SignedIn, SignedOut, SignOutButton, useAuth, useUser } from '@lumoauth/react';

export default function App() {
const user = useUser();
const { signInWithRedirect, config } = useAuth();
return (
<main>
<h1>Passkeys</h1>
<SignedOut>
{/* The hosted page runs WebAuthn. The app has no passkey code. */}
<button type="button" onClick={() => signInWithRedirect()}>Sign in</button>
</SignedOut>
<SignedIn>
<p>{user ? `Signed in as ${user.email}` : 'Loading the profile…'}</p>
{/* A passkey belongs to the domain where it is created. The account page
of LumoAuth creates it on the domain of the sign-in page. */}
<p>
Sign in faster next time:{' '}
<a href={`${config.domain}/account/security`} target="_blank" rel="noreferrer">add a passkey</a>
</p>
<SignOutButton />
</SignedIn>
</main>
);
}
sign-in/passkeys/js/src/main.jsx
// Sign in with a passkey on the hosted page, and add one from the app.
//
// cd sign-in/passkeys/js && npm install && npm run dev
//
// Then open http://localhost:5173.
import { createRoot } from 'react-dom/client';
import { AuthCallback, LumoAuthProvider } from '@lumoauth/react';
import App from './App.jsx';

const callbackPath = '/auth/callback';

createRoot(document.getElementById('root')).render(
<LumoAuthProvider
domain={import.meta.env.LUMOAUTH_URL}
orgId={import.meta.env.LUMOAUTH_ORG_ID}
clientId={import.meta.env.LUMOAUTH_CLIENT_ID}
redirectUri={window.location.origin + callbackPath}
>
{window.location.pathname === callbackPath ? <AuthCallback afterSignInUrl="/" /> : <App />}
</LumoAuthProvider>,
);
sign-in/passkeys/js/vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

// The browser gets these three values and nothing else from the environment.
// None of them is a secret: a browser app has no client secret and no API key.
export default defineConfig({
plugins: [react()],
define: {
'import.meta.env.LUMOAUTH_URL': JSON.stringify(process.env.LUMOAUTH_URL ?? 'https://app.lumoauth.dev'),
'import.meta.env.LUMOAUTH_ORG_ID': JSON.stringify(process.env.LUMOAUTH_ORG_ID ?? ''),
'import.meta.env.LUMOAUTH_CLIENT_ID': JSON.stringify(process.env.LUMOAUTH_CLIENT_ID ?? ''),
},
});
cd sign-in/passkeys/js && npm install && npm run dev

Open http://localhost:5173.

Check the result​

The setup script prints the first two lines. Open http://localhost:5173, click Sign in and sign in with the password. The app shows the last two lines.

Output
passkeys: on, FIDO-certified authenticators only: no
a passkey counts as both factors: yes

Signed in as maya.chen@example.com
Sign in faster next time: add a passkey
  1. Click add a passkey. The Sign-in & security page of your account opens in a new tab.
  2. Click Add a sign-in method, choose Passkey, and click Create a passkey. Confirm on your device.
  3. LumoAuth shows your recovery codes once. The passkey is then listed under Two-step verification, as Passkey · Strongest.
  4. Sign out in the app, open http://localhost:5173 again and click Sign in. Click Sign in with a passkey, with or without the email address, and confirm on your device. The app shows the signed-in lines again.

An administrator can list the passkeys of a person with the lumo CLI:

lumo users authenticators list maya.chen@example.com

lumo mfa coverage counts the people who have a passkey. Under Audit logs in the portal, the new passkey appears as passkey.registered. The details of the next user.login event show the method passkey.

Limits​

  • A passkey belongs to the domain on which it was created. A passkey created on app.lumoauth.dev does not sign in on your custom domain, and the other way round.
  • A passkey signs in only to the organization in which it was created.
  • LumoAuth always asks for user verification. A security key without a PIN asks the person to set one.
  • With Require FIDO-certified authenticators on, most passkeys of phones and password managers are refused. See FIDO Metadata Service.
  • A person who already has a second factor confirms it before they add a passkey.
  • useUser() does not say how the person signed in. The tokens do: a passkey sign-in carries amr ["hwk", "user", "mfa"]. MFA and step-up for one action checks it in an API.