mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-24 21:12:18 +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
|
* @return
|
||||||
*/
|
*/
|
||||||
private SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
private SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
||||||
http.authorizeExchange((exchange) -> exchange.anyExchange().authenticated());
|
http.authorizeExchange((authorize) -> authorize.anyExchange().authenticated());
|
||||||
if (isOAuth2Present && OAuth2ClasspathGuard.shouldConfigure(this.context)) {
|
if (isOAuth2Present && OAuth2ClasspathGuard.shouldConfigure(this.context)) {
|
||||||
OAuth2ClasspathGuard.configure(this.context, http);
|
OAuth2ClasspathGuard.configure(this.context, http);
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ import org.springframework.web.util.pattern.PathPatternParser;
|
|||||||
* @Bean
|
* @Bean
|
||||||
* public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
* public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
||||||
* http
|
* http
|
||||||
* .authorizeExchange((exchange) -> exchange.anyExchange().authenticated())
|
* .authorizeExchange((authorize) -> authorize.anyExchange().authenticated())
|
||||||
* .httpBasic(Customizer.withDefaults())
|
* .httpBasic(Customizer.withDefaults())
|
||||||
* .formLogin();
|
* .formLogin();
|
||||||
* return http.build();
|
* return http.build();
|
||||||
|
@ -377,7 +377,7 @@ public class EnableWebFluxSecurityTests {
|
|||||||
@Bean
|
@Bean
|
||||||
SecurityWebFilterChain apiHttpSecurity(ServerHttpSecurity http) {
|
SecurityWebFilterChain apiHttpSecurity(ServerHttpSecurity http) {
|
||||||
http.securityMatcher(new PathPatternParserServerWebExchangeMatcher("/api/**"))
|
http.securityMatcher(new PathPatternParserServerWebExchangeMatcher("/api/**"))
|
||||||
.authorizeExchange((exchange) -> exchange.anyExchange().denyAll());
|
.authorizeExchange((authorize) -> authorize.anyExchange().denyAll());
|
||||||
return http.build();
|
return http.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ public class ServerHttpSecurityConfigurationTests {
|
|||||||
SecurityWebFilterChain filterChain(ServerHttpSecurity http) {
|
SecurityWebFilterChain filterChain(ServerHttpSecurity http) {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
)
|
)
|
||||||
.formLogin(Customizer.withDefaults());
|
.formLogin(Customizer.withDefaults());
|
||||||
@ -300,7 +300,7 @@ public class ServerHttpSecurityConfigurationTests {
|
|||||||
SecurityWebFilterChain filterChain(ServerHttpSecurity http) {
|
SecurityWebFilterChain filterChain(ServerHttpSecurity http) {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
)
|
)
|
||||||
.formLogin((form) -> form
|
.formLogin((form) -> form
|
||||||
|
@ -89,7 +89,7 @@ public class AuthorizeExchangeSpecTests {
|
|||||||
@Test
|
@Test
|
||||||
public void antMatchersWhenPatternsInLambdaThenAnyMethod() {
|
public void antMatchersWhenPatternsInLambdaThenAnyMethod() {
|
||||||
this.http.csrf(ServerHttpSecurity.CsrfSpec::disable)
|
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();
|
WebTestClient client = buildClient();
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
client.get()
|
client.get()
|
||||||
@ -113,16 +113,16 @@ public class AuthorizeExchangeSpecTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void antMatchersWhenNoAccessAndAnotherMatcherThenThrowsException() {
|
public void antMatchersWhenNoAccessAndAnotherMatcherThenThrowsException() {
|
||||||
this.http.authorizeExchange((exchange) -> exchange.pathMatchers("/incomplete"));
|
this.http.authorizeExchange((authorize) -> authorize.pathMatchers("/incomplete"));
|
||||||
assertThatIllegalStateException()
|
assertThatIllegalStateException()
|
||||||
.isThrownBy(() -> this.http.authorizeExchange((exchange) -> exchange.pathMatchers("/throws-exception")));
|
.isThrownBy(() -> this.http.authorizeExchange((authorize) -> authorize.pathMatchers("/throws-exception")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void anyExchangeWhenFollowedByMatcherThenThrowsException() {
|
public void anyExchangeWhenFollowedByMatcherThenThrowsException() {
|
||||||
assertThatIllegalStateException().isThrownBy(() ->
|
assertThatIllegalStateException().isThrownBy(() ->
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
this.http.authorizeExchange((exchange) -> exchange
|
this.http.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().denyAll()
|
.anyExchange().denyAll()
|
||||||
.pathMatchers("/never-reached"))
|
.pathMatchers("/never-reached"))
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
@ -131,13 +131,13 @@ public class AuthorizeExchangeSpecTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void buildWhenMatcherDefinedWithNoAccessThenThrowsException() {
|
public void buildWhenMatcherDefinedWithNoAccessThenThrowsException() {
|
||||||
this.http.authorizeExchange((exchange) -> exchange.pathMatchers("/incomplete"));
|
this.http.authorizeExchange((authorize) -> authorize.pathMatchers("/incomplete"));
|
||||||
assertThatIllegalStateException().isThrownBy(this.http::build);
|
assertThatIllegalStateException().isThrownBy(this.http::build);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void buildWhenMatcherDefinedWithNoAccessInLambdaThenThrowsException() {
|
public void buildWhenMatcherDefinedWithNoAccessInLambdaThenThrowsException() {
|
||||||
this.http.authorizeExchange((exchanges) -> exchanges.pathMatchers("/incomplete"));
|
this.http.authorizeExchange((authorize) -> authorize.pathMatchers("/incomplete"));
|
||||||
assertThatIllegalStateException().isThrownBy(this.http::build);
|
assertThatIllegalStateException().isThrownBy(this.http::build);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ public class ExceptionHandlingSpecTests {
|
|||||||
public void requestWhenExceptionHandlingWithDefaultsInLambdaThenDefaultAuthenticationEntryPointUsed() {
|
public void requestWhenExceptionHandlingWithDefaultsInLambdaThenDefaultAuthenticationEntryPointUsed() {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
SecurityWebFilterChain securityWebFilter = this.http
|
SecurityWebFilterChain securityWebFilter = this.http
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
)
|
)
|
||||||
.exceptionHandling(withDefaults())
|
.exceptionHandling(withDefaults())
|
||||||
@ -104,7 +104,7 @@ public class ExceptionHandlingSpecTests {
|
|||||||
public void requestWhenCustomAuthenticationEntryPointInLambdaThenCustomAuthenticationEntryPointUsed() {
|
public void requestWhenCustomAuthenticationEntryPointInLambdaThenCustomAuthenticationEntryPointUsed() {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
SecurityWebFilterChain securityWebFilter = this.http
|
SecurityWebFilterChain securityWebFilter = this.http
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
)
|
)
|
||||||
.exceptionHandling((exceptionHandling) -> exceptionHandling
|
.exceptionHandling((exceptionHandling) -> exceptionHandling
|
||||||
@ -128,7 +128,7 @@ public class ExceptionHandlingSpecTests {
|
|||||||
SecurityWebFilterChain securityWebFilter = this.http
|
SecurityWebFilterChain securityWebFilter = this.http
|
||||||
.csrf((csrf) -> csrf.disable())
|
.csrf((csrf) -> csrf.disable())
|
||||||
.httpBasic(Customizer.withDefaults())
|
.httpBasic(Customizer.withDefaults())
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().hasRole("ADMIN"))
|
.anyExchange().hasRole("ADMIN"))
|
||||||
.exceptionHandling(withDefaults())
|
.exceptionHandling(withDefaults())
|
||||||
.build();
|
.build();
|
||||||
@ -148,7 +148,7 @@ public class ExceptionHandlingSpecTests {
|
|||||||
// @formatter:off
|
// @formatter:off
|
||||||
SecurityWebFilterChain securityWebFilter = this.http
|
SecurityWebFilterChain securityWebFilter = this.http
|
||||||
.httpBasic(withDefaults())
|
.httpBasic(withDefaults())
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().hasRole("ADMIN")
|
.anyExchange().hasRole("ADMIN")
|
||||||
)
|
)
|
||||||
.exceptionHandling(withDefaults())
|
.exceptionHandling(withDefaults())
|
||||||
@ -170,7 +170,7 @@ public class ExceptionHandlingSpecTests {
|
|||||||
SecurityWebFilterChain securityWebFilter = this.http
|
SecurityWebFilterChain securityWebFilter = this.http
|
||||||
.csrf((csrf) -> csrf.disable())
|
.csrf((csrf) -> csrf.disable())
|
||||||
.httpBasic(Customizer.withDefaults())
|
.httpBasic(Customizer.withDefaults())
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().hasRole("ADMIN"))
|
.anyExchange().hasRole("ADMIN"))
|
||||||
.exceptionHandling((handling) -> handling
|
.exceptionHandling((handling) -> handling
|
||||||
.accessDeniedHandler(httpStatusServerAccessDeniedHandler(HttpStatus.BAD_REQUEST)))
|
.accessDeniedHandler(httpStatusServerAccessDeniedHandler(HttpStatus.BAD_REQUEST)))
|
||||||
@ -191,7 +191,7 @@ public class ExceptionHandlingSpecTests {
|
|||||||
// @formatter:off
|
// @formatter:off
|
||||||
SecurityWebFilterChain securityWebFilter = this.http
|
SecurityWebFilterChain securityWebFilter = this.http
|
||||||
.httpBasic(withDefaults())
|
.httpBasic(withDefaults())
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().hasRole("ADMIN")
|
.anyExchange().hasRole("ADMIN")
|
||||||
)
|
)
|
||||||
.exceptionHandling((exceptionHandling) -> exceptionHandling
|
.exceptionHandling((exceptionHandling) -> exceptionHandling
|
||||||
|
@ -69,7 +69,7 @@ public class FormLoginTests {
|
|||||||
public void defaultLoginPage() {
|
public void defaultLoginPage() {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
SecurityWebFilterChain securityWebFilter = this.http
|
SecurityWebFilterChain securityWebFilter = this.http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated())
|
.anyExchange().authenticated())
|
||||||
.formLogin(withDefaults())
|
.formLogin(withDefaults())
|
||||||
.build();
|
.build();
|
||||||
@ -100,7 +100,7 @@ public class FormLoginTests {
|
|||||||
@Test
|
@Test
|
||||||
public void formLoginWhenDefaultsInLambdaThenCreatesDefaultLoginPage() {
|
public void formLoginWhenDefaultsInLambdaThenCreatesDefaultLoginPage() {
|
||||||
SecurityWebFilterChain securityWebFilter = this.http
|
SecurityWebFilterChain securityWebFilter = this.http
|
||||||
.authorizeExchange((exchanges) -> exchanges.anyExchange().authenticated())
|
.authorizeExchange((authorize) -> authorize.anyExchange().authenticated())
|
||||||
.formLogin(withDefaults())
|
.formLogin(withDefaults())
|
||||||
.build();
|
.build();
|
||||||
WebTestClient webTestClient = WebTestClientBuilder.bindToWebFilters(securityWebFilter).build();
|
WebTestClient webTestClient = WebTestClientBuilder.bindToWebFilters(securityWebFilter).build();
|
||||||
@ -127,7 +127,7 @@ public class FormLoginTests {
|
|||||||
public void customLoginPage() {
|
public void customLoginPage() {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
SecurityWebFilterChain securityWebFilter = this.http
|
SecurityWebFilterChain securityWebFilter = this.http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.pathMatchers("/login").permitAll()
|
.pathMatchers("/login").permitAll()
|
||||||
.anyExchange().authenticated())
|
.anyExchange().authenticated())
|
||||||
.formLogin((login) -> login
|
.formLogin((login) -> login
|
||||||
@ -155,7 +155,7 @@ public class FormLoginTests {
|
|||||||
public void formLoginWhenCustomLoginPageInLambdaThenUsed() {
|
public void formLoginWhenCustomLoginPageInLambdaThenUsed() {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
SecurityWebFilterChain securityWebFilter = this.http
|
SecurityWebFilterChain securityWebFilter = this.http
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.pathMatchers("/login").permitAll()
|
.pathMatchers("/login").permitAll()
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
)
|
)
|
||||||
@ -185,7 +185,7 @@ public class FormLoginTests {
|
|||||||
public void formLoginWhenCustomAuthenticationFailureHandlerThenUsed() {
|
public void formLoginWhenCustomAuthenticationFailureHandlerThenUsed() {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
SecurityWebFilterChain securityWebFilter = this.http
|
SecurityWebFilterChain securityWebFilter = this.http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.pathMatchers("/login", "/failure").permitAll()
|
.pathMatchers("/login", "/failure").permitAll()
|
||||||
.anyExchange().authenticated())
|
.anyExchange().authenticated())
|
||||||
.formLogin((login) -> login
|
.formLogin((login) -> login
|
||||||
@ -212,7 +212,7 @@ public class FormLoginTests {
|
|||||||
public void formLoginWhenCustomRequiresAuthenticationMatcherThenUsed() {
|
public void formLoginWhenCustomRequiresAuthenticationMatcherThenUsed() {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
SecurityWebFilterChain securityWebFilter = this.http
|
SecurityWebFilterChain securityWebFilter = this.http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.pathMatchers("/login", "/sign-in").permitAll()
|
.pathMatchers("/login", "/sign-in").permitAll()
|
||||||
.anyExchange().authenticated())
|
.anyExchange().authenticated())
|
||||||
.formLogin((login) -> login
|
.formLogin((login) -> login
|
||||||
@ -233,7 +233,7 @@ public class FormLoginTests {
|
|||||||
public void authenticationSuccess() {
|
public void authenticationSuccess() {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
SecurityWebFilterChain securityWebFilter = this.http
|
SecurityWebFilterChain securityWebFilter = this.http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated())
|
.anyExchange().authenticated())
|
||||||
.formLogin((login) -> login
|
.formLogin((login) -> login
|
||||||
.authenticationSuccessHandler(new RedirectServerAuthenticationSuccessHandler("/custom")))
|
.authenticationSuccessHandler(new RedirectServerAuthenticationSuccessHandler("/custom")))
|
||||||
@ -298,7 +298,7 @@ public class FormLoginTests {
|
|||||||
given(formLoginSecContextRepository.load(any())).willReturn(authentication(token));
|
given(formLoginSecContextRepository.load(any())).willReturn(authentication(token));
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
SecurityWebFilterChain securityWebFilter = this.http
|
SecurityWebFilterChain securityWebFilter = this.http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated())
|
.anyExchange().authenticated())
|
||||||
.securityContextRepository(defaultSecContextRepository)
|
.securityContextRepository(defaultSecContextRepository)
|
||||||
.formLogin((login) -> login
|
.formLogin((login) -> login
|
||||||
|
@ -44,7 +44,7 @@ public class LogoutSpecTests {
|
|||||||
public void defaultLogout() {
|
public void defaultLogout() {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
SecurityWebFilterChain securityWebFilter = this.http
|
SecurityWebFilterChain securityWebFilter = this.http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated())
|
.anyExchange().authenticated())
|
||||||
.formLogin(withDefaults())
|
.formLogin(withDefaults())
|
||||||
.build();
|
.build();
|
||||||
@ -78,7 +78,7 @@ public class LogoutSpecTests {
|
|||||||
public void customLogout() {
|
public void customLogout() {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
SecurityWebFilterChain securityWebFilter = this.http
|
SecurityWebFilterChain securityWebFilter = this.http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated())
|
.anyExchange().authenticated())
|
||||||
.formLogin(withDefaults())
|
.formLogin(withDefaults())
|
||||||
.logout((logout) -> logout
|
.logout((logout) -> logout
|
||||||
@ -114,7 +114,7 @@ public class LogoutSpecTests {
|
|||||||
public void logoutWhenCustomLogoutInLambdaThenCustomLogoutUsed() {
|
public void logoutWhenCustomLogoutInLambdaThenCustomLogoutUsed() {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
SecurityWebFilterChain securityWebFilter = this.http
|
SecurityWebFilterChain securityWebFilter = this.http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
)
|
)
|
||||||
.formLogin(withDefaults())
|
.formLogin(withDefaults())
|
||||||
@ -151,7 +151,7 @@ public class LogoutSpecTests {
|
|||||||
public void logoutWhenDisabledThenDefaultLogoutPageDoesNotExist() {
|
public void logoutWhenDisabledThenDefaultLogoutPageDoesNotExist() {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
SecurityWebFilterChain securityWebFilter = this.http
|
SecurityWebFilterChain securityWebFilter = this.http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated())
|
.anyExchange().authenticated())
|
||||||
.formLogin(withDefaults())
|
.formLogin(withDefaults())
|
||||||
.logout((logout) -> logout.disable())
|
.logout((logout) -> logout.disable())
|
||||||
@ -184,7 +184,7 @@ public class LogoutSpecTests {
|
|||||||
// @formatter:off
|
// @formatter:off
|
||||||
SecurityWebFilterChain securityWebFilter = this.http
|
SecurityWebFilterChain securityWebFilter = this.http
|
||||||
.securityContextRepository(repository)
|
.securityContextRepository(repository)
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated())
|
.anyExchange().authenticated())
|
||||||
.formLogin(withDefaults())
|
.formLogin(withDefaults())
|
||||||
.logout(withDefaults())
|
.logout(withDefaults())
|
||||||
|
@ -863,7 +863,7 @@ public class OAuth2LoginTests {
|
|||||||
http.authenticationManager(authenticationManager);
|
http.authenticationManager(authenticationManager);
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated())
|
.anyExchange().authenticated())
|
||||||
.oauth2Login(withDefaults())
|
.oauth2Login(withDefaults())
|
||||||
.formLogin(withDefaults());
|
.formLogin(withDefaults());
|
||||||
@ -885,7 +885,7 @@ public class OAuth2LoginTests {
|
|||||||
http.authenticationManager(authenticationManager);
|
http.authenticationManager(authenticationManager);
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated())
|
.anyExchange().authenticated())
|
||||||
.oauth2Login(withDefaults())
|
.oauth2Login(withDefaults())
|
||||||
.httpBasic(withDefaults());
|
.httpBasic(withDefaults());
|
||||||
@ -954,7 +954,7 @@ public class OAuth2LoginTests {
|
|||||||
SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated())
|
.anyExchange().authenticated())
|
||||||
.oauth2Login((login) -> login
|
.oauth2Login((login) -> login
|
||||||
.authenticationConverter(this.authenticationConverter)
|
.authenticationConverter(this.authenticationConverter)
|
||||||
@ -986,7 +986,7 @@ public class OAuth2LoginTests {
|
|||||||
SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
http
|
http
|
||||||
.authorizeExchange((authorizeExchange) -> authorizeExchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
)
|
)
|
||||||
.oauth2Login((oauth2) -> oauth2
|
.oauth2Login((oauth2) -> oauth2
|
||||||
@ -1024,7 +1024,7 @@ public class OAuth2LoginTests {
|
|||||||
SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated())
|
.anyExchange().authenticated())
|
||||||
.oauth2Login((login) -> login
|
.oauth2Login((login) -> login
|
||||||
.authenticationConverter(this.authenticationConverter)
|
.authenticationConverter(this.authenticationConverter)
|
||||||
|
@ -682,7 +682,7 @@ public class OAuth2ResourceServerSpecTests {
|
|||||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().hasAuthority("SCOPE_message:read"))
|
.anyExchange().hasAuthority("SCOPE_message:read"))
|
||||||
.oauth2ResourceServer((server) -> server
|
.oauth2ResourceServer((server) -> server
|
||||||
.jwt((jwt) -> jwt.publicKey(publicKey())));
|
.jwt((jwt) -> jwt.publicKey(publicKey())));
|
||||||
@ -701,7 +701,7 @@ public class OAuth2ResourceServerSpecTests {
|
|||||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
http
|
http
|
||||||
.authorizeExchange((authorizeExchange) -> authorizeExchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().hasAuthority("SCOPE_message:read")
|
.anyExchange().hasAuthority("SCOPE_message:read")
|
||||||
)
|
)
|
||||||
.oauth2ResourceServer((oauth2) -> oauth2
|
.oauth2ResourceServer((oauth2) -> oauth2
|
||||||
@ -727,7 +727,7 @@ public class OAuth2ResourceServerSpecTests {
|
|||||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().hasAuthority("SCOPE_message:read"))
|
.anyExchange().hasAuthority("SCOPE_message:read"))
|
||||||
.oauth2ResourceServer((server) -> server
|
.oauth2ResourceServer((server) -> server
|
||||||
.jwt((jwt) -> jwt.publicKey(this.key)));
|
.jwt((jwt) -> jwt.publicKey(this.key)));
|
||||||
@ -833,7 +833,7 @@ public class OAuth2ResourceServerSpecTests {
|
|||||||
SecurityWebFilterChain authorization(ServerHttpSecurity http) {
|
SecurityWebFilterChain authorization(ServerHttpSecurity http) {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().denyAll())
|
.anyExchange().denyAll())
|
||||||
.oauth2ResourceServer((server) -> server
|
.oauth2ResourceServer((server) -> server
|
||||||
.jwt((jwt) -> jwt.publicKey(publicKey())));
|
.jwt((jwt) -> jwt.publicKey(publicKey())));
|
||||||
@ -899,7 +899,7 @@ public class OAuth2ResourceServerSpecTests {
|
|||||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.pathMatchers("/*/message/**").hasAnyAuthority("SCOPE_message:read"))
|
.pathMatchers("/*/message/**").hasAnyAuthority("SCOPE_message:read"))
|
||||||
.oauth2ResourceServer((server) -> server
|
.oauth2ResourceServer((server) -> server
|
||||||
.authenticationManagerResolver(authenticationManagerResolver()));
|
.authenticationManagerResolver(authenticationManagerResolver()));
|
||||||
@ -957,7 +957,7 @@ public class OAuth2ResourceServerSpecTests {
|
|||||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().hasAuthority("SCOPE_message:read"))
|
.anyExchange().hasAuthority("SCOPE_message:read"))
|
||||||
.oauth2ResourceServer((server) -> server
|
.oauth2ResourceServer((server) -> server
|
||||||
.bearerTokenConverter(bearerTokenAuthenticationConverter())
|
.bearerTokenConverter(bearerTokenAuthenticationConverter())
|
||||||
@ -983,7 +983,7 @@ public class OAuth2ResourceServerSpecTests {
|
|||||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().hasAuthority("message:read"))
|
.anyExchange().hasAuthority("message:read"))
|
||||||
.oauth2ResourceServer((server) -> server
|
.oauth2ResourceServer((server) -> server
|
||||||
.jwt((jwt) -> jwt
|
.jwt((jwt) -> jwt
|
||||||
@ -1014,7 +1014,7 @@ public class OAuth2ResourceServerSpecTests {
|
|||||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.pathMatchers("/authenticated").authenticated()
|
.pathMatchers("/authenticated").authenticated()
|
||||||
.pathMatchers("/unobtainable").hasAuthority("unobtainable"))
|
.pathMatchers("/unobtainable").hasAuthority("unobtainable"))
|
||||||
.oauth2ResourceServer((server) -> server
|
.oauth2ResourceServer((server) -> server
|
||||||
@ -1102,7 +1102,7 @@ public class OAuth2ResourceServerSpecTests {
|
|||||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated())
|
.anyExchange().authenticated())
|
||||||
.oauth2ResourceServer((server) -> server
|
.oauth2ResourceServer((server) -> server
|
||||||
.authenticationManagerResolver(mock(ReactiveAuthenticationManagerResolver.class))
|
.authenticationManagerResolver(mock(ReactiveAuthenticationManagerResolver.class))
|
||||||
|
@ -49,7 +49,7 @@ public class RequestCacheTests {
|
|||||||
public void defaultFormLoginRequestCache() {
|
public void defaultFormLoginRequestCache() {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
SecurityWebFilterChain securityWebFilter = this.http
|
SecurityWebFilterChain securityWebFilter = this.http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated())
|
.anyExchange().authenticated())
|
||||||
.formLogin(withDefaults())
|
.formLogin(withDefaults())
|
||||||
.build();
|
.build();
|
||||||
@ -75,7 +75,7 @@ public class RequestCacheTests {
|
|||||||
public void requestCacheNoOp() {
|
public void requestCacheNoOp() {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
SecurityWebFilterChain securityWebFilter = this.http
|
SecurityWebFilterChain securityWebFilter = this.http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated())
|
.anyExchange().authenticated())
|
||||||
.formLogin(withDefaults())
|
.formLogin(withDefaults())
|
||||||
.requestCache((cache) -> cache
|
.requestCache((cache) -> cache
|
||||||
@ -103,7 +103,7 @@ public class RequestCacheTests {
|
|||||||
public void requestWhenCustomRequestCacheInLambdaThenCustomCacheUsed() {
|
public void requestWhenCustomRequestCacheInLambdaThenCustomCacheUsed() {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
SecurityWebFilterChain securityWebFilter = this.http
|
SecurityWebFilterChain securityWebFilter = this.http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
)
|
)
|
||||||
.formLogin(withDefaults())
|
.formLogin(withDefaults())
|
||||||
|
@ -191,7 +191,7 @@ public class ServerHttpSecurityTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void basicWhenNoCredentialsThenUnauthorized() {
|
public void basicWhenNoCredentialsThenUnauthorized() {
|
||||||
this.http.authorizeExchange((exchange) -> exchange.anyExchange().authenticated());
|
this.http.authorizeExchange((authorize) -> authorize.anyExchange().authenticated());
|
||||||
WebTestClient client = buildClient();
|
WebTestClient client = buildClient();
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
client.get().uri("/")
|
client.get().uri("/")
|
||||||
@ -207,7 +207,7 @@ public class ServerHttpSecurityTests {
|
|||||||
ServerAuthenticationEntryPoint authenticationEntryPoint = spy(
|
ServerAuthenticationEntryPoint authenticationEntryPoint = spy(
|
||||||
new HttpStatusServerEntryPoint(HttpStatus.UNAUTHORIZED));
|
new HttpStatusServerEntryPoint(HttpStatus.UNAUTHORIZED));
|
||||||
this.http.httpBasic((basic) -> basic.authenticationEntryPoint(authenticationEntryPoint));
|
this.http.httpBasic((basic) -> basic.authenticationEntryPoint(authenticationEntryPoint));
|
||||||
this.http.authorizeExchange((exchange) -> exchange.anyExchange().authenticated());
|
this.http.authorizeExchange((authorize) -> authorize.anyExchange().authenticated());
|
||||||
WebTestClient client = buildClient();
|
WebTestClient client = buildClient();
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
client.get().uri("/")
|
client.get().uri("/")
|
||||||
@ -228,7 +228,7 @@ public class ServerHttpSecurityTests {
|
|||||||
ServerAuthenticationFailureHandler.class);
|
ServerAuthenticationFailureHandler.class);
|
||||||
this.http.httpBasic((basic) -> basic.authenticationFailureHandler(authenticationFailureHandler));
|
this.http.httpBasic((basic) -> basic.authenticationFailureHandler(authenticationFailureHandler));
|
||||||
this.http.httpBasic((basic) -> basic.authenticationManager(authenticationManager));
|
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()))
|
given(authenticationManager.authenticate(any()))
|
||||||
.willReturn(Mono.error(() -> new BadCredentialsException("bad")));
|
.willReturn(Mono.error(() -> new BadCredentialsException("bad")));
|
||||||
given(authenticationFailureHandler.onAuthenticationFailure(any(), any())).willReturn(Mono.empty());
|
given(authenticationFailureHandler.onAuthenticationFailure(any(), any())).willReturn(Mono.empty());
|
||||||
@ -596,7 +596,7 @@ public class ServerHttpSecurityTests {
|
|||||||
ReactiveClientRegistrationRepository.class);
|
ReactiveClientRegistrationRepository.class);
|
||||||
SecurityWebFilterChain securityFilterChain = this.http
|
SecurityWebFilterChain securityFilterChain = this.http
|
||||||
.oauth2Login((login) -> login.clientRegistrationRepository(clientRegistrationRepository))
|
.oauth2Login((login) -> login.clientRegistrationRepository(clientRegistrationRepository))
|
||||||
.authorizeExchange((exchange) -> exchange.anyExchange().authenticated())
|
.authorizeExchange((authorize) -> authorize.anyExchange().authenticated())
|
||||||
.requestCache((c) -> c.requestCache(requestCache))
|
.requestCache((c) -> c.requestCache(requestCache))
|
||||||
.build();
|
.build();
|
||||||
WebTestClient client = WebTestClientBuilder.bindToWebFilters(securityFilterChain).build();
|
WebTestClient client = WebTestClientBuilder.bindToWebFilters(securityFilterChain).build();
|
||||||
|
@ -418,7 +418,7 @@ public class SessionManagementSpecTests {
|
|||||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchanges) -> exchanges.anyExchange().authenticated())
|
.authorizeExchange((authorize) -> authorize.anyExchange().authenticated())
|
||||||
.formLogin(Customizer.withDefaults())
|
.formLogin(Customizer.withDefaults())
|
||||||
.sessionManagement((sessionManagement) -> sessionManagement
|
.sessionManagement((sessionManagement) -> sessionManagement
|
||||||
.concurrentSessions((concurrentSessions) -> concurrentSessions
|
.concurrentSessions((concurrentSessions) -> concurrentSessions
|
||||||
@ -453,7 +453,7 @@ public class SessionManagementSpecTests {
|
|||||||
DefaultWebSessionManager webSessionManager) {
|
DefaultWebSessionManager webSessionManager) {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
)
|
)
|
||||||
.oauth2Login((oauth2Login) -> oauth2Login
|
.oauth2Login((oauth2Login) -> oauth2Login
|
||||||
@ -493,7 +493,7 @@ public class SessionManagementSpecTests {
|
|||||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchanges) -> exchanges.anyExchange().authenticated())
|
.authorizeExchange((authorize) -> authorize.anyExchange().authenticated())
|
||||||
.formLogin(Customizer.withDefaults())
|
.formLogin(Customizer.withDefaults())
|
||||||
.sessionManagement((sessionManagement) -> sessionManagement
|
.sessionManagement((sessionManagement) -> sessionManagement
|
||||||
.concurrentSessions((concurrentSessions) -> concurrentSessions
|
.concurrentSessions((concurrentSessions) -> concurrentSessions
|
||||||
@ -516,7 +516,7 @@ public class SessionManagementSpecTests {
|
|||||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchanges) -> exchanges.anyExchange().authenticated())
|
.authorizeExchange((authorize) -> authorize.anyExchange().authenticated())
|
||||||
.formLogin((login) -> login
|
.formLogin((login) -> login
|
||||||
.authenticationSuccessHandler(new RedirectServerAuthenticationSuccessHandler("/"))
|
.authenticationSuccessHandler(new RedirectServerAuthenticationSuccessHandler("/"))
|
||||||
)
|
)
|
||||||
@ -542,7 +542,7 @@ public class SessionManagementSpecTests {
|
|||||||
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchanges) -> exchanges.anyExchange().authenticated())
|
.authorizeExchange((authorize) -> authorize.anyExchange().authenticated())
|
||||||
.httpBasic((basic) -> basic
|
.httpBasic((basic) -> basic
|
||||||
.securityContextRepository(new WebSessionServerSecurityContextRepository())
|
.securityContextRepository(new WebSessionServerSecurityContextRepository())
|
||||||
)
|
)
|
||||||
|
@ -24,7 +24,7 @@ SecurityWebFilterChain http(ServerHttpSecurity http) throws Exception {
|
|||||||
);
|
);
|
||||||
|
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchange) -> exchange.anyExchange().authenticated())
|
.authorizeExchange((authorize) -> authorize.anyExchange().authenticated())
|
||||||
.logout((logout) -> logout.logoutHandler(logoutHandler));
|
.logout((logout) -> logout.logoutHandler(logoutHandler));
|
||||||
|
|
||||||
return http.build();
|
return http.build();
|
||||||
@ -40,7 +40,7 @@ fun http(http: ServerHttpSecurity): SecurityWebFilterChain {
|
|||||||
val customLogoutHandler = DelegatingServerLogoutHandler(
|
val customLogoutHandler = DelegatingServerLogoutHandler(
|
||||||
SecurityContextServerLogoutHandler(), WebSessionServerLogoutHandler()
|
SecurityContextServerLogoutHandler(), WebSessionServerLogoutHandler()
|
||||||
)
|
)
|
||||||
|
|
||||||
return http {
|
return http {
|
||||||
authorizeExchange {
|
authorizeExchange {
|
||||||
authorize(anyExchange, authenticated)
|
authorize(anyExchange, authenticated)
|
||||||
|
@ -15,7 +15,7 @@ Java::
|
|||||||
@Bean
|
@Bean
|
||||||
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
)
|
)
|
||||||
.httpBasic(withDefaults())
|
.httpBasic(withDefaults())
|
||||||
|
@ -614,7 +614,7 @@ public class SecurityConfig {
|
|||||||
return http
|
return http
|
||||||
// Demonstrate that method security works
|
// Demonstrate that method security works
|
||||||
// Best practice to use both for defense in depth
|
// Best practice to use both for defense in depth
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().permitAll()
|
.anyExchange().permitAll()
|
||||||
)
|
)
|
||||||
.httpBasic(withDefaults())
|
.httpBasic(withDefaults())
|
||||||
|
@ -87,7 +87,7 @@ public class HelloWebfluxSecurityConfig {
|
|||||||
@Bean
|
@Bean
|
||||||
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
)
|
)
|
||||||
.httpBasic(withDefaults())
|
.httpBasic(withDefaults())
|
||||||
@ -161,7 +161,7 @@ static class MultiSecurityHttpConfig {
|
|||||||
SecurityWebFilterChain apiHttpSecurity(ServerHttpSecurity http) {
|
SecurityWebFilterChain apiHttpSecurity(ServerHttpSecurity http) {
|
||||||
http
|
http
|
||||||
.securityMatcher(new PathPatternParserServerWebExchangeMatcher("/api/**")) <2>
|
.securityMatcher(new PathPatternParserServerWebExchangeMatcher("/api/**")) <2>
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
)
|
)
|
||||||
.oauth2ResourceServer(OAuth2ResourceServerSpec::jwt); <3>
|
.oauth2ResourceServer(OAuth2ResourceServerSpec::jwt); <3>
|
||||||
@ -171,7 +171,7 @@ static class MultiSecurityHttpConfig {
|
|||||||
@Bean
|
@Bean
|
||||||
SecurityWebFilterChain webHttpSecurity(ServerHttpSecurity http) { <4>
|
SecurityWebFilterChain webHttpSecurity(ServerHttpSecurity http) { <4>
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
)
|
)
|
||||||
.httpBasic(withDefaults()); <5>
|
.httpBasic(withDefaults()); <5>
|
||||||
|
@ -128,7 +128,7 @@ Java::
|
|||||||
@Bean
|
@Bean
|
||||||
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
)
|
)
|
||||||
.oauth2ResourceServer(OAuth2ResourceServerSpec::jwt)
|
.oauth2ResourceServer(OAuth2ResourceServerSpec::jwt)
|
||||||
@ -170,7 +170,7 @@ import static org.springframework.security.oauth2.core.authorization.OAuth2React
|
|||||||
@Bean
|
@Bean
|
||||||
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.pathMatchers("/message/**").access(hasScope("message:read"))
|
.pathMatchers("/message/**").access(hasScope("message:read"))
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
)
|
)
|
||||||
@ -254,7 +254,7 @@ Java::
|
|||||||
@Bean
|
@Bean
|
||||||
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
)
|
)
|
||||||
.oauth2ResourceServer((oauth2) -> oauth2
|
.oauth2ResourceServer((oauth2) -> oauth2
|
||||||
@ -302,7 +302,7 @@ Java::
|
|||||||
@Bean
|
@Bean
|
||||||
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
)
|
)
|
||||||
.oauth2ResourceServer((oauth2) -> oauth2
|
.oauth2ResourceServer((oauth2) -> oauth2
|
||||||
@ -691,7 +691,7 @@ import static org.springframework.security.oauth2.core.authorization.OAuth2React
|
|||||||
@Bean
|
@Bean
|
||||||
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.mvcMatchers("/contacts/**").access(hasScope("contacts"))
|
.mvcMatchers("/contacts/**").access(hasScope("contacts"))
|
||||||
.mvcMatchers("/messages/**").access(hasScope("messages"))
|
.mvcMatchers("/messages/**").access(hasScope("messages"))
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
@ -762,7 +762,7 @@ Java::
|
|||||||
@Bean
|
@Bean
|
||||||
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
)
|
)
|
||||||
.oauth2ResourceServer((oauth2) -> oauth2
|
.oauth2ResourceServer((oauth2) -> oauth2
|
||||||
|
@ -27,7 +27,7 @@ JwtIssuerReactiveAuthenticationManagerResolver authenticationManagerResolver = J
|
|||||||
.fromTrustedIssuers("https://idp.example.org/issuerOne", "https://idp.example.org/issuerTwo");
|
.fromTrustedIssuers("https://idp.example.org/issuerOne", "https://idp.example.org/issuerTwo");
|
||||||
|
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
)
|
)
|
||||||
.oauth2ResourceServer((oauth2) -> oauth2
|
.oauth2ResourceServer((oauth2) -> oauth2
|
||||||
@ -83,7 +83,7 @@ JwtIssuerReactiveAuthenticationManagerResolver authenticationManagerResolver =
|
|||||||
new JwtIssuerReactiveAuthenticationManagerResolver(authenticationManagers::get);
|
new JwtIssuerReactiveAuthenticationManagerResolver(authenticationManagers::get);
|
||||||
|
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
)
|
)
|
||||||
.oauth2ResourceServer((oauth2) -> oauth2
|
.oauth2ResourceServer((oauth2) -> oauth2
|
||||||
|
@ -176,7 +176,7 @@ Java::
|
|||||||
@Bean
|
@Bean
|
||||||
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
)
|
)
|
||||||
.oauth2ResourceServer(ServerHttpSecurity.OAuth2ResourceServerSpec::opaqueToken)
|
.oauth2ResourceServer(ServerHttpSecurity.OAuth2ResourceServerSpec::opaqueToken)
|
||||||
@ -221,7 +221,7 @@ public class MyCustomSecurityConfiguration {
|
|||||||
@Bean
|
@Bean
|
||||||
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.pathMatchers("/messages/**").access(hasScope("message:read"))
|
.pathMatchers("/messages/**").access(hasScope("message:read"))
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
)
|
)
|
||||||
@ -310,7 +310,7 @@ public class DirectlyConfiguredIntrospectionUri {
|
|||||||
@Bean
|
@Bean
|
||||||
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
)
|
)
|
||||||
.oauth2ResourceServer((oauth2) -> oauth2
|
.oauth2ResourceServer((oauth2) -> oauth2
|
||||||
@ -364,7 +364,7 @@ public class DirectlyConfiguredIntrospector {
|
|||||||
@Bean
|
@Bean
|
||||||
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
)
|
)
|
||||||
.oauth2ResourceServer((oauth2) -> oauth2
|
.oauth2ResourceServer((oauth2) -> oauth2
|
||||||
@ -457,7 +457,7 @@ public class MappedAuthorities {
|
|||||||
@Bean
|
@Bean
|
||||||
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
||||||
http
|
http
|
||||||
.authorizeExchange((exchange) -> exchange
|
.authorizeExchange((authorize) -> authorize
|
||||||
.pathMatchers("/contacts/**").access(hasScope("contacts"))
|
.pathMatchers("/contacts/**").access(hasScope("contacts"))
|
||||||
.pathMatchers("/messages/**").access(hasScope("messages"))
|
.pathMatchers("/messages/**").access(hasScope("messages"))
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
|
@ -63,7 +63,7 @@ public class CustomX509Configuration {
|
|||||||
.principalExtractor(principalExtractor)
|
.principalExtractor(principalExtractor)
|
||||||
.authenticationManager(authenticationManager)
|
.authenticationManager(authenticationManager)
|
||||||
)
|
)
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
);
|
);
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
|
@ -44,7 +44,7 @@ public class DefaultX509Configuration {
|
|||||||
// @formatter:off
|
// @formatter:off
|
||||||
http
|
http
|
||||||
.x509(Customizer.withDefaults())
|
.x509(Customizer.withDefaults())
|
||||||
.authorizeExchange((exchanges) -> exchanges
|
.authorizeExchange((authorize) -> authorize
|
||||||
.anyExchange().authenticated()
|
.anyExchange().authenticated()
|
||||||
);
|
);
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
|
Loading…
x
Reference in New Issue
Block a user