Format authorizeRequests Blocks

This commit changes all auhorizeRequests
declarations to use the same variable name
and declare the lambda parameter and reference
on the same line.

Issue gh-13067
This commit is contained in:
Josh Cummings 2025-06-19 16:55:21 -06:00
parent 5dd40a7f10
commit cf6b52d6f7
No known key found for this signature in database
GPG Key ID: 869B37A20E876129
15 changed files with 40 additions and 78 deletions

View File

@ -147,8 +147,7 @@ public class AnonymousConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().permitAll() .anyRequest().permitAll()
) )
.anonymous(AbstractHttpConfigurer::disable); .anonymous(AbstractHttpConfigurer::disable);
@ -171,8 +170,7 @@ public class AnonymousConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().permitAll() .anyRequest().permitAll()
) )
.anonymous(withDefaults()); .anonymous(withDefaults());

View File

@ -219,8 +219,7 @@ public class AuthorizeRequestsTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.requestMatchers(new AntPathRequestMatcher("/**", HttpMethod.POST.name())).denyAll() .requestMatchers(new AntPathRequestMatcher("/**", HttpMethod.POST.name())).denyAll()
); );
// @formatter:on // @formatter:on
@ -349,8 +348,7 @@ public class AuthorizeRequestsTests {
// @formatter:off // @formatter:off
http http
.httpBasic(withDefaults()) .httpBasic(withDefaults())
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.requestMatchers("/path").denyAll() .requestMatchers("/path").denyAll()
); );
// @formatter:on // @formatter:on
@ -421,8 +419,7 @@ public class AuthorizeRequestsTests {
// @formatter:off // @formatter:off
http http
.httpBasic(withDefaults()) .httpBasic(withDefaults())
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.requestMatchers(mvcMatcherBuilder.pattern("/path")).denyAll() .requestMatchers(mvcMatcherBuilder.pattern("/path")).denyAll()
); );
// @formatter:on // @formatter:on
@ -489,8 +486,7 @@ public class AuthorizeRequestsTests {
// @formatter:off // @formatter:off
http http
.httpBasic(withDefaults()) .httpBasic(withDefaults())
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.requestMatchers("/user/{userName}").access("#userName == 'user'") .requestMatchers("/user/{userName}").access("#userName == 'user'")
); );
// @formatter:on // @formatter:on

View File

@ -251,8 +251,7 @@ public class CorsConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().authenticated() .anyRequest().authenticated()
) )
.cors(withDefaults()); .cors(withDefaults());
@ -308,8 +307,7 @@ public class CorsConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().authenticated() .anyRequest().authenticated()
) )
.cors(withDefaults()); .cors(withDefaults());
@ -364,8 +362,7 @@ public class CorsConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().authenticated() .anyRequest().authenticated()
) )
.cors(withDefaults()); .cors(withDefaults());

View File

@ -113,8 +113,7 @@ public class ExceptionHandlingConfigurerAccessDeniedHandlerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().denyAll() .anyRequest().denyAll()
) )
.exceptionHandling((exceptionHandling) -> .exceptionHandling((exceptionHandling) ->

View File

@ -453,8 +453,7 @@ public class FormLoginConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().hasRole("USER") .anyRequest().hasRole("USER")
) )
.formLogin(withDefaults()); .formLogin(withDefaults());
@ -516,8 +515,7 @@ public class FormLoginConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().hasRole("USER") .anyRequest().hasRole("USER")
) )
.formLogin((formLogin) -> .formLogin((formLogin) ->
@ -572,8 +570,7 @@ public class FormLoginConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().authenticated() .anyRequest().authenticated()
) )
.formLogin((formLogin) -> .formLogin((formLogin) ->

View File

@ -250,8 +250,7 @@ public class HttpBasicConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().authenticated() .anyRequest().authenticated()
) )
.httpBasic(withDefaults()); .httpBasic(withDefaults());

View File

@ -341,8 +341,7 @@ public class HttpSecurityRequestMatchersTests {
.requestMatchers(new MvcRequestMatcher(introspector, "/path")) .requestMatchers(new MvcRequestMatcher(introspector, "/path"))
) )
.httpBasic(withDefaults()) .httpBasic(withDefaults())
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().denyAll() .anyRequest().denyAll()
); );
return http.build(); return http.build();
@ -416,8 +415,7 @@ public class HttpSecurityRequestMatchersTests {
.requestMatchers("/never-match") .requestMatchers("/never-match")
) )
.httpBasic(withDefaults()) .httpBasic(withDefaults())
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().denyAll() .anyRequest().denyAll()
); );
return http.build(); return http.build();

View File

