You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the web based authorization rules are specified in a specific order and the first rule that matches the request is used. For example with the following rules:
A request to /users/123 would match on /users/** first, so the authenticaticated() rule is applied even though the request also (and more precisely matches /users/{id}.
This is in contrast to Spring MVC and WebFlux routing where the @RequestMapping are not specified in any particular order but the best match is found and used.
For example, in the example below the URL /users/123 will still route to findUserById method:
It would be nice if Spring Security could support a "Best Match" based algorithm. Things to consider:
Performance: Is this going to perform well?
Caching: Spring MVC / WebFlux will likely have to replicate the same logic over the same @RequestMapping
Make it clear that order does not matter
Make it clear that the algorithm being used is Spring's since Spring Security is used on Spring applications but also used on standard servlet applications which may determine "Best Match" differently
Hi, @rwinch I've been investigating how this could be implemented, given that PathPatternRequestMatcher is going to be a default choice, we could probably try to achieve this by sorting mapped RequestMatchers using PathPattern.SPECIFICITY_COMPARATOR, this way we would have more specific matchers placed at the beginning of the mapped authorization rules:
Currently the web based authorization rules are specified in a specific order and the first rule that matches the request is used. For example with the following rules:
A request to
/users/123
would match on/users/**
first, so theauthenticaticated()
rule is applied even though the request also (and more precisely matches/users/{id}
.This is in contrast to Spring MVC and WebFlux routing where the
@RequestMapping
are not specified in any particular order but the best match is found and used.For example, in the example below the URL
/users/123
will still route tofindUserById
method:It would be nice if Spring Security could support a "Best Match" based algorithm. Things to consider:
@RequestMapping
cc @wilkinsona @rstoyanchev
The text was updated successfully, but these errors were encountered: