spring-projects / spring-projects/spring-security

Allow Custom PublicKeyCredentialRequestOptionsRepository in WebAuthnConfigurer

Open
#16,874 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage type: enhancement
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 credentialRequestOptionsFilter and webAuthnAuthnFilter from the SecurityFilterChain to set the RequestOptionsRepository.
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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.