@ -209,8 +209,7 @@ public class JeeConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().hasRole("USER") .anyRequest().hasRole("USER")
) )
.jee((jee) -> .jee((jee) ->
@ -231,8 +230,7 @@ public class JeeConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().hasRole("USER") .anyRequest().hasRole("USER")
) )
.jee((jee) -> .jee((jee) ->
@ -256,8 +254,7 @@ public class JeeConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().hasRole("USER") .anyRequest().hasRole("USER")
) )
.jee((jee) -> .jee((jee) ->

View File

@ -200,8 +200,7 @@ public class NamespaceHttpBasicTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().hasRole("USER") .anyRequest().hasRole("USER")
) )
.httpBasic(withDefaults()); .httpBasic(withDefaults());
@ -236,8 +235,7 @@ public class NamespaceHttpBasicTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().hasRole("USER") .anyRequest().hasRole("USER")
) )
.httpBasic((httpBasicConfig) -> httpBasicConfig.realmName("Custom Realm")); .httpBasic((httpBasicConfig) -> httpBasicConfig.realmName("Custom Realm"));
@ -325,8 +323,7 @@ public class NamespaceHttpBasicTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().hasRole("USER") .anyRequest().hasRole("USER")
) )
.httpBasic((httpBasicConfig) -> .httpBasic((httpBasicConfig) ->

View File

@ -130,8 +130,7 @@ public class NamespaceHttpServerAccessDeniedHandlerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().denyAll() .anyRequest().denyAll()
) )
.exceptionHandling((exceptionHandling) -> .exceptionHandling((exceptionHandling) ->
@ -176,8 +175,7 @@ public class NamespaceHttpServerAccessDeniedHandlerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().denyAll() .anyRequest().denyAll()
) )
.exceptionHandling((exceptionHandling) -> .exceptionHandling((exceptionHandling) ->

View File

@ -508,8 +508,7 @@ public class RememberMeConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().hasRole("USER") .anyRequest().hasRole("USER")
) )
.formLogin(withDefaults()) .formLogin(withDefaults())
@ -557,8 +556,7 @@ public class RememberMeConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().hasRole("USER") .anyRequest().hasRole("USER")
) )
.formLogin(withDefaults()) .formLogin(withDefaults())
@ -636,8 +634,7 @@ public class RememberMeConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().hasRole("USER") .anyRequest().hasRole("USER")
) )
.sessionManagement((sessionManagement) -> .sessionManagement((sessionManagement) ->

View File

@ -412,8 +412,7 @@ public class RequestCacheConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().authenticated() .anyRequest().authenticated()
) )
.formLogin(withDefaults()) .formLogin(withDefaults())
@ -432,8 +431,7 @@ public class RequestCacheConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().authenticated() .anyRequest().authenticated()
) )
.formLogin(withDefaults()) .formLogin(withDefaults())
@ -452,8 +450,7 @@ public class RequestCacheConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().authenticated() .anyRequest().authenticated()
) )
.formLogin(withDefaults()) .formLogin(withDefaults())

View File

@ -106,8 +106,7 @@ public class RequestMatcherConfigurerTests {
matchers matchers
.requestMatchers(new AntPathRequestMatcher("/oauth/**")) .requestMatchers(new AntPathRequestMatcher("/oauth/**"))
) )
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().denyAll() .anyRequest().denyAll()
); );
return http.build(); return http.build();

View File

@ -399,8 +399,7 @@ public class OAuth2ClientConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().authenticated() .anyRequest().authenticated()
) )
.oauth2Client(withDefaults()); .oauth2Client(withDefaults());

View File

@ -1395,10 +1395,9 @@ public class OAuth2ResourceServerConfigurerTests {
context.registerBean("converterOne", JwtAuthenticationConverter.class, () -> converterBean); context.registerBean("converterOne", JwtAuthenticationConverter.class, () -> converterBean);
context.registerBean("converterTwo", JwtAuthenticationConverter.class, () -> converterBean); context.registerBean("converterTwo", JwtAuthenticationConverter.class, () -> converterBean);
this.spring.context(context).autowire(); this.spring.context(context).autowire();
new OAuth2ResourceServerConfigurer<HttpSecurity>(context).jwt((jwt) -> { new OAuth2ResourceServerConfigurer<HttpSecurity>(context)
assertThatExceptionOfType(NoUniqueBeanDefinitionException.class) .jwt((jwt) -> assertThatExceptionOfType(NoUniqueBeanDefinitionException.class)
.isThrownBy(jwt::getJwtAuthenticationConverter); .isThrownBy(jwt::getJwtAuthenticationConverter));
});
} }
@Test @Test
@ -1577,8 +1576,7 @@ public class OAuth2ResourceServerConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.requestMatchers("/requires-read-scope").access("hasAuthority('SCOPE_message:read')") .requestMatchers("/requires-read-scope").access("hasAuthority('SCOPE_message:read')")
.anyRequest().authenticated() .anyRequest().authenticated()
) )
@ -1630,8 +1628,7 @@ public class OAuth2ResourceServerConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.requestMatchers("/requires-read-scope").access("hasAuthority('SCOPE_message:read')") .requestMatchers("/requires-read-scope").access("hasAuthority('SCOPE_message:read')")
.anyRequest().authenticated() .anyRequest().authenticated()
) )
@ -2122,8 +2119,7 @@ public class OAuth2ResourceServerConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().authenticated() .anyRequest().authenticated()
) )
.oauth2ResourceServer((oauth2ResourceServer) -> .oauth2ResourceServer((oauth2ResourceServer) ->
@ -2386,8 +2382,7 @@ public class OAuth2ResourceServerConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.requestMatchers("/requires-read-scope").hasAuthority("SCOPE_message:read") .requestMatchers("/requires-read-scope").hasAuthority("SCOPE_message:read")
.anyRequest().authenticated() .anyRequest().authenticated()
) )
@ -2433,8 +2428,7 @@ public class OAuth2ResourceServerConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().authenticated() .anyRequest().authenticated()
) )
.oauth2ResourceServer((oauth2ResourceServer) -> .oauth2ResourceServer((oauth2ResourceServer) ->