Skip to content

Commit 01d1e20

Browse files
Deprecate shouldFilterAllDispatcherTypes
Closes gh-12138
1 parent 76eba9b commit 01d1e20

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

config/src/main/java/org/springframework/security/config/annotation/web/configurers/AuthorizeHttpRequestsConfigurer.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,25 @@ public AuthorizationManagerRequestMatcherRegistry withObjectPostProcessor(
194194
* @return the {@link AuthorizationManagerRequestMatcherRegistry} for further
195195
* customizations
196196
* @since 5.7
197+
* @deprecated Permit access to the {@link jakarta.servlet.DispatcherType}
198+
* instead. <pre>
199+
* &#064;Configuration
200+
* &#064;EnableWebSecurity
201+
* public class SecurityConfig {
202+
*
203+
* &#064;Bean
204+
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
205+
* http
206+
* .authorizeHttpRequests((authorize) -&gt; authorize
207+
* .dispatcherTypeMatchers(DispatcherType.ERROR).permitAll()
208+
* // ...
209+
* );
210+
* return http.build();
211+
* }
212+
* }
213+
* </pre>
197214
*/
215+
@Deprecated(since = "6.1", forRemoval = true)
198216
public AuthorizationManagerRequestMatcherRegistry shouldFilterAllDispatcherTypes(boolean shouldFilter) {
199217
this.shouldFilterAllDispatcherTypes = shouldFilter;
200218
return this;

web/src/main/java/org/springframework/security/web/access/intercept/AuthorizationFilter.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -170,7 +170,25 @@ public AuthorizationManager<HttpServletRequest> getAuthorizationManager() {
170170
* @param shouldFilterAllDispatcherTypes should filter all dispatcher types. Default
171171
* is {@code true}
172172
* @since 5.7
173+
* @deprecated Permit access to the {@link jakarta.servlet.DispatcherType} instead.
174+
* <pre>
175+
* &#064;Configuration
176+
* &#064;EnableWebSecurity
177+
* public class SecurityConfig {
178+
*
179+
* &#064;Bean
180+
* public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
181+
* http
182+
* .authorizeHttpRequests((authorize) -&gt; authorize
183+
* .dispatcherTypeMatchers(DispatcherType.ERROR).permitAll()
184+
* // ...
185+
* );
186+
* return http.build();
187+
* }
188+
* }
189+
* </pre>
173190
*/
191+
@Deprecated(since = "6.1", forRemoval = true)
174192
public void setShouldFilterAllDispatcherTypes(boolean shouldFilterAllDispatcherTypes) {
175193
this.observeOncePerRequest = !shouldFilterAllDispatcherTypes;
176194
this.filterErrorDispatch = shouldFilterAllDispatcherTypes;

0 commit comments

Comments
 (0)