Scrivio Interview library
DesignIntermediate6 min read · updated 12 November 2026

Design passwordless login with passkeys (WebAuthn) for a consumer Spring Boot web application, including account recovery. What does Spring Security provide and what must you build?

Passkeys are public-key credentials bound to our site's origin: the device keeps the private key, we store only the public key and verify signed challenges, so there is no shared secret to phish or leak. Spring Security 6.4 and later run the registration and authentication ceremonies through http.webAuthn(...), and we supply a durable repository for credentials, support several passkeys per account including synced ones, and build account recovery, the real weak point, with backup passkeys, verified contact details plus step-up checks, and support processes that resist social engineering. We roll out alongside passwords and measure adoption and support tickets.

Why this question is asked

Passwordless login with passkeys is becoming the default for consumer products, and Spring Security now supports it directly. The interesting design work is around it: how credentials are stored, how customers with several devices are handled, and above all how someone who loses every device gets back in. Interviewers ask this question to see whether we know what the framework does and whether we can design the parts it does not. In this answer, we will recap how passkeys work, configure Spring Security's WebAuthn support, choose storage, handle multiple passkeys, design recovery, and plan the rollout.

1A Quick Recap of How Passkeys Work

WebAuthn is the browser standard behind passkeys. In the registration ceremony, our server sends a random challenge and some details about our site (the relying party, identified by our domain). The user's device creates a new key pair for our site, keeps the private key protected by the device's unlock (fingerprint, face or PIN), and returns the public key together with the signed challenge. We store the public key and a credential id.

In the authentication ceremony, we send a new challenge, the device signs it with the private key after the user unlocks it, and we verify the signature with the stored public key. The browser includes the origin, the website address, in what it signs, and refuses to use a passkey on a site other than the one it was created for. That is why passkeys resist phishing: a fake site cannot get a signature that works for us. And we never store a secret: a leaked table of public keys lets nobody log in.

Step throughRegistering and using a passkey
Browser and deviceSpring applicationCredential store
request registration options
challenge, relying party id, user handle
create key pair after fingerprint or PIN
public key, credential id, signed challenge
save public key and credential id
later: request authentication options
new challenge
challenge signed with the private key
look up public key, verify signature, update counter

9 messages in order. Play them, or step through them one at a time.

2What Spring Security Provides

Since Spring Security 6.4, http.webAuthn(...) adds endpoints for both ceremonies: for registration options and registration, and for authentication options and login with a passkey. It validates the responses using the WebAuthn4J library, which we add as a dependency, and it can render simple default pages for registering a passkey and logging in. We configure the relying party name, its id (our registrable domain) and the allowed origins.

Java
@Bean
SecurityFilterChain security(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests(a -> a.anyRequest().authenticated())
.formLogin(Customizer.withDefaults()) // passwords stay during the transition
.webAuthn(w -> w
.rpName("Example Shop")
.rpId("example.com") // passkeys work on example.com and its subdomains
.allowedOrigins("https://www.example.com")); // must match the browser's origin exactly
return http.build();
}

Notice that rpId must be our real domain. Passkeys created for example.com cannot be used on another domain, so choosing it is a one-way decision: if the brand later moves to a new domain, existing passkeys will not work there. That deserves a moment of thought before launch.

3Storing Credentials Durably

By default Spring Security keeps registered credentials and the mapping from users to WebAuthn user handles in memory. That is fine for a demo and useless in production: every restart would erase every customer's passkeys. Spring Security defines two repositories, one for the user entities and one for the credentials, and recent versions include JDBC implementations of both (check your version for the class names and table definitions). We register them as beans backed by our database.

For each credential we store the credential id, the public key, the signature counter, when it was created and last used, whether it is backed up (synced), and a label the customer can recognise, such as 'iPhone' or 'Work laptop'. We never need to protect the public key as a secret, but we do protect the table's integrity, because swapping a public key would let someone log in.

4Several Passkeys per Account and Synced Passkeys

Customers have several devices, so one account must be able to hold several passkeys. Many passkeys today are synced: the platform's password manager copies them across the customer's devices, so a passkey created on a phone also works on their tablet. Others live on one device or on a hardware security key.

