Description
Describe the bug
The common pattern for filters is to provide the ability to set a custom RequestMatcher for them to execute.
This is the case for Saml2WebSsoAuthenticationRequestFilter
and AbstractAuthenticationProcessingFilter
.
Now Saml2WebSsoAuthenticationFilter
extends AbstractAuthenticationProcessingFilter
but creates its own custom private RequestMatcher from a String.
This is unnecessarily restrictive for the developer, and goes against the common pattern.
Not only that, but since AbstractAuthenticationProcessingFilter
provides setRequiresAuthenticationRequestMatcher()
A developer can totally unknowingly set a different matcher on the parent.
Example
The following line compiles and looks valid to a developer using SpringSecurity, but creates an instance of the filter that is completely inconsistent.
final Saml2WebSsoAuthenticationFilter myFilter = new Saml2WebSsoAuthenticationFilter(getRelyingPartyRegistrationRepository());
myFilter.setRequiresAuthenticationRequestMatcher(new AntPathRequestMatcher("/someother"));
The method requiresAuthentication
will match based on the parent matcher, but attemptAuthentication
will match based on the local one.