Find misordered HttpSecurity URL patterns
ProprietarySpring Security checks the URL patterns of HttpSecurity.authorizeRequests() in declaration order and applies the first one that matches, so a pattern declared after a less specific one never takes effect. Marks an antMatchers(String...) pattern that an earlier antMatchers(String...) pattern in the same call chain after authorizeRequests() already matches, including an earlier pattern in the same call. A pattern equal to an earlier one is marked with a request to remove it and give the first occurrence the last rule instead, because Spring Security applies only the last rule, at the position of the first. Patterns are string literals, static final constants declared in the repository's main Java sources, concatenations of those with each other and with int, long, short, byte, char and boolean literals and constants, and a variable or field named on its own that the file declares once and writes once; any other argument, such as a constant of a library, or of a class name two modules share used outside the file that declares it, is ignored on its own. A later pattern containing ?, * or { is only compared for equality and against an earlier pattern's prefix before a trailing **. antMatchers with an HttpMethod, other matcher methods, lambda customizers, registries held in a variable and other registries of the chain such as requestMatchers() are not searched. Nothing is reordered, because that changes which access rule applies to a URL. Test sources are not searched.
io. moderne. java. spring. security. FindMisorderedHttpSecurityMatchersmod run . --recipe= io. moderne. java. spring. security. FindMisorderedHttpSecurityMatchersInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.