Skip to content

Commit a4c338f

Browse files
committed
Format authorizeExchange Blocks
This commit formats authorizeExchange blocks to use a common variable name and ensure the variable and reference are on the same line. Issue gh-13067
1 parent da6c7b8 commit a4c338f

File tree

22 files changed

+78
-78
lines changed

22 files changed

+78
-78
lines changed

config/src/main/java/org/springframework/security/config/annotation/web/reactive/WebFluxSecurityConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private SecurityWebFilterChain springSecurityFilterChain() {
123123
* @return
124124
*/
125125
private SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
126-
http.authorizeExchange((exchange) -> exchange.anyExchange().authenticated());
126+
http.authorizeExchange((authorize) -> authorize.anyExchange().authenticated());
127127
if (isOAuth2Present && OAuth2ClasspathGuard.shouldConfigure(this.context)) {
128128
OAuth2ClasspathGuard.configure(this.context, http);
129129
}

config/src/main/java/org/springframework/security/config/web/server/ServerHttpSecurity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@
270270
* @Bean
271271
* public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
272272
* http
273-
* .authorizeExchange((exchange) -> exchange.anyExchange().authenticated())
273+
* .authorizeExchange((authorize) -> authorize.anyExchange().authenticated())
274274
* .httpBasic(Customizer.withDefaults())
275275
* .formLogin();
276276
* return http.build();

config/src/test/java/org/springframework/security/config/annotation/web/reactive/EnableWebFluxSecurityTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ static class MultiSecurityHttpConfig {
377377
@Bean
378378
SecurityWebFilterChain apiHttpSecurity(ServerHttpSecurity http) {
379379
http.securityMatcher(new PathPatternParserServerWebExchangeMatcher("/api/**"))
380-
.authorizeExchange((exchange) -> exchange.anyExchange().denyAll());
380+
.authorizeExchange((authorize) -> authorize.anyExchange().denyAll());
381381
return http.build();
382382
}
383383

config/src/test/java/org/springframework/security/config/annotation/web/reactive/ServerHttpSecurityConfigurationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ static class FormLoginConfig {
281281
SecurityWebFilterChain filterChain(ServerHttpSecurity http) {
282282
// @formatter:off
283283
http
284-
.authorizeExchange((exchange) -> exchange
284+
.authorizeExchange((authorize) -> authorize
285285
.anyExchange().authenticated()
286286
)
287287
.formLogin(Customizer.withDefaults());
@@ -300,7 +300,7 @@ static class FormLoginRedirectToResetPasswordConfig {
300300
SecurityWebFilterChain filterChain(ServerHttpSecurity http) {
301301
// @formatter:off
302302
http
303-
.authorizeExchange((exchange) -> exchange
303+
.authorizeExchange((authorize) -> authorize
304304
.anyExchange().authenticated()
305305
)
306306
.formLogin((form) -> form

config/src/test/java/org/springframework/security/config/web/server/AuthorizeExchangeSpecTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public void antMatchersWhenPatternsThenAnyMethod() {
8989
@Test
9090
public void antMatchersWhenPatternsInLambdaThenAnyMethod() {
9191
this.http.csrf(ServerHttpSecurity.CsrfSpec::disable)
92-
.authorizeExchange((exchanges) -> exchanges.pathMatchers("/a", "/b").denyAll().anyExchange().permitAll());
92+
.authorizeExchange((authorize) -> authorize.pathMatchers("/a", "/b").denyAll().anyExchange().permitAll());
9393
WebTestClient client = buildClient();
9494
// @formatter:off
9595
client.get()
@@ -113,16 +113,16 @@ public void antMatchersWhenPatternsInLambdaThenAnyMethod() {
113113

114114
@Test
115115
public void antMatchersWhenNoAccessAndAnotherMatcherThenThrowsException() {
116-
this.http.authorizeExchange((exchange) -> exchange.pathMatchers("/incomplete"));
116+
this.http.authorizeExchange((authorize) -> authorize.pathMatchers("/incomplete"));
117117
assertThatIllegalStateException()
118-
.isThrownBy(() -> this.http.authorizeExchange((exchange) -> exchange.pathMatchers("/throws-exception")));
118+
.isThrownBy(() -> this.http.authorizeExchange((authorize) -> authorize.pathMatchers("/throws-exception")));
119119
}
120120

121121
@Test
122122
public void anyExchangeWhenFollowedByMatcherThenThrowsException() {
123123
assertThatIllegalStateException().isThrownBy(() ->
124124
// @formatter:off
125-
this.http.authorizeExchange((exchange) -> exchange
125+
this.http.authorizeExchange((authorize) -> authorize
126126
.anyExchange().denyAll()
127127
.pathMatchers("/never-reached"))
128128
// @formatter:on
@@ -131,13 +131,13 @@ public void anyExchangeWhenFollowedByMatcherThenThrowsException() {
131131

132132
@Test
133133
public void buildWhenMatcherDefinedWithNoAccessThenThrowsException() {
134-
this.http.authorizeExchange((exchange) -> exchange.pathMatchers("/incomplete"));
134+
this.http.authorizeExchange((authorize) -> authorize.pathMatchers("/incomplete"));
135135
assertThatIllegalStateException().isThrownBy(this.http::build);
136136
}
137137

138138
@Test
139139
public void buildWhenMatcherDefinedWithNoAccessInLambdaThenThrowsException() {
140-
this.http.authorizeExchange((exchanges) -> exchanges.pathMatchers("/incomplete"));
140+
this.http.authorizeExchange((authorize) -> authorize.pathMatchers("/incomplete"));
141141
assertThatIllegalStateException().isThrownBy(this.http::build);
142142
}
143143

config/src/test/java/org/springframework/security/config/web/server/ExceptionHandlingSpecTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void defaultAuthenticationEntryPoint() {
6363
public void requestWhenExceptionHandlingWithDefaultsInLambdaThenDefaultAuthenticationEntryPointUsed() {
6464
// @formatter:off
6565
SecurityWebFilterChain securityWebFilter = this.http
66-
.authorizeExchange((exchanges) -> exchanges
66+
.authorizeExchange((authorize) -> authorize
6767
.anyExchange().authenticated()
6868
)
6969
.exceptionHandling(withDefaults())
@@ -104,7 +104,7 @@ public void customAuthenticationEntryPoint() {
104104
public void requestWhenCustomAuthenticationEntryPointInLambdaThenCustomAuthenticationEntryPointUsed() {
105105
// @formatter:off
106106
SecurityWebFilterChain securityWebFilter = this.http
107-
.authorizeExchange((exchanges) -> exchanges
107+
.authorizeExchange((authorize) -> authorize
108108
.anyExchange().authenticated()
109109
)
110110
.exceptionHandling((exceptionHandling) -> exceptionHandling
@@ -128,7 +128,7 @@ public void defaultAccessDeniedHandler() {
128128
SecurityWebFilterChain securityWebFilter = this.http
129129
.csrf((csrf) -> csrf.disable())
130130
.httpBasic(Customizer.withDefaults())
131-
.authorizeExchange((exchange) -> exchange
131+
.authorizeExchange((authorize) -> authorize
132132
.anyExchange().hasRole("ADMIN"))
133133
.exceptionHandling(withDefaults())
134134
.build();
@@ -148,7 +148,7 @@ public void requestWhenExceptionHandlingWithDefaultsInLambdaThenDefaultAccessDen
148148
// @formatter:off
149149
SecurityWebFilterChain securityWebFilter = this.http
150150
.httpBasic(withDefaults())
151-
.authorizeExchange((exchanges) -> exchanges
151+
.authorizeExchange((authorize) -> authorize
152152
.anyExchange().hasRole("ADMIN")
153153
)
154154
.exceptionHandling(withDefaults())
@@ -170,7 +170,7 @@ public void customAccessDeniedHandler() {
170170
SecurityWebFilterChain securityWebFilter = this.http
171171
.csrf((csrf) -> csrf.disable())
172172
.httpBasic(Customizer.withDefaults())
173-
.authorizeExchange((exchange) -> exchange
173+
.authorizeExchange((authorize) -> authorize
174174
.anyExchange().hasRole("ADMIN"))
175175
.exceptionHandling((handling) -> handling
176176
.accessDeniedHandler(httpStatusServerAccessDeniedHandler(HttpStatus.BAD_REQUEST)))
@@ -191,7 +191,7 @@ public void requestWhenCustomAccessDeniedHandlerInLambdaThenCustomAccessDeniedHa
191191
// @formatter:off
192192
SecurityWebFilterChain securityWebFilter = this.http
193193
.httpBasic(withDefaults())
194-
.authorizeExchange((exchanges) -> exchanges
194+
.authorizeExchange((authorize) -> authorize
195195
.anyExchange().hasRole("ADMIN")
196196
)
197197
.exceptionHandling((exceptionHandling) -> exceptionHandling

config/src/test/java/org/springframework/security/config/web/server/FormLoginTests.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public class FormLoginTests {
6969
public void defaultLoginPage() {
7070
// @formatter:off
7171
SecurityWebFilterChain securityWebFilter = this.http
72-
.authorizeExchange((exchange) -> exchange
72+
.authorizeExchange((authorize) -> authorize
7373
.anyExchange().authenticated())
7474
.formLogin(withDefaults())
7575
.build();
@@ -100,7 +100,7 @@ public void defaultLoginPage() {
100100
@Test
101101
public void formLoginWhenDefaultsInLambdaThenCreatesDefaultLoginPage() {
102102
SecurityWebFilterChain securityWebFilter = this.http
103-
.authorizeExchange((exchanges) -> exchanges.anyExchange().authenticated())
103+
.authorizeExchange((authorize) -> authorize.anyExchange().authenticated())
104104
.formLogin(withDefaults())
105105
.build();
106106
WebTestClient webTestClient = WebTestClientBuilder.bindToWebFilters(securityWebFilter).build();
@@ -127,7 +127,7 @@ public void formLoginWhenDefaultsInLambdaThenCreatesDefaultLoginPage() {
127127
public void customLoginPage() {
128128
// @formatter:off
129129
SecurityWebFilterChain securityWebFilter = this.http
130-
.authorizeExchange((exchange) -> exchange
130+
.authorizeExchange((authorize) -> authorize
131131
.pathMatchers("/login").permitAll()
132132
.anyExchange().authenticated())
133133
.formLogin((login) -> login
@@ -155,7 +155,7 @@ public void customLoginPage() {
155155
public void formLoginWhenCustomLoginPageInLambdaThenUsed() {
156156
// @formatter:off
157157
SecurityWebFilterChain securityWebFilter = this.http
158-
.authorizeExchange((exchanges) -> exchanges
158+
.authorizeExchange((authorize) -> authorize
159159
.pathMatchers("/login").permitAll()
160160
.anyExchange().authenticated()
161161
)
@@ -185,7 +185,7 @@ public void formLoginWhenCustomLoginPageInLambdaThenUsed() {
185185
public void formLoginWhenCustomAuthenticationFailureHandlerThenUsed() {
186186
// @formatter:off
187187
SecurityWebFilterChain securityWebFilter = this.http
188-
.authorizeExchange((exchange) -> exchange
188+
.authorizeExchange((authorize) -> authorize
189189
.pathMatchers("/login", "/failure").permitAll()
190190
.anyExchange().authenticated())
191191
.formLogin((login) -> login
@@ -212,7 +212,7 @@ public void formLoginWhenCustomAuthenticationFailureHandlerThenUsed() {
212212
public void formLoginWhenCustomRequiresAuthenticationMatcherThenUsed() {
213213
// @formatter:off
214214
SecurityWebFilterChain securityWebFilter = this.http
215-
.authorizeExchange((exchange) -> exchange
215+
.authorizeExchange((authorize) -> authorize
216216
.pathMatchers("/login", "/sign-in").permitAll()
217217
.anyExchange().authenticated())
218218
.formLogin((login) -> login
@@ -233,7 +233,7 @@ public void formLoginWhenCustomRequiresAuthenticationMatcherThenUsed() {
233233
public void authenticationSuccess() {
234234
// @formatter:off
235235
SecurityWebFilterChain securityWebFilter = this.http
236-
.authorizeExchange((exchange) -> exchange
236+
.authorizeExchange((authorize) -> authorize
237237
.anyExchange().authenticated())
238238
.formLogin((login) -> login
239239
.authenticationSuccessHandler(new RedirectServerAuthenticationSuccessHandler("/custom")))
@@ -298,7 +298,7 @@ public void formLoginSecurityContextRepository() {
298298
given(formLoginSecContextRepository.load(any())).willReturn(authentication(token));
299299
// @formatter:off
300300
SecurityWebFilterChain securityWebFilter = this.http
301-
.authorizeExchange((exchange) -> exchange
301+
.authorizeExchange((authorize) -> authorize
302302
.anyExchange().authenticated())
303303
.securityContextRepository(defaultSecContextRepository)
304304
.formLogin((login) -> login

config/src/test/java/org/springframework/security/config/web/server/LogoutSpecTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class LogoutSpecTests {
4444
public void defaultLogout() {
4545
// @formatter:off
4646
SecurityWebFilterChain securityWebFilter = this.http
47-
.authorizeExchange((exchange) -> exchange
47+
.authorizeExchange((authorize) -> authorize
4848
.anyExchange().authenticated())
4949
.formLogin(withDefaults())
5050
.build();
@@ -78,7 +78,7 @@ public void defaultLogout() {
7878
public void customLogout() {
7979
// @formatter:off
8080
SecurityWebFilterChain securityWebFilter = this.http
81-
.authorizeExchange((exchange) -> exchange
81+
.authorizeExchange((authorize) -> authorize
8282
.anyExchange().authenticated())
8383
.formLogin(withDefaults())
8484
.logout((logout) -> logout
@@ -114,7 +114,7 @@ public void customLogout() {
114114
public void logoutWhenCustomLogoutInLambdaThenCustomLogoutUsed() {
115115
// @formatter:off
116116
SecurityWebFilterChain securityWebFilter = this.http
117-
.authorizeExchange((exchange) -> exchange
117+
.authorizeExchange((authorize) -> authorize
118118
.anyExchange().authenticated()
119119
)
120120
.formLogin(withDefaults())
@@ -151,7 +151,7 @@ public void logoutWhenCustomLogoutInLambdaThenCustomLogoutUsed() {
151151
public void logoutWhenDisabledThenDefaultLogoutPageDoesNotExist() {
152152
// @formatter:off
153153
SecurityWebFilterChain securityWebFilter = this.http
154-
.authorizeExchange((exchange) -> exchange
154+
.authorizeExchange((authorize) -> authorize
155155
.anyExchange().authenticated())
156156
.formLogin(withDefaults())
157157
.logout((logout) -> logout.disable())
@@ -184,7 +184,7 @@ public void logoutWhenCustomSecurityContextRepositoryThenLogsOut() {
184184
// @formatter:off
185185
SecurityWebFilterChain securityWebFilter = this.http
186186
.securityContextRepository(repository)
187-
.authorizeExchange((exchange) -> exchange
187+
.authorizeExchange((authorize) -> authorize
188188
.anyExchange().authenticated())
189189
.formLogin(withDefaults())
190190
.logout(withDefaults())

config/src/test/java/org/springframework/security/config/web/server/OAuth2LoginTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
863863
http.authenticationManager(authenticationManager);
864864
// @formatter:off
865865
http
866-
.authorizeExchange((exchange) -> exchange
866+
.authorizeExchange((authorize) -> authorize
867867
.anyExchange().authenticated())
868868
.oauth2Login(withDefaults())
869869
.formLogin(withDefaults());
@@ -885,7 +885,7 @@ SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
885885
http.authenticationManager(authenticationManager);
886886
// @formatter:off
887887
http
888-
.authorizeExchange((exchange) -> exchange
888+
.authorizeExchange((authorize) -> authorize
889889
.anyExchange().authenticated())
890890
.oauth2Login(withDefaults())
891891
.httpBasic(withDefaults());
@@ -954,7 +954,7 @@ static class OAuth2LoginMockAuthenticationManagerConfig {
954954
SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
955955
// @formatter:off
956956
http
957-
.authorizeExchange((exchange) -> exchange
957+
.authorizeExchange((authorize) -> authorize
958958
.anyExchange().authenticated())
959959
.oauth2Login((login) -> login
960960
.authenticationConverter(this.authenticationConverter)
@@ -986,7 +986,7 @@ static class OAuth2LoginMockAuthenticationManagerInLambdaConfig {
986986
SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
987987
// @formatter:off
988988
http
989-
.authorizeExchange((authorizeExchange) -> authorizeExchange
989+
.authorizeExchange((authorize) -> authorize
990990
.anyExchange().authenticated()
991991
)
992992
.oauth2Login((oauth2) -> oauth2
@@ -1024,7 +1024,7 @@ static class OAuth2LoginWithCustomBeansConfig {
10241024
SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
10251025
// @formatter:off
10261026
http
1027-
.authorizeExchange((exchange) -> exchange
1027+
.authorizeExchange((authorize) -> authorize
10281028
.anyExchange().authenticated())
10291029
.oauth2Login((login) -> login
10301030
.authenticationConverter(this.authenticationConverter)

config/src/test/java/org/springframework/security/config/web/server/OAuth2ResourceServerSpecTests.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ static class PublicKeyConfig {
682682
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
683683
// @formatter:off
684684
http
685-
.authorizeExchange((exchange) -> exchange
685+
.authorizeExchange((authorize) -> authorize
686686
.anyExchange().hasAuthority("SCOPE_message:read"))
687687
.oauth2ResourceServer((server) -> server
688688
.jwt((jwt) -> jwt.publicKey(publicKey())));
@@ -701,7 +701,7 @@ static class PublicKeyInLambdaConfig {
701701
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
702702
// @formatter:off
703703
http
704-
.authorizeExchange((authorizeExchange) -> authorizeExchange
704+
.authorizeExchange((authorize) -> authorize
705705
.anyExchange().hasAuthority("SCOPE_message:read")
706706
)
707707
.oauth2ResourceServer((oauth2) -> oauth2
@@ -727,7 +727,7 @@ static class PlaceholderConfig {
727727
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
728728
// @formatter:off
729729
http
730-
.authorizeExchange((exchange) -> exchange
730+
.authorizeExchange((authorize) -> authorize
731731
.anyExchange().hasAuthority("SCOPE_message:read"))
732732
.oauth2ResourceServer((server) -> server
733733
.jwt((jwt) -> jwt.publicKey(this.key)));
@@ -833,7 +833,7 @@ static class DenyAllConfig {
833833
SecurityWebFilterChain authorization(ServerHttpSecurity http) {
834834
// @formatter:off
835835
http
836-
.authorizeExchange((exchange) -> exchange
836+
.authorizeExchange((authorize) -> authorize
837837
.anyExchange().denyAll())
838838
.oauth2ResourceServer((server) -> server
839839
.jwt((jwt) -> jwt.publicKey(publicKey())));
@@ -899,7 +899,7 @@ static class CustomAuthenticationManagerResolverConfig {
899899
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
900900
// @formatter:off
901901
http
902-
.authorizeExchange((exchange) -> exchange
902+
.authorizeExchange((authorize) -> authorize
903903
.pathMatchers("/*/message/**").hasAnyAuthority("SCOPE_message:read"))
904904
.oauth2ResourceServer((server) -> server
905905
.authenticationManagerResolver(authenticationManagerResolver()));
@@ -957,7 +957,7 @@ static class CustomBearerTokenServerAuthenticationConverter {
957957
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
958958
// @formatter:off
959959
http
960-
.authorizeExchange((exchange) -> exchange
960+
.authorizeExchange((authorize) -> authorize
961961
.anyExchange().hasAuthority("SCOPE_message:read"))
962962
.oauth2ResourceServer((server) -> server
963963
.bearerTokenConverter(bearerTokenAuthenticationConverter())
@@ -983,7 +983,7 @@ static class CustomJwtAuthenticationConverterConfig {
983983
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
984984
// @formatter:off
985985
http
986-
.authorizeExchange((exchange) -> exchange
986+
.authorizeExchange((authorize) -> authorize
987987
.anyExchange().hasAuthority("message:read"))
988988
.oauth2ResourceServer((server) -> server
989989
.jwt((jwt) -> jwt
@@ -1014,7 +1014,7 @@ static class CustomErrorHandlingConfig {
10141014
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
10151015
// @formatter:off
10161016
http
1017-
.authorizeExchange((exchange) -> exchange
1017+
.authorizeExchange((authorize) -> authorize
10181018
.pathMatchers("/authenticated").authenticated()
10191019
.pathMatchers("/unobtainable").hasAuthority("unobtainable"))
10201020
.oauth2ResourceServer((server) -> server
@@ -1102,7 +1102,7 @@ static class AuthenticationManagerResolverPlusOtherConfig {
11021102
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
11031103
// @formatter:off
11041104
http
1105-
.authorizeExchange((exchange) -> exchange
1105+
.authorizeExchange((authorize) -> authorize
11061106
.anyExchange().authenticated())
11071107
.oauth2ResourceServer((server) -> server
11081108
.authenticationManagerResolver(mock(ReactiveAuthenticationManagerResolver.class))

0 commit comments

Comments
 (0)