spring-projects / spring-projects/spring-security

WebAuthnAuthenticationProvider does not pass UserDetails to WebAuthnAuthentication

Open Beginner friendly
#18,105 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage type: bug
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.

https://github.com/spring-projects/spring-security/blob/7.0.0-RC1/webauthn/src/main/java/org/springframework/security/web/webauthn/authentication/WebAuthnAuthenticationProvider.java#L77

To Reproduce

  • authenticate via webauthn
  • check SecurityContext.getAuthentication().getPrincipal() - it is an ImmutablePublicKeyCredentialUserEntity

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.