48
48
* </p>
49
49
*
50
50
* <pre>
51
- * protected void configure(HttpSecurity http) throws Exception {
52
- * http.apply(new UrlAuthorizationConfigurer<HttpSecurity>()).getRegistry()
51
+ * @Bean
52
+ * public SecurityFilterChain filterChain(HttpSecurity http, ApplicationContext context) throws Exception {
53
+ * http.apply(new UrlAuthorizationConfigurer<HttpSecurity>(context)).getRegistry()
53
54
* .requestMatchers("/users**", "/sessions/**").hasRole("USER")
54
55
* .requestMatchers("/signup").hasRole("ANONYMOUS").anyRequest().hasRole("USER");
55
56
* }
@@ -201,24 +202,22 @@ private StandardInterceptUrlRegistry(ApplicationContext context) {
201
202
setApplicationContext (context );
202
203
}
203
204
205
+ /**
206
+ * @deprecated use {@link #requestMatchers(HttpMethod, String...)} instead
207
+ */
204
208
@ Override
205
- public AuthorizedUrl requestMatchers (String ... patterns ) {
206
- return super .requestMatchers (patterns );
207
- }
208
-
209
- @ Override
210
- public AuthorizedUrl requestMatchers (HttpMethod method , String ... patterns ) {
211
- return super .requestMatchers (method , patterns );
212
- }
213
-
214
- @ Override
215
- public AuthorizedUrl requestMatchers (HttpMethod method ) {
216
- return super .requestMatchers (method );
209
+ @ Deprecated
210
+ public MvcMatchersAuthorizedUrl mvcMatchers (HttpMethod method , String ... mvcPatterns ) {
211
+ return new MvcMatchersAuthorizedUrl (createMvcMatchers (method , mvcPatterns ));
217
212
}
218
213
214
+ /**
215
+ * @deprecated use {@link #requestMatchers(String...)} instead
216
+ */
219
217
@ Override
220
- public AuthorizedUrl requestMatchers (RequestMatcher ... requestMatchers ) {
221
- return super .requestMatchers (requestMatchers );
218
+ @ Deprecated
219
+ public MvcMatchersAuthorizedUrl mvcMatchers (String ... patterns ) {
220
+ return mvcMatchers (null , patterns );
222
221
}
223
222
224
223
@ Override
@@ -243,6 +242,32 @@ public H and() {
243
242
244
243
}
245
244
245
+ /**
246
+ * An {@link AuthorizedUrl} that allows optionally configuring the
247
+ * {@link MvcRequestMatcher#setMethod(HttpMethod)}
248
+ *
249
+ * @author Rob Winch
250
+ */
251
+ public final class MvcMatchersAuthorizedUrl extends AuthorizedUrl {
252
+
253
+ /**
254
+ * Creates a new instance
255
+ * @param requestMatchers the {@link RequestMatcher} instances to map
256
+ */
257
+ private MvcMatchersAuthorizedUrl (List <MvcRequestMatcher > requestMatchers ) {
258
+ super (requestMatchers );
259
+ }
260
+
261
+ @ SuppressWarnings ("unchecked" )
262
+ public AuthorizedUrl servletPath (String servletPath ) {
263
+ for (MvcRequestMatcher matcher : (List <MvcRequestMatcher >) getMatchers ()) {
264
+ matcher .setServletPath (servletPath );
265
+ }
266
+ return this ;
267
+ }
268
+
269
+ }
270
+
246
271
/**
247
272
* Maps the specified {@link RequestMatcher} instances to {@link ConfigAttribute}
248
273
* instances.
0 commit comments