mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-24 13:02:13 +00:00
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
This commit is contained in:
parent
da6c7b8759
commit
a4c338f8a5
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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())
|
||||
|
@ -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)
|
||||
|
@ -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))
|
||||
|
@ -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())
|
||||
|
@ -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();
|
||||
|
@ -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())
|
||||
)
|
||||
|
@ -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)
|
||||
|
@ -15,7 +15,7 @@ Java::
|
||||
@Bean
|
||||
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
||||
http
|
||||
.authorizeExchange((exchanges) -> exchanges
|
||||
.authorizeExchange((authorize) -> authorize
|
||||
.anyExchange().authenticated()
|
||||
)
|
||||
.httpBasic(withDefaults())
|
||||
|
@ -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())
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
@ -63,7 +63,7 @@ public class CustomX509Configuration {
|
||||
.principalExtractor(principalExtractor)
|
||||
.authenticationManager(authenticationManager)
|
||||
)
|
||||
.authorizeExchange((exchanges) -> exchanges
|
||||
.authorizeExchange((authorize) -> authorize
|
||||
.anyExchange().authenticated()
|
||||
);
|
||||
// @formatter:on
|
||||
|
@ -44,7 +44,7 @@ public class DefaultX509Configuration {
|
||||
// @formatter:off
|
||||
http
|
||||
.x509(Customizer.withDefaults())
|
||||
.authorizeExchange((exchanges) -> exchanges
|
||||
.authorizeExchange((authorize) -> authorize
|
||||
.anyExchange().authenticated()
|
||||
);
|
||||
// @formatter:on
|
||||
|
Loading…
x
Reference in New Issue
Block a user