Skip to content

Saml2WebSsoAuthenticationFilter does not follow standard patterns for request matching. #8768

Closed
@fpagliar

Description

@fpagliar

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.

Metadata

Metadata

Assignees

Labels

in: saml2An issue in SAML2 modulestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions