This article describes the process of configuring Keycloak for passwordless login using passkeys, webauthn, and OTP (One-Time Password). Some configurations in this article may require Keycloak 23 or higher to function properly.

Configuring the Authentication Section

In Keycloak’s Authentication - Flow menu, duplicate the browser flow. We’ll name the copy browser with optional webauth and otp.

Duplicate Browser Flow
Duplicate Browser Flow

In the new flow, delete browser password form and all steps/flows below it:

delete old form
delete old form

First, add a step, select username Form, and set it to required:

Below, add a subflow and name it passwordless or password or otp:

add-subflow
add-subflow

Within the passwordless or password or otp subflow, add three steps: Password Form, WebAuthn Passwordless Authenticator, and OTP Form. These three steps correspond to password authentication, passkey/webauthn authentication, and OTP code (six-digit two-factor authentication) respectively. Set these three steps as alternative, meaning users can choose any one of the three methods to log in.

The final result after adding all steps should look like this:

Authentication Flow
Authentication Flow

Bind Flow

Click on Action in the upper right corner of the flow and bind the newly created flow to the browser flow (browser login):

bind-flow
bind-flow

Enable webauthn in required actions

In Authentication-Required actions, enable Webauthn Register Passwordless:

enable-webauth
enable-webauth

Using passkey to log in

Add a passkey

In the Signing in section of the account panel, you’ll see a new Passwordless option. Click Set up Security key to set up your Passkey.

set-security-key
set-security-key

Test Passkey login

After entering your account information, you will see the login method interface:

sign-in-screen
sign-in-screen

Click Security Key to log in using Passkey.

choose-method
choose-method

Misc

If users are required to set up a passkey/OTP, the Set as default action option in Required Actions needs to be checked.

References