spring-projects / spring-projects/spring-security
Explore changing X.509 MFA behavior when unauthenticated
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
NOTE: This is a ticket that the Spring Security team is reviewing for inclusion. It's not considered ready to implement yet. When it is, this disclaimer will be removed and the title may change
During the work for #2603, it was discussed that when using .x509 and .formLogin together:
http
.x509(Customizer.withDefaults())
.formLogin(Customizer.withDefaults())
// ...
Then when the user is unauthenticated, it redirects to /login.
This makes sense since, without MFA, this HttpSecurity statement reads: either X.509 or Form Login is a permissible way of authenticating.
However, if MFA is activated, then it may not make sense to redirect to /login. This is because X.509 certificates are a pre-authentication mechanism. So, if we are redirecting to /login, this means that we already know that there was no X.509 certificate and the second factor (X.509) will ultimately fail.
This is addressed when the user is already logged in by way of the MissingAuthorityDelegatingAccessDeniedHandler, which can prioritize X.509's authentication entry point (Http403AuthenticationEntryPoint) based on the order in which the entry points are declared.
However, before authentication, the filter chain doesn't have access to any such information.
It would be nice if, when MFA is activated and X.509 is listed as one of the required factors, that unauthenticated users are also forbidden if the X.509 filter doesn't find a certificate.
We may be able to have GlobalMultifactorAuthenticationConfiguration publish a bean that X509Configurer or ExceptionHandlingConfigurer is aware of. This would allow either the X509AuthenticationFilter or the ExceptionHandlingConfigurer to modify their configuration.
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
Review #2603 and the interaction among GlobalMultifactorAuthenticationConfiguration, X509Configurer, ExceptionHandlingConfigurer, and X509AuthenticationFilter. Compare this with MissingAuthorityDelegatingAccessDeniedHandler to establish the desired unauthenticated MFA behavior. Done means the team has agreed on the design and the relevant configuration path is updated accordingly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- authentication, security
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100