Migrate to AuthorizationFilter in Spring Security auto-config
This commit updates Servlet based Spring Security auto-configuration to use AuthorizationFilter, which is intended to supersede FilterSecurityInterceptor. See gh-31255
This commit is contained in:
committed by
Andy Wilkinson
parent
5543fba57e
commit
230f2cda84
@@ -58,7 +58,7 @@ class OAuth2WebSecurityConfiguration {
|
||||
|
||||
@Bean
|
||||
SecurityFilterChain oauth2SecurityFilterChain(HttpSecurity http) throws Exception {
|
||||
http.authorizeRequests((requests) -> requests.anyRequest().authenticated());
|
||||
http.authorizeHttpRequests((requests) -> requests.anyRequest().authenticated());
|
||||
http.oauth2Login(Customizer.withDefaults());
|
||||
http.oauth2Client();
|
||||
return http.build();
|
||||
|
||||
@@ -153,7 +153,7 @@ class OAuth2ResourceServerJwtConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnBean(JwtDecoder.class)
|
||||
SecurityFilterChain jwtSecurityFilterChain(HttpSecurity http) throws Exception {
|
||||
http.authorizeRequests((requests) -> requests.anyRequest().authenticated());
|
||||
http.authorizeHttpRequests((requests) -> requests.anyRequest().authenticated());
|
||||
http.oauth2ResourceServer(OAuth2ResourceServerConfigurer::jwt);
|
||||
return http.build();
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class OAuth2ResourceServerOpaqueTokenConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnBean(OpaqueTokenIntrospector.class)
|
||||
SecurityFilterChain opaqueTokenSecurityFilterChain(HttpSecurity http) throws Exception {
|
||||
http.authorizeRequests((requests) -> requests.anyRequest().authenticated());
|
||||
http.authorizeHttpRequests((requests) -> requests.anyRequest().authenticated());
|
||||
http.oauth2ResourceServer(OAuth2ResourceServerConfigurer::opaqueToken);
|
||||
return http.build();
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class Saml2LoginConfiguration {
|
||||
|
||||
@Bean
|
||||
SecurityFilterChain samlSecurityFilterChain(HttpSecurity http) throws Exception {
|
||||
http.authorizeRequests((requests) -> requests.anyRequest().authenticated()).saml2Login();
|
||||
http.authorizeHttpRequests((requests) -> requests.anyRequest().authenticated()).saml2Login();
|
||||
http.saml2Logout();
|
||||
return http.build();
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class SpringBootWebSecurityConfiguration {
|
||||
@Bean
|
||||
@Order(SecurityProperties.BASIC_AUTH_ORDER)
|
||||
SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws Exception {
|
||||
http.authorizeRequests().anyRequest().authenticated();
|
||||
http.authorizeHttpRequests().anyRequest().authenticated();
|
||||
http.formLogin();
|
||||
http.httpBasic();
|
||||
return http.build();
|
||||
|
||||
@@ -160,7 +160,7 @@ class GraphQlWebMvcSecurityAutoConfigurationTests {
|
||||
return http.csrf((c) -> c.disable())
|
||||
// Demonstrate that method security works
|
||||
// Best practice to use both for defense in depth
|
||||
.authorizeRequests((requests) -> requests.anyRequest().permitAll()).httpBasic(withDefaults())
|
||||
.authorizeHttpRequests((requests) -> requests.anyRequest().permitAll()).httpBasic(withDefaults())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -241,7 +241,7 @@ class OAuth2WebSecurityConfigurationTests {
|
||||
|
||||
@Bean
|
||||
SecurityFilterChain testSecurityFilterChain(HttpSecurity http) throws Exception {
|
||||
return http.antMatcher("/**").authorizeRequests((authorize) -> authorize.anyRequest().authenticated())
|
||||
return http.antMatcher("/**").authorizeHttpRequests((authorize) -> authorize.anyRequest().authenticated())
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
@@ -692,7 +692,7 @@ class OAuth2ResourceServerAutoConfigurationTests {
|
||||
|
||||
@Bean
|
||||
SecurityFilterChain testSecurityFilterChain(HttpSecurity http) throws Exception {
|
||||
return http.antMatcher("/**").authorizeRequests((authorize) -> authorize.anyRequest().authenticated())
|
||||
return http.antMatcher("/**").authorizeHttpRequests((authorize) -> authorize.anyRequest().authenticated())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -321,7 +321,7 @@ class Saml2RelyingPartyAutoConfigurationTests {
|
||||
|
||||
@Bean
|
||||
SecurityFilterChain testSecurityFilterChain(HttpSecurity http) throws Exception {
|
||||
return http.antMatcher("/**").authorizeRequests((authorize) -> authorize.anyRequest().authenticated())
|
||||
return http.antMatcher("/**").authorizeHttpRequests((authorize) -> authorize.anyRequest().authenticated())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -298,7 +298,7 @@ class SecurityAutoConfigurationTests {
|
||||
|
||||
@Bean
|
||||
SecurityFilterChain testSecurityFilterChain(HttpSecurity http) throws Exception {
|
||||
return http.antMatcher("/**").authorizeRequests((authorize) -> authorize.anyRequest().authenticated())
|
||||
return http.antMatcher("/**").authorizeHttpRequests((authorize) -> authorize.anyRequest().authenticated())
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user