Our account page should list all passkeys with their labels and last use, let the customer add one and remove one, and encourage a second passkey on a different platform or a security key. Removing the last passkey from a passkey-only account needs a step-up check, otherwise an attacker with a stolen session could lock the owner out.

5Recovery: the Real Weak Point

When login becomes very hard to attack, attackers turn to recovery, the path for a customer who has lost every device. If recovery is a single emailed link, the account is only as strong as the customer's email. So we design recovery in layers. The first is prevention: encourage a second passkey or a recovery code at enrolment. The second is self-service recovery with verified email and phone combined, plus friction that hurts attackers more than customers: a waiting period of, say, 24 hours before a new passkey becomes usable, notifications to every known channel, and a cancel link for the real owner. The third is human support for the rest, with identity checks that do not rely on information an attacker can find, and with escalation for high-value accounts.

Step throughRecovering an account with no passkey
  1. Customer has a backup passkey or recovery code?
    YesLog in and register a new passkeyNoStart self-service recovery
  2. Verify email and phoneboth, not either
  3. Risk signals high?
    YesSend to identity-checked supportNoStart a 24 hour waiting period
  4. Owner cancels from a notification?
    YesStop recovery, alert securityNoRegister a new passkey
  5. Notify all channels of the changeand revoke old sessions

5 steps in order. Play them, or step through them one at a time.

6Rolling Out Alongside Passwords

We do not remove passwords on day one. We offer a passkey after a successful password login, at sign-up and in account settings, and we let customers who have a passkey remove their password later. We measure the share of active customers with a passkey, the share of logins using one, login success rates by method, recovery requests, and support tickets about login. If recovery tickets climb, we improve enrolment of backup passkeys before pushing adoption further.

7Follow-up questions

What is the signature counter for?

Some authenticators increase a counter with every signature. If we see a counter go backwards, the credential may have been cloned. Synced passkeys often report zero, so we treat the counter as a signal where it is available rather than a hard rule.

Do we need attestation?

Attestation proves which kind of authenticator created the passkey. Consumer applications usually do not request it, because it adds privacy concerns and complexity. Enterprises that must allow only certain hardware keys may need it.

Can passkeys replace MFA?

A passkey combines something the user has, the device, with something they are or know, the unlock, so it is usually treated as satisfying multi-factor requirements on its own. Check the specific regulation if one applies.

8Conclusion

In this answer, we designed passkey login for a consumer Spring Boot application. Passkeys are origin-bound public-key credentials, so there is nothing to phish or leak. Spring Security 6.4 and later handle the WebAuthn ceremonies with http.webAuthn(...), and we supply durable credential repositories, support several and synced passkeys per account, build layered recovery with backup passkeys, verified contacts, waiting periods and careful support, and roll out alongside passwords while measuring adoption and tickets.

What to say in the interviewAbout 90 seconds aloud

Open with

Passkeys are WebAuthn credentials: during registration the device creates a key pair for our domain, keeps the private key behind the device unlock, and gives us the public key.

Then, if they want more

To log in we send a challenge, the device signs it, and we verify with the public key. The browser binds this to our origin, so a phishing site cannot use it, and we store no secret that could leak.

Spring Security 6.4 and later provide http.webAuthn, where I set the relying party name, the relying party id, which is our domain and effectively permanent, and the allowed origins; it handles the registration and authentication ceremonies with WebAuthn4J.

What I must build starts with storage: the defaults are in memory, so I would use durable repositories for user entities and credentials, storing credential id, public key, counter, backup state and a label. Then account management: several passkeys per account, synced and device-bound, listed with last use, add and remove, with step-up before removing the last one.

Recovery is the weak point, so I would encourage a second passkey or recovery code at enrolment, require both verified email and phone for self-service recovery with a waiting period and notifications the owner can cancel, and send risky cases to support with checks that resist social engineering.

I would roll out alongside passwords and measure adoption, login success, recovery requests and tickets.

About this answer

Last updated
12 November 2026
Versions it names
Spring Security 6
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Spring Security reference
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Design passwordless login with passkeys (WebAuthn) for a consumer Spring Boot web...": https://scrivio-interview-library.netlify.app/spring-boot/authentication/619c228c9a/