Remove formLogin() and httpBasic() from defaults

This commit is contained in:
Rob Winch 2017-10-12 16:20:38 -05:00
parent 5fae710d69
commit 211e8eae90
4 changed files with 10 additions and 4 deletions

View File

@ -67,8 +67,6 @@ public class ServerHttpSecurityConfiguration implements WebFluxConfigurer {
return http()
.authenticationManager(authenticationManager())
.headers().and()
.httpBasic().and()
.formLogin().and()
.logout().and();
}

View File

@ -65,7 +65,11 @@ public class WebFluxSecurityConfiguration {
ServerHttpSecurity http = context.getBean(ServerHttpSecurity.class);
http
.authorizeExchange()
.anyExchange().authenticated();
.anyExchange().authenticated()
.and()
.httpBasic().and()
.formLogin().and()
.build();
return Arrays.asList(http.build());
}
}

View File

@ -43,6 +43,7 @@ public class LogoutBuilderTests {
.authorizeExchange()
.anyExchange().authenticated()
.and()
.formLogin().and()
.build();
WebTestClient webTestClient = WebTestClientBuilder
@ -82,6 +83,7 @@ public class LogoutBuilderTests {
.authorizeExchange()
.anyExchange().authenticated()
.and()
.formLogin().and()
.logout()
.logoutUrl("/custom-logout")
.and()

View File

@ -36,10 +36,12 @@ public class SecurityConfig {
@Bean
SecurityWebFilterChain springWebFilterChain(ServerHttpSecurity http) throws Exception {
return http
// we rely on method security
// Demonstrate that method security works
// Best practice to use both for defense in depth
.authorizeExchange()
.anyExchange().permitAll()
.and()
.httpBasic().and()
.build();
}