Skip to content

Commit 6e3a87d

Browse files
committed
Merge pull request spring-projects#31255 from vpavic
* spring-projectsgh-31255: Migrate to AuthorizationFilter in Spring Security auto-config Closes spring-projectsgh-31255
2 parents 5543fba + 230f2cd commit 6e3a87d

File tree

38 files changed

+52
-51
lines changed

38 files changed

+52
-51
lines changed

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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/graphql/security/GraphQlWebMvcSecurityAutoConfigurationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ DefaultSecurityFilterChain springWebFilterChain(HttpSecurity http) throws Except
160160
return http.csrf((c) -> c.disable())
161161
// Demonstrate that method security works
162162
// Best practice to use both for defense in depth
163-
.authorizeRequests((requests) -> requests.anyRequest().permitAll()).httpBasic(withDefaults())
163+
.authorizeHttpRequests((requests) -> requests.anyRequest().permitAll()).httpBasic(withDefaults())
164164
.build();
165165
}
166166

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

Lines changed: 1 addition & 1 deletion
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
}

0 commit comments

Comments
 (0)