spring-projects / spring-projects/spring-security
Allow Custom PublicKeyCredentialRequestOptionsRepository in WebAuthnConfigurer
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
Expected Behavior
As a developer, I would like to provide my own implementations for PublicKeyCredentialRequestOptionsRepository.
Current Behavior
Currently, there is no option to change the credentialRequestOptionsFilter and webAuthnAuthnFilter requestOptionsRepository. While this provides a default implementation, it lacks the flexibility to easily inject a custom PublicKeyCredentialRequestOptionsRepository for specific application needs.
Context
I'm trying to integrate WebAuthn into a Spring Security application and require a custom PublicKeyCredentialRequestOptionsRepository. The current configuration forces me to either accept the defaults or do workarounds.
https://github.com/spring-projects/spring-security/issues/16369
Workarounds:
- Manually retrieve the
credentialRequestOptionsFilterandwebAuthnAuthnFilterfrom theSecurityFilterChainto set theRequestOptionsRepository.
securityFilterChain.getFilters().stream()
.filter(WebAuthnAuthenticationFilter.class::isInstance)
.map(WebAuthnAuthenticationFilter.class::cast)
.findFirst()
.ifPresent(filter -> {
filter.setAuthenticationSuccessHandler(webAuthnAuthenticationSuccessHandler);
filter.setRequestOptionsRepository(databasePublicKeyCredentialRequestOptionsRepository);
});
securityFilterChain.getFilters().stream()
.filter(PublicKeyCredentialRequestOptionsFilter.class::isInstance)
.map(PublicKeyCredentialRequestOptionsFilter.class::cast)
.findFirst()
.ifPresent(filter -> {
filter.setRequestOptionsRepository(databasePublicKeyCredentialRequestOptionsRepository);
});
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 WebAuthnConfigurer and trace how credentialRequestOptionsFilter and WebAuthnAuthenticationFilter receive their requestOptionsRepository values. The change is complete when applications can provide a custom PublicKeyCredentialRequestOptionsRepository through the configuration instead of retrieving filters manually; the payload names no test file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- authentication, security
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100