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
Copy file name to clipboardExpand all lines: config/src/main/java/org/springframework/security/config/annotation/web/AbstractRequestMatcherRegistry.java
-13Lines changed: 0 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -179,19 +179,6 @@ public C requestMatchers(RequestMatcher... requestMatchers) {
Copy file name to clipboardExpand all lines: config/src/test/java/org/springframework/security/config/annotation/web/configurers/AuthorizeHttpRequestsConfigurerTests.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1343,11 +1343,11 @@ static class MvcRequestMatcherBuilderConfig {
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/migration-7/web.adoc
+36-5Lines changed: 36 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -103,11 +103,42 @@ Xml::
103
103
----
104
104
======
105
105
106
-
== Use Absolute Authorization URIs
106
+
== Include the Servlet Path Prefix in Authorization Rules
107
107
108
-
The Java DSL now requires that all URIs be absolute (less any context root).
108
+
As of Spring Security 7, `AntPathRequestMatcher` and `MvcRequestMatcher` are no longer supported and the Java DSL requires that all URIs be absolute (less any context root).
109
109
110
-
This means any endpoints that are not part of the default servlet, xref:servlet/authorization/authorize-http-requests.adoc#match-by-mvc[the servlet path needs to be specified].
111
-
For URIs that match an extension, like `.jsp`, use `regexMatcher("\\.jsp$")`.
110
+
For many applications this will make no difference since most commonly all URIs listed are matched by the default servlet.
112
111
113
-
Alternatively, you can change each of your `String` URI authorization rules to xref:servlet/authorization/authorize-http-requests.adoc#security-matchers[use a `RequestMatcher`].
112
+
However, if you have other servlets with servlet path prefixes, xref:servlet/authorization/authorize-http-requests.adoc[then these paths need to be supplied separately].
113
+
114
+
For example, if I have a Spring MVC controller with `@RequestMapping("/orders")` and my MVC application is deployed to `/mvc` (instead of the default servlet), then the URI for this endpoint is `/mvc/orders`.
115
+
Historically, the Java DSL hasn't had a simple way to specify the servlet path prefix and Spring Security attempted to infer it.
116
+
117
+
Over time, we learned that these inference would surprise developers.
118
+
Instead of taking this responsibility away from developers, now it is simpler to specify the servlet path prefix like so:
There are several other components that create request matchers for you like `PathRequest#toStaticResources#atCommonLocations`
660
+
There are several other components that create request matchers for you like {spring-boot-api-url}org/springframework/boot/autoconfigure/security/servlet/PathRequest.html[`PathRequest#toStaticResources#atCommonLocations`]
Copy file name to clipboardExpand all lines: web/src/test/java/org/springframework/security/web/servlet/util/matcher/PathPatternRequestMatcherTests.java
0 commit comments