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: docs/modules/ROOT/pages/servlet/authorization/authorize-http-requests.adoc
+66Lines changed: 66 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -52,6 +52,7 @@ In many cases, your authorization rules will be more sophisticated than that, so
52
52
* I have an app that uses `authorizeRequests` and I want to <<migrate-authorize-requests,migrate it to `authorizeHttpRequests`>>
53
53
* I want to <<request-authorization-architecture,understand how the `AuthorizationFilter` components work>>
54
54
* I want to <<match-requests, match requests>> based on a pattern; specifically <<match-by-regex,regex>>
55
+
* I want to match request, and I map Spring MVC to <<mvc-not-default-servlet, something other than the default servlet>>
55
56
* I want to <<authorize-requests, authorize requests>>
56
57
* I want to <<match-by-custom, match a request programmatically>>
57
58
* I want to <<authorize-requests, authorize a request programmatically>>
@@ -570,6 +571,71 @@ http {
570
571
----
571
572
====
572
573
574
+
[[match-by-mvc]]
575
+
=== Using an MvcRequestMatcher
576
+
577
+
Generally speaking, you can use `requestMatchers(String)` as demonstrated above.
578
+
579
+
However, if you map Spring MVC to a different servlet path, then you need to account for that in your security configuration.
580
+
581
+
For example, if Spring MVC is mapped to `/spring-mvc` instead of `/` (the default), then you may have an endpoint like `/spring-mvc/my/controller` that you want to authorize.
582
+
583
+
You need to use `MvcRequestMatcher` to split the servlet path and the controller path in your configuration like so:
0 commit comments