From a4c338f8a517c332d2ce0cf2c4ccc62ef30793f2 Mon Sep 17 00:00:00 2001 From: Josh Cummings <3627351+jzheaux@users.noreply.github.com> Date: Thu, 19 Jun 2025 18:29:38 -0600 Subject: [PATCH] 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 --- .../reactive/WebFluxSecurityConfiguration.java | 2 +- .../config/web/server/ServerHttpSecurity.java | 2 +- .../reactive/EnableWebFluxSecurityTests.java | 2 +- .../ServerHttpSecurityConfigurationTests.java | 4 ++-- .../web/server/AuthorizeExchangeSpecTests.java | 12 ++++++------ .../web/server/ExceptionHandlingSpecTests.java | 12 ++++++------ .../config/web/server/FormLoginTests.java | 16 ++++++++-------- .../config/web/server/LogoutSpecTests.java | 10 +++++----- .../config/web/server/OAuth2LoginTests.java | 10 +++++----- .../server/OAuth2ResourceServerSpecTests.java | 18 +++++++++--------- .../config/web/server/RequestCacheTests.java | 6 +++--- .../web/server/ServerHttpSecurityTests.java | 8 ++++---- .../web/server/SessionManagementSpecTests.java | 10 +++++----- .../pages/reactive/authentication/logout.adoc | 4 ++-- .../authorization/authorize-http-requests.adoc | 2 +- .../pages/reactive/authorization/method.adoc | 2 +- .../pages/reactive/configuration/webflux.adoc | 6 +++--- .../reactive/oauth2/resource-server/jwt.adoc | 12 ++++++------ .../oauth2/resource-server/multitenancy.adoc | 4 ++-- .../oauth2/resource-server/opaque-token.adoc | 10 +++++----- .../reactivex509/CustomX509Configuration.java | 2 +- .../reactivex509/DefaultX509Configuration.java | 2 +- 22 files changed, 78 insertions(+), 78 deletions(-) diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/reactive/WebFluxSecurityConfiguration.java b/config/src/main/java/org/springframework/security/config/annotation/web/reactive/WebFluxSecurityConfiguration.java index 0afea13f5a..0187bb7e92 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/reactive/WebFluxSecurityConfiguration.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/reactive/WebFluxSecurityConfiguration.java @@ -123,7 +123,7 @@ class WebFluxSecurityConfiguration { * @return */ private SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { - http.authorizeExchange((exchange) -> exchange.anyExchange().authenticated()); + http.authorizeExchange((authorize) -> authorize.anyExchange().authenticated()); if (isOAuth2Present && OAuth2ClasspathGuard.shouldConfigure(this.context)) { OAuth2ClasspathGuard.configure(this.context, http); } diff --git a/config/src/main/java/org/springframework/security/config/web/server/ServerHttpSecurity.java b/config/src/main/java/org/springframework/security/config/web/server/ServerHttpSecurity.java index 3e93825f79..a46e7841b3 100644 --- a/config/src/main/java/org/springframework/security/config/web/server/ServerHttpSecurity.java +++ b/config/src/main/java/org/springframework/security/config/web/server/ServerHttpSecurity.java @@ -270,7 +270,7 @@ import org.springframework.web.util.pattern.PathPatternParser; * @Bean * public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { * http - * .authorizeExchange((exchange) -> exchange.anyExchange().authenticated()) + * .authorizeExchange((authorize) -> authorize.anyExchange().authenticated()) * .httpBasic(Customizer.withDefaults()) * .formLogin(); * return http.build(); diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/reactive/EnableWebFluxSecurityTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/reactive/EnableWebFluxSecurityTests.java index 7275ebf5d6..28e1787f43 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/reactive/EnableWebFluxSecurityTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/reactive/EnableWebFluxSecurityTests.java @@ -377,7 +377,7 @@ public class EnableWebFluxSecurityTests { @Bean SecurityWebFilterChain apiHttpSecurity(ServerHttpSecurity http) { http.securityMatcher(new PathPatternParserServerWebExchangeMatcher("/api/**")) - .authorizeExchange((exchange) -> exchange.anyExchange().denyAll()); + .authorizeExchange((authorize) -> authorize.anyExchange().denyAll()); return http.build(); } diff --git a/config/src/test/java/org/springframework/security/config/annotation/web/reactive/ServerHttpSecurityConfigurationTests.java b/config/src/test/java/org/springframework/security/config/annotation/web/reactive/ServerHttpSecurityConfigurationTests.java index 4129702b34..5d56a97012 100644 --- a/config/src/test/java/org/springframework/security/config/annotation/web/reactive/ServerHttpSecurityConfigurationTests.java +++ b/config/src/test/java/org/springframework/security/config/annotation/web/reactive/ServerHttpSecurityConfigurationTests.java @@ -281,7 +281,7 @@ public class ServerHttpSecurityConfigurationTests { SecurityWebFilterChain filterChain(ServerHttpSecurity http) { // @formatter:off http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated() ) .formLogin(Customizer.withDefaults()); @@ -300,7 +300,7 @@ public class ServerHttpSecurityConfigurationTests { SecurityWebFilterChain filterChain(ServerHttpSecurity http) { // @formatter:off http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated() ) .formLogin((form) -> form diff --git a/config/src/test/java/org/springframework/security/config/web/server/AuthorizeExchangeSpecTests.java b/config/src/test/java/org/springframework/security/config/web/server/AuthorizeExchangeSpecTests.java index b4e4839359..658f5666d7 100644 --- a/config/src/test/java/org/springframework/security/config/web/server/AuthorizeExchangeSpecTests.java +++ b/config/src/test/java/org/springframework/security/config/web/server/AuthorizeExchangeSpecTests.java @@ -89,7 +89,7 @@ public class AuthorizeExchangeSpecTests { @Test public void antMatchersWhenPatternsInLambdaThenAnyMethod() { this.http.csrf(ServerHttpSecurity.CsrfSpec::disable) - .authorizeExchange((exchanges) -> exchanges.pathMatchers("/a", "/b").denyAll().anyExchange().permitAll()); + .authorizeExchange((authorize) -> authorize.pathMatchers("/a", "/b").denyAll().anyExchange().permitAll()); WebTestClient client = buildClient(); // @formatter:off client.get() @@ -113,16 +113,16 @@ public class AuthorizeExchangeSpecTests { @Test public void antMatchersWhenNoAccessAndAnotherMatcherThenThrowsException() { - this.http.authorizeExchange((exchange) -> exchange.pathMatchers("/incomplete")); + this.http.authorizeExchange((authorize) -> authorize.pathMatchers("/incomplete")); assertThatIllegalStateException() - .isThrownBy(() -> this.http.authorizeExchange((exchange) -> exchange.pathMatchers("/throws-exception"))); + .isThrownBy(() -> this.http.authorizeExchange((authorize) -> authorize.pathMatchers("/throws-exception"))); } @Test public void anyExchangeWhenFollowedByMatcherThenThrowsException() { assertThatIllegalStateException().isThrownBy(() -> // @formatter:off - this.http.authorizeExchange((exchange) -> exchange + this.http.authorizeExchange((authorize) -> authorize .anyExchange().denyAll() .pathMatchers("/never-reached")) // @formatter:on @@ -131,13 +131,13 @@ public class AuthorizeExchangeSpecTests { @Test public void buildWhenMatcherDefinedWithNoAccessThenThrowsException() { - this.http.authorizeExchange((exchange) -> exchange.pathMatchers("/incomplete")); + this.http.authorizeExchange((authorize) -> authorize.pathMatchers("/incomplete")); assertThatIllegalStateException().isThrownBy(this.http::build); } @Test public void buildWhenMatcherDefinedWithNoAccessInLambdaThenThrowsException() { - this.http.authorizeExchange((exchanges) -> exchanges.pathMatchers("/incomplete")); + this.http.authorizeExchange((authorize) -> authorize.pathMatchers("/incomplete")); assertThatIllegalStateException().isThrownBy(this.http::build); } diff --git a/config/src/test/java/org/springframework/security/config/web/server/ExceptionHandlingSpecTests.java b/config/src/test/java/org/springframework/security/config/web/server/ExceptionHandlingSpecTests.java index cc38649dc3..e99cd5c5d2 100644 --- a/config/src/test/java/org/springframework/security/config/web/server/ExceptionHandlingSpecTests.java +++ b/config/src/test/java/org/springframework/security/config/web/server/ExceptionHandlingSpecTests.java @@ -63,7 +63,7 @@ public class ExceptionHandlingSpecTests { public void requestWhenExceptionHandlingWithDefaultsInLambdaThenDefaultAuthenticationEntryPointUsed() { // @formatter:off SecurityWebFilterChain securityWebFilter = this.http - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated() ) .exceptionHandling(withDefaults()) @@ -104,7 +104,7 @@ public class ExceptionHandlingSpecTests { public void requestWhenCustomAuthenticationEntryPointInLambdaThenCustomAuthenticationEntryPointUsed() { // @formatter:off SecurityWebFilterChain securityWebFilter = this.http - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated() ) .exceptionHandling((exceptionHandling) -> exceptionHandling @@ -128,7 +128,7 @@ public class ExceptionHandlingSpecTests { SecurityWebFilterChain securityWebFilter = this.http .csrf((csrf) -> csrf.disable()) .httpBasic(Customizer.withDefaults()) - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().hasRole("ADMIN")) .exceptionHandling(withDefaults()) .build(); @@ -148,7 +148,7 @@ public class ExceptionHandlingSpecTests { // @formatter:off SecurityWebFilterChain securityWebFilter = this.http .httpBasic(withDefaults()) - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .anyExchange().hasRole("ADMIN") ) .exceptionHandling(withDefaults()) @@ -170,7 +170,7 @@ public class ExceptionHandlingSpecTests { SecurityWebFilterChain securityWebFilter = this.http .csrf((csrf) -> csrf.disable()) .httpBasic(Customizer.withDefaults()) - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().hasRole("ADMIN")) .exceptionHandling((handling) -> handling .accessDeniedHandler(httpStatusServerAccessDeniedHandler(HttpStatus.BAD_REQUEST))) @@ -191,7 +191,7 @@ public class ExceptionHandlingSpecTests { // @formatter:off SecurityWebFilterChain securityWebFilter = this.http .httpBasic(withDefaults()) - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .anyExchange().hasRole("ADMIN") ) .exceptionHandling((exceptionHandling) -> exceptionHandling diff --git a/config/src/test/java/org/springframework/security/config/web/server/FormLoginTests.java b/config/src/test/java/org/springframework/security/config/web/server/FormLoginTests.java index 1fef14dbac..a770ff69c0 100644 --- a/config/src/test/java/org/springframework/security/config/web/server/FormLoginTests.java +++ b/config/src/test/java/org/springframework/security/config/web/server/FormLoginTests.java @@ -69,7 +69,7 @@ public class FormLoginTests { public void defaultLoginPage() { // @formatter:off SecurityWebFilterChain securityWebFilter = this.http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated()) .formLogin(withDefaults()) .build(); @@ -100,7 +100,7 @@ public class FormLoginTests { @Test public void formLoginWhenDefaultsInLambdaThenCreatesDefaultLoginPage() { SecurityWebFilterChain securityWebFilter = this.http - .authorizeExchange((exchanges) -> exchanges.anyExchange().authenticated()) + .authorizeExchange((authorize) -> authorize.anyExchange().authenticated()) .formLogin(withDefaults()) .build(); WebTestClient webTestClient = WebTestClientBuilder.bindToWebFilters(securityWebFilter).build(); @@ -127,7 +127,7 @@ public class FormLoginTests { public void customLoginPage() { // @formatter:off SecurityWebFilterChain securityWebFilter = this.http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .pathMatchers("/login").permitAll() .anyExchange().authenticated()) .formLogin((login) -> login @@ -155,7 +155,7 @@ public class FormLoginTests { public void formLoginWhenCustomLoginPageInLambdaThenUsed() { // @formatter:off SecurityWebFilterChain securityWebFilter = this.http - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .pathMatchers("/login").permitAll() .anyExchange().authenticated() ) @@ -185,7 +185,7 @@ public class FormLoginTests { public void formLoginWhenCustomAuthenticationFailureHandlerThenUsed() { // @formatter:off SecurityWebFilterChain securityWebFilter = this.http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .pathMatchers("/login", "/failure").permitAll() .anyExchange().authenticated()) .formLogin((login) -> login @@ -212,7 +212,7 @@ public class FormLoginTests { public void formLoginWhenCustomRequiresAuthenticationMatcherThenUsed() { // @formatter:off SecurityWebFilterChain securityWebFilter = this.http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .pathMatchers("/login", "/sign-in").permitAll() .anyExchange().authenticated()) .formLogin((login) -> login @@ -233,7 +233,7 @@ public class FormLoginTests { public void authenticationSuccess() { // @formatter:off SecurityWebFilterChain securityWebFilter = this.http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated()) .formLogin((login) -> login .authenticationSuccessHandler(new RedirectServerAuthenticationSuccessHandler("/custom"))) @@ -298,7 +298,7 @@ public class FormLoginTests { given(formLoginSecContextRepository.load(any())).willReturn(authentication(token)); // @formatter:off SecurityWebFilterChain securityWebFilter = this.http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated()) .securityContextRepository(defaultSecContextRepository) .formLogin((login) -> login diff --git a/config/src/test/java/org/springframework/security/config/web/server/LogoutSpecTests.java b/config/src/test/java/org/springframework/security/config/web/server/LogoutSpecTests.java index 22912a2a1d..b4cb5e7d32 100644 --- a/config/src/test/java/org/springframework/security/config/web/server/LogoutSpecTests.java +++ b/config/src/test/java/org/springframework/security/config/web/server/LogoutSpecTests.java @@ -44,7 +44,7 @@ public class LogoutSpecTests { public void defaultLogout() { // @formatter:off SecurityWebFilterChain securityWebFilter = this.http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated()) .formLogin(withDefaults()) .build(); @@ -78,7 +78,7 @@ public class LogoutSpecTests { public void customLogout() { // @formatter:off SecurityWebFilterChain securityWebFilter = this.http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated()) .formLogin(withDefaults()) .logout((logout) -> logout @@ -114,7 +114,7 @@ public class LogoutSpecTests { public void logoutWhenCustomLogoutInLambdaThenCustomLogoutUsed() { // @formatter:off SecurityWebFilterChain securityWebFilter = this.http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated() ) .formLogin(withDefaults()) @@ -151,7 +151,7 @@ public class LogoutSpecTests { public void logoutWhenDisabledThenDefaultLogoutPageDoesNotExist() { // @formatter:off SecurityWebFilterChain securityWebFilter = this.http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated()) .formLogin(withDefaults()) .logout((logout) -> logout.disable()) @@ -184,7 +184,7 @@ public class LogoutSpecTests { // @formatter:off SecurityWebFilterChain securityWebFilter = this.http .securityContextRepository(repository) - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated()) .formLogin(withDefaults()) .logout(withDefaults()) diff --git a/config/src/test/java/org/springframework/security/config/web/server/OAuth2LoginTests.java b/config/src/test/java/org/springframework/security/config/web/server/OAuth2LoginTests.java index 33efb51810..fc158311b4 100644 --- a/config/src/test/java/org/springframework/security/config/web/server/OAuth2LoginTests.java +++ b/config/src/test/java/org/springframework/security/config/web/server/OAuth2LoginTests.java @@ -863,7 +863,7 @@ public class OAuth2LoginTests { http.authenticationManager(authenticationManager); // @formatter:off http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated()) .oauth2Login(withDefaults()) .formLogin(withDefaults()); @@ -885,7 +885,7 @@ public class OAuth2LoginTests { http.authenticationManager(authenticationManager); // @formatter:off http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated()) .oauth2Login(withDefaults()) .httpBasic(withDefaults()); @@ -954,7 +954,7 @@ public class OAuth2LoginTests { SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) { // @formatter:off http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated()) .oauth2Login((login) -> login .authenticationConverter(this.authenticationConverter) @@ -986,7 +986,7 @@ public class OAuth2LoginTests { SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) { // @formatter:off http - .authorizeExchange((authorizeExchange) -> authorizeExchange + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated() ) .oauth2Login((oauth2) -> oauth2 @@ -1024,7 +1024,7 @@ public class OAuth2LoginTests { SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) { // @formatter:off http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated()) .oauth2Login((login) -> login .authenticationConverter(this.authenticationConverter) diff --git a/config/src/test/java/org/springframework/security/config/web/server/OAuth2ResourceServerSpecTests.java b/config/src/test/java/org/springframework/security/config/web/server/OAuth2ResourceServerSpecTests.java index 7c8fd3a427..ad44d3372d 100644 --- a/config/src/test/java/org/springframework/security/config/web/server/OAuth2ResourceServerSpecTests.java +++ b/config/src/test/java/org/springframework/security/config/web/server/OAuth2ResourceServerSpecTests.java @@ -682,7 +682,7 @@ public class OAuth2ResourceServerSpecTests { SecurityWebFilterChain springSecurity(ServerHttpSecurity http) { // @formatter:off http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().hasAuthority("SCOPE_message:read")) .oauth2ResourceServer((server) -> server .jwt((jwt) -> jwt.publicKey(publicKey()))); @@ -701,7 +701,7 @@ public class OAuth2ResourceServerSpecTests { SecurityWebFilterChain springSecurity(ServerHttpSecurity http) { // @formatter:off http - .authorizeExchange((authorizeExchange) -> authorizeExchange + .authorizeExchange((authorize) -> authorize .anyExchange().hasAuthority("SCOPE_message:read") ) .oauth2ResourceServer((oauth2) -> oauth2 @@ -727,7 +727,7 @@ public class OAuth2ResourceServerSpecTests { SecurityWebFilterChain springSecurity(ServerHttpSecurity http) { // @formatter:off http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().hasAuthority("SCOPE_message:read")) .oauth2ResourceServer((server) -> server .jwt((jwt) -> jwt.publicKey(this.key))); @@ -833,7 +833,7 @@ public class OAuth2ResourceServerSpecTests { SecurityWebFilterChain authorization(ServerHttpSecurity http) { // @formatter:off http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().denyAll()) .oauth2ResourceServer((server) -> server .jwt((jwt) -> jwt.publicKey(publicKey()))); @@ -899,7 +899,7 @@ public class OAuth2ResourceServerSpecTests { SecurityWebFilterChain springSecurity(ServerHttpSecurity http) { // @formatter:off http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .pathMatchers("/*/message/**").hasAnyAuthority("SCOPE_message:read")) .oauth2ResourceServer((server) -> server .authenticationManagerResolver(authenticationManagerResolver())); @@ -957,7 +957,7 @@ public class OAuth2ResourceServerSpecTests { SecurityWebFilterChain springSecurity(ServerHttpSecurity http) { // @formatter:off http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().hasAuthority("SCOPE_message:read")) .oauth2ResourceServer((server) -> server .bearerTokenConverter(bearerTokenAuthenticationConverter()) @@ -983,7 +983,7 @@ public class OAuth2ResourceServerSpecTests { SecurityWebFilterChain springSecurity(ServerHttpSecurity http) { // @formatter:off http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().hasAuthority("message:read")) .oauth2ResourceServer((server) -> server .jwt((jwt) -> jwt @@ -1014,7 +1014,7 @@ public class OAuth2ResourceServerSpecTests { SecurityWebFilterChain springSecurity(ServerHttpSecurity http) { // @formatter:off http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .pathMatchers("/authenticated").authenticated() .pathMatchers("/unobtainable").hasAuthority("unobtainable")) .oauth2ResourceServer((server) -> server @@ -1102,7 +1102,7 @@ public class OAuth2ResourceServerSpecTests { SecurityWebFilterChain springSecurity(ServerHttpSecurity http) { // @formatter:off http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated()) .oauth2ResourceServer((server) -> server .authenticationManagerResolver(mock(ReactiveAuthenticationManagerResolver.class)) diff --git a/config/src/test/java/org/springframework/security/config/web/server/RequestCacheTests.java b/config/src/test/java/org/springframework/security/config/web/server/RequestCacheTests.java index de9c5d4427..9c7aef9306 100644 --- a/config/src/test/java/org/springframework/security/config/web/server/RequestCacheTests.java +++ b/config/src/test/java/org/springframework/security/config/web/server/RequestCacheTests.java @@ -49,7 +49,7 @@ public class RequestCacheTests { public void defaultFormLoginRequestCache() { // @formatter:off SecurityWebFilterChain securityWebFilter = this.http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated()) .formLogin(withDefaults()) .build(); @@ -75,7 +75,7 @@ public class RequestCacheTests { public void requestCacheNoOp() { // @formatter:off SecurityWebFilterChain securityWebFilter = this.http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated()) .formLogin(withDefaults()) .requestCache((cache) -> cache @@ -103,7 +103,7 @@ public class RequestCacheTests { public void requestWhenCustomRequestCacheInLambdaThenCustomCacheUsed() { // @formatter:off SecurityWebFilterChain securityWebFilter = this.http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated() ) .formLogin(withDefaults()) diff --git a/config/src/test/java/org/springframework/security/config/web/server/ServerHttpSecurityTests.java b/config/src/test/java/org/springframework/security/config/web/server/ServerHttpSecurityTests.java index 7521d5925f..0aedcb2de8 100644 --- a/config/src/test/java/org/springframework/security/config/web/server/ServerHttpSecurityTests.java +++ b/config/src/test/java/org/springframework/security/config/web/server/ServerHttpSecurityTests.java @@ -191,7 +191,7 @@ public class ServerHttpSecurityTests { @Test public void basicWhenNoCredentialsThenUnauthorized() { - this.http.authorizeExchange((exchange) -> exchange.anyExchange().authenticated()); + this.http.authorizeExchange((authorize) -> authorize.anyExchange().authenticated()); WebTestClient client = buildClient(); // @formatter:off client.get().uri("/") @@ -207,7 +207,7 @@ public class ServerHttpSecurityTests { ServerAuthenticationEntryPoint authenticationEntryPoint = spy( new HttpStatusServerEntryPoint(HttpStatus.UNAUTHORIZED)); this.http.httpBasic((basic) -> basic.authenticationEntryPoint(authenticationEntryPoint)); - this.http.authorizeExchange((exchange) -> exchange.anyExchange().authenticated()); + this.http.authorizeExchange((authorize) -> authorize.anyExchange().authenticated()); WebTestClient client = buildClient(); // @formatter:off client.get().uri("/") @@ -228,7 +228,7 @@ public class ServerHttpSecurityTests { ServerAuthenticationFailureHandler.class); this.http.httpBasic((basic) -> basic.authenticationFailureHandler(authenticationFailureHandler)); this.http.httpBasic((basic) -> basic.authenticationManager(authenticationManager)); - this.http.authorizeExchange((exchange) -> exchange.anyExchange().authenticated()); + this.http.authorizeExchange((authorize) -> authorize.anyExchange().authenticated()); given(authenticationManager.authenticate(any())) .willReturn(Mono.error(() -> new BadCredentialsException("bad"))); given(authenticationFailureHandler.onAuthenticationFailure(any(), any())).willReturn(Mono.empty()); @@ -596,7 +596,7 @@ public class ServerHttpSecurityTests { ReactiveClientRegistrationRepository.class); SecurityWebFilterChain securityFilterChain = this.http .oauth2Login((login) -> login.clientRegistrationRepository(clientRegistrationRepository)) - .authorizeExchange((exchange) -> exchange.anyExchange().authenticated()) + .authorizeExchange((authorize) -> authorize.anyExchange().authenticated()) .requestCache((c) -> c.requestCache(requestCache)) .build(); WebTestClient client = WebTestClientBuilder.bindToWebFilters(securityFilterChain).build(); diff --git a/config/src/test/java/org/springframework/security/config/web/server/SessionManagementSpecTests.java b/config/src/test/java/org/springframework/security/config/web/server/SessionManagementSpecTests.java index 1a380bb6e3..2277351408 100644 --- a/config/src/test/java/org/springframework/security/config/web/server/SessionManagementSpecTests.java +++ b/config/src/test/java/org/springframework/security/config/web/server/SessionManagementSpecTests.java @@ -418,7 +418,7 @@ public class SessionManagementSpecTests { SecurityWebFilterChain springSecurity(ServerHttpSecurity http) { // @formatter:off http - .authorizeExchange((exchanges) -> exchanges.anyExchange().authenticated()) + .authorizeExchange((authorize) -> authorize.anyExchange().authenticated()) .formLogin(Customizer.withDefaults()) .sessionManagement((sessionManagement) -> sessionManagement .concurrentSessions((concurrentSessions) -> concurrentSessions @@ -453,7 +453,7 @@ public class SessionManagementSpecTests { DefaultWebSessionManager webSessionManager) { // @formatter:off http - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated() ) .oauth2Login((oauth2Login) -> oauth2Login @@ -493,7 +493,7 @@ public class SessionManagementSpecTests { SecurityWebFilterChain springSecurity(ServerHttpSecurity http) { // @formatter:off http - .authorizeExchange((exchanges) -> exchanges.anyExchange().authenticated()) + .authorizeExchange((authorize) -> authorize.anyExchange().authenticated()) .formLogin(Customizer.withDefaults()) .sessionManagement((sessionManagement) -> sessionManagement .concurrentSessions((concurrentSessions) -> concurrentSessions @@ -516,7 +516,7 @@ public class SessionManagementSpecTests { SecurityWebFilterChain springSecurity(ServerHttpSecurity http) { // @formatter:off http - .authorizeExchange((exchanges) -> exchanges.anyExchange().authenticated()) + .authorizeExchange((authorize) -> authorize.anyExchange().authenticated()) .formLogin((login) -> login .authenticationSuccessHandler(new RedirectServerAuthenticationSuccessHandler("/")) ) @@ -542,7 +542,7 @@ public class SessionManagementSpecTests { SecurityWebFilterChain springSecurity(ServerHttpSecurity http) { // @formatter:off http - .authorizeExchange((exchanges) -> exchanges.anyExchange().authenticated()) + .authorizeExchange((authorize) -> authorize.anyExchange().authenticated()) .httpBasic((basic) -> basic .securityContextRepository(new WebSessionServerSecurityContextRepository()) ) diff --git a/docs/modules/ROOT/pages/reactive/authentication/logout.adoc b/docs/modules/ROOT/pages/reactive/authentication/logout.adoc index 26fed89b69..c89fc400ed 100644 --- a/docs/modules/ROOT/pages/reactive/authentication/logout.adoc +++ b/docs/modules/ROOT/pages/reactive/authentication/logout.adoc @@ -24,7 +24,7 @@ SecurityWebFilterChain http(ServerHttpSecurity http) throws Exception { ); http - .authorizeExchange((exchange) -> exchange.anyExchange().authenticated()) + .authorizeExchange((authorize) -> authorize.anyExchange().authenticated()) .logout((logout) -> logout.logoutHandler(logoutHandler)); return http.build(); @@ -40,7 +40,7 @@ fun http(http: ServerHttpSecurity): SecurityWebFilterChain { val customLogoutHandler = DelegatingServerLogoutHandler( SecurityContextServerLogoutHandler(), WebSessionServerLogoutHandler() ) - + return http { authorizeExchange { authorize(anyExchange, authenticated) diff --git a/docs/modules/ROOT/pages/reactive/authorization/authorize-http-requests.adoc b/docs/modules/ROOT/pages/reactive/authorization/authorize-http-requests.adoc index 21f678acf0..b9226e86e4 100644 --- a/docs/modules/ROOT/pages/reactive/authorization/authorize-http-requests.adoc +++ b/docs/modules/ROOT/pages/reactive/authorization/authorize-http-requests.adoc @@ -15,7 +15,7 @@ Java:: @Bean SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { http - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated() ) .httpBasic(withDefaults()) diff --git a/docs/modules/ROOT/pages/reactive/authorization/method.adoc b/docs/modules/ROOT/pages/reactive/authorization/method.adoc index ebc83eef0a..95d0f91af1 100644 --- a/docs/modules/ROOT/pages/reactive/authorization/method.adoc +++ b/docs/modules/ROOT/pages/reactive/authorization/method.adoc @@ -614,7 +614,7 @@ public class SecurityConfig { return http // Demonstrate that method security works // Best practice to use both for defense in depth - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .anyExchange().permitAll() ) .httpBasic(withDefaults()) diff --git a/docs/modules/ROOT/pages/reactive/configuration/webflux.adoc b/docs/modules/ROOT/pages/reactive/configuration/webflux.adoc index 158605ec42..ad17e3093a 100644 --- a/docs/modules/ROOT/pages/reactive/configuration/webflux.adoc +++ b/docs/modules/ROOT/pages/reactive/configuration/webflux.adoc @@ -87,7 +87,7 @@ public class HelloWebfluxSecurityConfig { @Bean public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { http - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated() ) .httpBasic(withDefaults()) @@ -161,7 +161,7 @@ static class MultiSecurityHttpConfig { SecurityWebFilterChain apiHttpSecurity(ServerHttpSecurity http) { http .securityMatcher(new PathPatternParserServerWebExchangeMatcher("/api/**")) <2> - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated() ) .oauth2ResourceServer(OAuth2ResourceServerSpec::jwt); <3> @@ -171,7 +171,7 @@ static class MultiSecurityHttpConfig { @Bean SecurityWebFilterChain webHttpSecurity(ServerHttpSecurity http) { <4> http - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated() ) .httpBasic(withDefaults()); <5> diff --git a/docs/modules/ROOT/pages/reactive/oauth2/resource-server/jwt.adoc b/docs/modules/ROOT/pages/reactive/oauth2/resource-server/jwt.adoc index 0d404deb79..7858d29fbe 100644 --- a/docs/modules/ROOT/pages/reactive/oauth2/resource-server/jwt.adoc +++ b/docs/modules/ROOT/pages/reactive/oauth2/resource-server/jwt.adoc @@ -128,7 +128,7 @@ Java:: @Bean SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { http - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated() ) .oauth2ResourceServer(OAuth2ResourceServerSpec::jwt) @@ -170,7 +170,7 @@ import static org.springframework.security.oauth2.core.authorization.OAuth2React @Bean SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { http - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .pathMatchers("/message/**").access(hasScope("message:read")) .anyExchange().authenticated() ) @@ -254,7 +254,7 @@ Java:: @Bean SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { http - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated() ) .oauth2ResourceServer((oauth2) -> oauth2 @@ -302,7 +302,7 @@ Java:: @Bean SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { http - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated() ) .oauth2ResourceServer((oauth2) -> oauth2 @@ -691,7 +691,7 @@ import static org.springframework.security.oauth2.core.authorization.OAuth2React @Bean SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { http - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .mvcMatchers("/contacts/**").access(hasScope("contacts")) .mvcMatchers("/messages/**").access(hasScope("messages")) .anyExchange().authenticated() @@ -762,7 +762,7 @@ Java:: @Bean SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { http - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated() ) .oauth2ResourceServer((oauth2) -> oauth2 diff --git a/docs/modules/ROOT/pages/reactive/oauth2/resource-server/multitenancy.adoc b/docs/modules/ROOT/pages/reactive/oauth2/resource-server/multitenancy.adoc index b1353c8cf9..82b1360bef 100644 --- a/docs/modules/ROOT/pages/reactive/oauth2/resource-server/multitenancy.adoc +++ b/docs/modules/ROOT/pages/reactive/oauth2/resource-server/multitenancy.adoc @@ -27,7 +27,7 @@ JwtIssuerReactiveAuthenticationManagerResolver authenticationManagerResolver = J .fromTrustedIssuers("https://idp.example.org/issuerOne", "https://idp.example.org/issuerTwo"); http - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated() ) .oauth2ResourceServer((oauth2) -> oauth2 @@ -83,7 +83,7 @@ JwtIssuerReactiveAuthenticationManagerResolver authenticationManagerResolver = new JwtIssuerReactiveAuthenticationManagerResolver(authenticationManagers::get); http - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated() ) .oauth2ResourceServer((oauth2) -> oauth2 diff --git a/docs/modules/ROOT/pages/reactive/oauth2/resource-server/opaque-token.adoc b/docs/modules/ROOT/pages/reactive/oauth2/resource-server/opaque-token.adoc index 1293acf8ae..3d3258a831 100644 --- a/docs/modules/ROOT/pages/reactive/oauth2/resource-server/opaque-token.adoc +++ b/docs/modules/ROOT/pages/reactive/oauth2/resource-server/opaque-token.adoc @@ -176,7 +176,7 @@ Java:: @Bean SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { http - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated() ) .oauth2ResourceServer(ServerHttpSecurity.OAuth2ResourceServerSpec::opaqueToken) @@ -221,7 +221,7 @@ public class MyCustomSecurityConfiguration { @Bean SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { http - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .pathMatchers("/messages/**").access(hasScope("message:read")) .anyExchange().authenticated() ) @@ -310,7 +310,7 @@ public class DirectlyConfiguredIntrospectionUri { @Bean SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { http - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated() ) .oauth2ResourceServer((oauth2) -> oauth2 @@ -364,7 +364,7 @@ public class DirectlyConfiguredIntrospector { @Bean SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { http - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated() ) .oauth2ResourceServer((oauth2) -> oauth2 @@ -457,7 +457,7 @@ public class MappedAuthorities { @Bean SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { http - .authorizeExchange((exchange) -> exchange + .authorizeExchange((authorize) -> authorize .pathMatchers("/contacts/**").access(hasScope("contacts")) .pathMatchers("/messages/**").access(hasScope("messages")) .anyExchange().authenticated() diff --git a/docs/src/test/java/org/springframework/security/docs/reactive/authentication/reactivex509/CustomX509Configuration.java b/docs/src/test/java/org/springframework/security/docs/reactive/authentication/reactivex509/CustomX509Configuration.java index 45679a2ab9..979179488d 100644 --- a/docs/src/test/java/org/springframework/security/docs/reactive/authentication/reactivex509/CustomX509Configuration.java +++ b/docs/src/test/java/org/springframework/security/docs/reactive/authentication/reactivex509/CustomX509Configuration.java @@ -63,7 +63,7 @@ public class CustomX509Configuration { .principalExtractor(principalExtractor) .authenticationManager(authenticationManager) ) - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated() ); // @formatter:on diff --git a/docs/src/test/java/org/springframework/security/docs/reactive/authentication/reactivex509/DefaultX509Configuration.java b/docs/src/test/java/org/springframework/security/docs/reactive/authentication/reactivex509/DefaultX509Configuration.java index ea0f34ddc3..15e6562a72 100644 --- a/docs/src/test/java/org/springframework/security/docs/reactive/authentication/reactivex509/DefaultX509Configuration.java +++ b/docs/src/test/java/org/springframework/security/docs/reactive/authentication/reactivex509/DefaultX509Configuration.java @@ -44,7 +44,7 @@ public class DefaultX509Configuration { // @formatter:off http .x509(Customizer.withDefaults()) - .authorizeExchange((exchanges) -> exchanges + .authorizeExchange((authorize) -> authorize .anyExchange().authenticated() ); // @formatter:on