spring-projects / spring-projects/spring-security
WebAuthnAuthenticationProvider does not pass UserDetails to WebAuthnAuthentication
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
Describe the bug
WebAuthnAuthenticationProvider creates a WebAuthnAuthentication with a principal of type PublicKeyCredentialUserEntity instead of UserDetails.
To Reproduce
- authenticate via webauthn
- check
SecurityContext.getAuthentication().getPrincipal()- it is anImmutablePublicKeyCredentialUserEntity
Expected behavior
The retrieved UserDetails instance should be used as principal of the created WebAuthnAuthentication (WebAuthnAuthenticationProvider javadoc looks correct).
Sample
sample app will be referenced asap:
- run
- http://localhost:8080/login - user / password
- http://localhost:8080/webauthn/register - register a passkey
- http://localhost:8080/logout
- http://localhost:8080/login - use passkey
- check debug console log
2025-10-27T15:19:44.309+01:00 DEBUG 40608 --- [demo] [nio-8080-exec-2] o.s.s.w.w.a.WebAuthnAuthenticationFilter : Set SecurityContextHolder to WebAuthnAuthentication [Principal=org.springframework.security.web.webauthn.api.ImmutablePublicKeyCredentialUserEntity@205490ff, Credentials=[PROTECTED], Authenticated=true, Details=null, Granted Authorities=[ROLE_USER, FactorGrantedAuthority [authority=FACTOR_WEBAUTHN, issuedAt=2025-10-27T14:19:42.009552700Z]]]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at webauthn/src/main/java/org/springframework/security/web/webauthn/authentication/WebAuthnAuthenticationProvider.java around line 77 and trace the authentication flow described in the issue. Reproduce the WebAuthn login, inspect SecurityContext.getAuthentication().getPrincipal(), and consider the issue complete when it is the retrieved UserDetails instance rather than an ImmutablePublicKeyCredentialUserEntity.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- authentication, security
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100