Skip to content

Commit 217302b

Browse files
committed
Migrate to AuthorizationFilter in Spring Security auto-config
This commit updates Servlet based Spring Security auto-configuration to use AuthorizationFilter, which is intended to superseed FilterSecurityInterceptor.
1 parent d7537bf commit 217302b

File tree

35 files changed

+48
-48
lines changed

35 files changed

+48
-48
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/servlet/ManagementWebSecurityAutoConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class ManagementWebSecurityAutoConfiguration {
5858
@Bean
5959
@Order(SecurityProperties.BASIC_AUTH_ORDER)
6060
SecurityFilterChain managementSecurityFilterChain(HttpSecurity http) throws Exception {
61-
http.authorizeRequests((requests) -> {
61+
http.authorizeHttpRequests((requests) -> {
6262
requests.requestMatchers(EndpointRequest.to(HealthEndpoint.class)).permitAll();
6363
requests.anyRequest().authenticated();
6464
});

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/AbstractEndpointRequestIntegrationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ org.springframework.security.config.annotation.web.configuration.WebSecurityConf
183183

184184
@Override
185185
protected void configure(HttpSecurity http) throws Exception {
186-
http.authorizeRequests((requests) -> {
186+
http.authorizeHttpRequests((requests) -> {
187187
requests.requestMatchers(EndpointRequest.toLinks()).permitAll();
188188
requests.requestMatchers(EndpointRequest.to(TestEndpoint1.class)).permitAll();
189189
requests.requestMatchers(EndpointRequest.toAnyEndpoint()).authenticated();

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/ManagementWebSecurityAutoConfigurationTests.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ static class CustomSecurityConfiguration
179179

180180
@Override
181181
protected void configure(HttpSecurity http) throws Exception {
182-
http.authorizeRequests((requests) -> {
182+
http.authorizeHttpRequests((requests) -> {
183183
requests.antMatchers("/foo").permitAll();
184184
requests.anyRequest().authenticated();
185185
});
@@ -194,7 +194,7 @@ static class TestSecurityFilterChainConfig {
194194

195195
@Bean
196196
SecurityFilterChain testSecurityFilterChain(HttpSecurity http) throws Exception {
197-
return http.antMatcher("/**").authorizeRequests((authorize) -> authorize.anyRequest().authenticated())
197+
return http.antMatcher("/**").authorizeHttpRequests((authorize) -> authorize.anyRequest().authenticated())
198198
.build();
199199
}
200200

@@ -206,8 +206,8 @@ static class TestRemoteDevToolsSecurityFilterChainConfig extends TestSecurityFil
206206
@Bean
207207
@Order(SecurityProperties.BASIC_AUTH_ORDER - 1)
208208
SecurityFilterChain testRemoteDevToolsSecurityFilterChain(HttpSecurity http) throws Exception {
209-
return http.requestMatcher(new AntPathRequestMatcher("/**")).authorizeRequests().anyRequest().anonymous()
210-
.and().csrf().disable().build();
209+
return http.requestMatcher(new AntPathRequestMatcher("/**")).authorizeHttpRequests().anyRequest()
210+
.anonymous().and().csrf().disable().build();
211211
}
212212

213213
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/servlet/OAuth2WebSecurityConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static class OAuth2SecurityFilterChainConfiguration {
5858

5959
@Bean
6060
SecurityFilterChain oauth2SecurityFilterChain(HttpSecurity http) throws Exception {
61-
http.authorizeRequests((requests) -> requests.anyRequest().authenticated());
61+
http.authorizeHttpRequests((requests) -> requests.anyRequest().authenticated());
6262
http.oauth2Login(Customizer.withDefaults());
6363
http.oauth2Client();
6464
return http.build();

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerJwtConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static class OAuth2SecurityFilterChainConfiguration {
153153
@Bean
154154
@ConditionalOnBean(JwtDecoder.class)
155155
SecurityFilterChain jwtSecurityFilterChain(HttpSecurity http) throws Exception {
156-
http.authorizeRequests((requests) -> requests.anyRequest().authenticated());
156+
http.authorizeHttpRequests((requests) -> requests.anyRequest().authenticated());
157157
http.oauth2ResourceServer(OAuth2ResourceServerConfigurer::jwt);
158158
return http.build();
159159
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerOpaqueTokenConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static class OAuth2SecurityFilterChainConfiguration {
6060
@Bean
6161
@ConditionalOnBean(OpaqueTokenIntrospector.class)
6262
SecurityFilterChain opaqueTokenSecurityFilterChain(HttpSecurity http) throws Exception {
63-
http.authorizeRequests((requests) -> requests.anyRequest().authenticated());
63+
http.authorizeHttpRequests((requests) -> requests.anyRequest().authenticated());
6464
http.oauth2ResourceServer(OAuth2ResourceServerConfigurer::opaqueToken);
6565
return http.build();
6666
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/saml2/Saml2LoginConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Saml2LoginConfiguration {
3737

3838
@Bean
3939
SecurityFilterChain samlSecurityFilterChain(HttpSecurity http) throws Exception {
40-
http.authorizeRequests((requests) -> requests.anyRequest().authenticated()).saml2Login();
40+
http.authorizeHttpRequests((requests) -> requests.anyRequest().authenticated()).saml2Login();
4141
http.saml2Logout();
4242
return http.build();
4343
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/SpringBootWebSecurityConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static class SecurityFilterChainConfiguration {
5454
@Bean
5555
@Order(SecurityProperties.BASIC_AUTH_ORDER)
5656
SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws Exception {
57-
http.authorizeRequests().anyRequest().authenticated();
57+
http.authorizeHttpRequests().anyRequest().authenticated();
5858
http.formLogin();
5959
http.httpBasic();
6060
return http.build();

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/client/servlet/OAuth2WebSecurityConfigurationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ static class TestSecurityFilterChainConfig {
241241

242242
@Bean
243243
SecurityFilterChain testSecurityFilterChain(HttpSecurity http) throws Exception {
244-
return http.antMatcher("/**").authorizeRequests((authorize) -> authorize.anyRequest().authenticated())
244+
return http.antMatcher("/**").authorizeHttpRequests((authorize) -> authorize.anyRequest().authenticated())
245245
.build();
246246

247247
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerAutoConfigurationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ static class TestSecurityFilterChainConfig {
692692

693693
@Bean
694694
SecurityFilterChain testSecurityFilterChain(HttpSecurity http) throws Exception {
695-
return http.antMatcher("/**").authorizeRequests((authorize) -> authorize.anyRequest().authenticated())
695+
return http.antMatcher("/**").authorizeHttpRequests((authorize) -> authorize.anyRequest().authenticated())
696696
.build();
697697
}
698698

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/saml2/Saml2RelyingPartyAutoConfigurationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ static class TestSecurityFilterChainConfig {
321321

322322
@Bean
323323
SecurityFilterChain testSecurityFilterChain(HttpSecurity http) throws Exception {
324-
return http.antMatcher("/**").authorizeRequests((authorize) -> authorize.anyRequest().authenticated())
324+
return http.antMatcher("/**").authorizeHttpRequests((authorize) -> authorize.anyRequest().authenticated())
325325
.build();
326326
}
327327

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/servlet/SecurityAutoConfigurationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ static class TestSecurityFilterChainConfig {
298298

299299
@Bean
300300
SecurityFilterChain testSecurityFilterChain(HttpSecurity http) throws Exception {
301-
return http.antMatcher("/**").authorizeRequests((authorize) -> authorize.anyRequest().authenticated())
301+
return http.antMatcher("/**").authorizeHttpRequests((authorize) -> authorize.anyRequest().authenticated())
302302
.build();
303303

304304
}

spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/RemoteDevtoolsSecurityConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class RemoteDevtoolsSecurityConfiguration {
5050
@ConditionalOnMissingBean(org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter.class)
5151
@SuppressWarnings("deprecation")
5252
SecurityFilterChain devtoolsSecurityFilterChain(HttpSecurity http) throws Exception {
53-
http.requestMatcher(new AntPathRequestMatcher(this.url)).authorizeRequests().anyRequest().anonymous().and()
53+
http.requestMatcher(new AntPathRequestMatcher(this.url)).authorizeHttpRequests().anyRequest().anonymous().and()
5454
.csrf().disable();
5555
return http.build();
5656
}

spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/RemoteDevToolsAutoConfigurationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ static class TestWebSecurityConfigurerAdapter
277277

278278
@Override
279279
protected void configure(HttpSecurity http) throws Exception {
280-
http.antMatcher("/foo/**").authorizeRequests().anyRequest().authenticated().and().httpBasic();
280+
http.antMatcher("/foo/**").authorizeHttpRequests().anyRequest().authenticated().and().httpBasic();
281281
}
282282

283283
}

spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuator/endpoints/security/exposeall/MySecurityConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class MySecurityConfiguration {
2828
@Bean
2929
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
3030
http.requestMatcher(EndpointRequest.toAnyEndpoint());
31-
http.authorizeRequests((requests) -> requests.anyRequest().permitAll());
31+
http.authorizeHttpRequests((requests) -> requests.anyRequest().permitAll());
3232
return http.build();
3333
}
3434

spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuator/endpoints/security/typical/MySecurityConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class MySecurityConfiguration {
3030
@Bean
3131
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
3232
http.requestMatcher(EndpointRequest.toAnyEndpoint());
33-
http.authorizeRequests((requests) -> requests.anyRequest().hasRole("ENDPOINT_ADMIN"));
33+
http.authorizeHttpRequests((requests) -> requests.anyRequest().hasRole("ENDPOINT_ADMIN"));
3434
http.httpBasic(withDefaults());
3535
return http.build();
3636
}

spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/data/sql/h2webconsole/springsecurity/DevProfileSecurityConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class DevProfileSecurityConfiguration {
3434
@Order(Ordered.HIGHEST_PRECEDENCE)
3535
SecurityFilterChain h2ConsoleSecurityFilterChain(HttpSecurity http) throws Exception {
3636
http.requestMatcher(PathRequest.toH2Console());
37-
http.authorizeRequests(yourCustomAuthorization());
37+
http.authorizeHttpRequests(yourCustomAuthorization());
3838
http.csrf((csrf) -> csrf.disable());
3939
http.headers((headers) -> headers.frameOptions().sameOrigin());
4040
return http.build();

spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testing/slicetests/MyConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class MyConfiguration {
3030

3131
@Bean
3232
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
33-
http.authorizeRequests((requests) -> requests.anyRequest().authenticated());
33+
http.authorizeHttpRequests((requests) -> requests.anyRequest().authenticated());
3434
return http.build();
3535
}
3636

spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testing/slicetests/MySecurityConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class MySecurityConfiguration {
2626

2727
@Bean
2828
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
29-
http.authorizeRequests((requests) -> requests.anyRequest().authenticated());
29+
http.authorizeHttpRequests((requests) -> requests.anyRequest().authenticated());
3030
return http.build();
3131
}
3232

spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/web/security/oauth2/client/MyOAuthClientConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class MyOAuthClientConfiguration {
2626

2727
@Bean
2828
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
29-
http.authorizeRequests((requests) -> requests.anyRequest().authenticated());
29+
http.authorizeHttpRequests((requests) -> requests.anyRequest().authenticated());
3030
http.oauth2Login((login) -> login.redirectionEndpoint().baseUri("custom-callback"));
3131
return http.build();
3232
}

spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/web/security/saml2/relyingparty/MySamlRelyingPartyConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class MySamlRelyingPartyConfiguration {
2626

2727
@Bean
2828
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
29-
http.authorizeRequests().anyRequest().authenticated();
29+
http.authorizeHttpRequests().anyRequest().authenticated();
3030
http.saml2Login();
3131
http.saml2Logout((saml2) -> saml2.logoutRequest((request) -> request.logoutUrl("/SLOService.saml2"))
3232
.logoutResponse((response) -> response.logoutUrl("/SLOService.saml2")));

spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/security/exposeall/MySecurityConfiguration.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ class MySecurityConfiguration {
2727

2828
@Bean
2929
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
30-
http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeRequests {
30+
http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeHttpRequests {
3131
requests -> requests.anyRequest().permitAll() }
3232
return http.build()
3333
}
3434

35-
}
35+
}

spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/endpoints/security/typical/MySecurityConfiguration.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ class MySecurityConfiguration {
2727

2828
@Bean
2929
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
30-
http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeRequests { requests ->
30+
http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeHttpRequests { requests ->
3131
requests.anyRequest().hasRole("ENDPOINT_ADMIN")
3232
}
3333
http.httpBasic()
3434
return http.build()
3535
}
3636

37-
}
37+
}

spring-boot-project/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/web/security/oauth2/client/MyOAuthClientConfiguration.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class MyOAuthClientConfiguration {
2626

2727
@Bean
2828
fun securityFilterChain(http: HttpSecurity): SecurityFilterChain {
29-
http.authorizeRequests().anyRequest().authenticated()
29+
http.authorizeHttpRequests().anyRequest().authenticated()
3030
http.oauth2Login().redirectionEndpoint().baseUri("custom-callback")
3131
return http.build()
3232
}

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/src/main/java/smoketest/actuator/customsecurity/SecurityConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private UserDetails createUserDetails(String username, String password, String..
5555

5656
@Bean
5757
SecurityFilterChain configure(HttpSecurity http) throws Exception {
58-
http.authorizeRequests((requests) -> {
58+
http.authorizeHttpRequests((requests) -> {
5959
requests.mvcMatchers("/actuator/beans").hasRole("BEANS");
6060
requests.requestMatchers(EndpointRequest.to("health")).permitAll();
6161
requests.requestMatchers(EndpointRequest.toAnyEndpoint().excluding(MappingsEndpoint.class))

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-method-security/src/main/java/smoketest/security/method/SampleMethodSecurityApplication.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ protected static class ApplicationSecurity {
6969
@Bean
7070
SecurityFilterChain configure(HttpSecurity http) throws Exception {
7171
http.csrf().disable();
72-
http.authorizeRequests((requests) -> requests.anyRequest().fullyAuthenticated()
73-
.filterSecurityInterceptorOncePerRequest(true));
72+
http.authorizeHttpRequests(
73+
(requests) -> requests.anyRequest().fullyAuthenticated().shouldFilterAllDispatcherTypes(false));
7474
http.formLogin((form) -> form.loginPage("/login").permitAll());
7575
http.exceptionHandling((exceptions) -> exceptions.accessDeniedPage("/access"));
7676
return http.build();
@@ -86,8 +86,8 @@ protected static class ActuatorSecurity {
8686
SecurityFilterChain actuatorSecurity(HttpSecurity http) throws Exception {
8787
http.csrf().disable();
8888
http.requestMatcher(EndpointRequest.toAnyEndpoint());
89-
http.authorizeRequests(
90-
(requests) -> requests.anyRequest().authenticated().filterSecurityInterceptorOncePerRequest(true));
89+
http.authorizeHttpRequests(
90+
(requests) -> requests.anyRequest().authenticated().shouldFilterAllDispatcherTypes(false));
9191
http.httpBasic();
9292
return http.build();
9393
}

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure-custom/src/main/java/smoketest/web/secure/custom/SampleWebSecureCustomApplication.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 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.
@@ -44,7 +44,7 @@ protected static class ApplicationSecurity {
4444
@Bean
4545
SecurityFilterChain configure(HttpSecurity http) throws Exception {
4646
http.csrf().disable();
47-
http.authorizeRequests((requests) -> requests.anyRequest().fullyAuthenticated());
47+
http.authorizeHttpRequests((requests) -> requests.anyRequest().fullyAuthenticated());
4848
http.formLogin((form) -> form.loginPage("/login").permitAll());
4949
return http.build();
5050
}

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure-jdbc/src/main/java/smoketest/web/secure/jdbc/SampleWebSecureJdbcApplication.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 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.
@@ -47,7 +47,7 @@ protected static class ApplicationSecurity {
4747
@Bean
4848
SecurityFilterChain configure(HttpSecurity http) throws Exception {
4949
http.csrf().disable();
50-
http.authorizeRequests((requests) -> requests.anyRequest().fullyAuthenticated());
50+
http.authorizeHttpRequests((requests) -> requests.anyRequest().fullyAuthenticated());
5151
http.formLogin((form) -> form.loginPage("/login").permitAll());
5252
return http.build();
5353
}

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/AbstractErrorPageTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected AbstractErrorPageTests(String pathPrefix) {
5050
@Test
5151
void testBadCredentials() {
5252
final ResponseEntity<JsonNode> response = this.testRestTemplate.withBasicAuth("username", "wrongpassword")
53-
.exchange("/test", HttpMethod.GET, null, JsonNode.class);
53+
.exchange(this.pathPrefix + "/test", HttpMethod.GET, null, JsonNode.class);
5454
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
5555
JsonNode jsonResponse = response.getBody();
5656
assertThat(jsonResponse).isNull();

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/CustomServletPathErrorPageTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ static class SecurityConfiguration {
4444

4545
@Bean
4646
SecurityFilterChain configure(HttpSecurity http) throws Exception {
47-
http.authorizeRequests((requests) -> {
47+
http.authorizeHttpRequests((requests) -> {
4848
requests.antMatchers("/custom/servlet/path/public/**").permitAll();
4949
requests.anyRequest().fullyAuthenticated();
50-
requests.filterSecurityInterceptorOncePerRequest(true);
50+
requests.shouldFilterAllDispatcherTypes(false);
5151
});
5252
http.httpBasic();
5353
http.formLogin((form) -> form.loginPage("/custom/servlet/path/login").permitAll());

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/CustomServletPathUnauthenticatedErrorPageTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static class SecurityConfiguration {
4343

4444
@Bean
4545
SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws Exception {
46-
http.authorizeRequests((requests) -> {
46+
http.authorizeHttpRequests((requests) -> {
4747
requests.antMatchers("/custom/servlet/path/error").permitAll();
4848
requests.antMatchers("/custom/servlet/path/public/**").permitAll();
4949
requests.anyRequest().authenticated();

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/ErrorPageTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ static class SecurityConfiguration {
4343

4444
@Bean
4545
SecurityFilterChain configure(HttpSecurity http) throws Exception {
46-
http.authorizeRequests((requests) -> {
46+
http.authorizeHttpRequests((requests) -> {
4747
requests.antMatchers("/public/**").permitAll();
4848
requests.anyRequest().fullyAuthenticated();
49-
requests.filterSecurityInterceptorOncePerRequest(true);
49+
requests.shouldFilterAllDispatcherTypes(false);
5050
});
5151
http.httpBasic();
5252
http.formLogin((form) -> form.loginPage("/login").permitAll());

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/NoSessionErrorPageTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ static class SecurityConfiguration {
4545
@Bean
4646
SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws Exception {
4747
http.sessionManagement((session) -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
48-
.authorizeRequests((requests) -> {
48+
.authorizeHttpRequests((requests) -> {
4949
requests.antMatchers("/public/**").permitAll();
5050
requests.anyRequest().authenticated();
51-
requests.filterSecurityInterceptorOncePerRequest(true);
51+
requests.shouldFilterAllDispatcherTypes(false);
5252
});
5353
http.httpBasic();
5454
return http.build();

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/SampleWebSecureApplicationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static class SecurityConfiguration {
9595
@Bean
9696
SecurityFilterChain configure(HttpSecurity http) throws Exception {
9797
http.csrf().disable();
98-
http.authorizeRequests((requests) -> {
98+
http.authorizeHttpRequests((requests) -> {
9999
requests.antMatchers("/public/**").permitAll();
100100
requests.anyRequest().fullyAuthenticated();
101101
});

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/UnauthenticatedErrorPageTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static class SecurityConfiguration {
4343

4444
@Bean
4545
SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws Exception {
46-
http.authorizeRequests((requests) -> {
46+
http.authorizeHttpRequests((requests) -> {
4747
requests.antMatchers("/error").permitAll();
4848
requests.antMatchers("/public/**").permitAll();
4949
requests.anyRequest().authenticated();

0 commit comments

Comments
 (0)