Passkeys in the login form
Passkeys are WebAuthn credentials that sign people in without a password: synced ones in a password manager, and device-bound ones such as a security key. Keycloak added them to its default login forms in 26.3 as a preview and made them a supported feature in 26.4.
- In your realm, open Authentication, then Policies, then Webauthn Passwordless Policy.
- Turn Enable Passkeys on and save.
The username field then offers saved passkeys through the browser’s autofill (conditional UI), and a Sign in with Passkey button opens the browser’s own dialog (modal UI) for passkeys on other devices or security keys. The Passkey Mediation setting decides whether the dialog opens on its own when the page loads. People register a passkey from the account console, or your app asks them to with the WebAuthn Register Passwordless action.
With passkeys on, the default browser flow skips the second factor when someone signed in with a passkey, since a passkey already proves both. To ask for a second factor anyway, disable the Condition - credential step in that flow.
One-time codes from an authenticator app
Time-based one-time codes (TOTP) work with FreeOTP, Google Authenticator and other authenticator apps. Counter-based codes (HOTP) are available too. The realm’s OTP Policy sets the algorithm, the number of digits and the period.
The default browser flow has a Browser - Conditional 2FA sub-flow that asks for a code only when the user has set one up. To require codes from everyone, make Configure OTP a default required action, so each person sets up an app at their next sign-in. The authenticator URI tool and the TOTP generator help you test.
Security keys and recovery codes
Inside the same conditional sub-flow sit two more methods, disabled by default:
- WebAuthn Authenticator, for a security key or a platform authenticator as the second factor. Set it to Alternative to offer it next to codes.
- Recovery Authentication Code Form, supported since Keycloak 26.3. People print a set of single-use codes, and a code stands in for the phone they lost. Since 26.4 you can ask people to set up recovery codes right after they set up an authenticator app.
When a user has several methods, the login shows the one with the highest priority and a Try Another Way link for the rest. Brute-force detection protects passwords, one-time codes and recovery codes.
Stronger sign-in only where it matters
Step-up authentication asks for a second factor only for sensitive actions. In the realm, map ACR values to numeric levels of authentication, and build the browser flow with Conditional - Level Of Authentication steps: level 1 for a password, level 2 for a password and a code. Your app requests a level with acr_values or the claims parameter, and the token’s acr claim says what was done.
This is how an app lets people browse after a plain sign-in and asks for a code before changing an email or a payment method.
What is not built in
- Codes by SMS: Keycloak has no built-in SMS sign-in. It needs an extension, and tenant images do not support extensions yet.
- Push approvals in a vendor’s mobile app: these come from products with their own apps, not from Keycloak.
- A custom look for the passkey and code pages: they use Keycloak’s built-in theme, since custom themes are not supported in tenant images yet.