Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes gh-13562
This allows an application to directly configure how
requestMatchers(String)
works, thereby delegating the responsibility of disambiguating request patterns.For example, in an application where Spring MVC is on
/servlet/path
and there are other servlets, there might exist two endpoints, one at/example
and one at/servlet/path/example
. Because Spring MVC patterns exclude the/servlet/path
prefix, a declaration like this one:becomes ambiguous.
With this PR, an application can alleviate this in one of three ways:
First, they can state that all their
String
-based request matcher endpoints are MVC endpoints, a common scenario:Spring Security will consult this bean instead of using the default behavior in
requestMatchers(String)
,securityMatchers(String)
orignoringRequestMatchers(String)
methods and interpret each one as a Spring MVC request.Second, they can construct a
MvcRequestMatcherFactory
which will check the destination of the request and use MVC matching rules if the request is targetingDispatcherServlet
or Ant matching rules otherwise:Or third, they can introduce logic of their own like so:
Though in the third case, it will likely be less work to do the first or second option and then do: