Created
May 5, 2021 13:22
-
-
Save walidum/5dc4c1ec7cc1ba8c28a6801ef9f227aa to your computer and use it in GitHub Desktop.
WebFluxSecurity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
@EnableWebFluxSecurity | |
public class HelloWebfluxSecurityConfig { | |
@Bean | |
public MapReactiveUserDetailsService userDetailsService() { | |
UserDetails user = User.withDefaultPasswordEncoder() | |
.username("user") | |
.password("user") | |
.roles("USER") | |
.build(); | |
return new MapReactiveUserDetailsService(user); | |
} | |
@Bean | |
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { | |
http | |
.authorizeExchange(exchanges -> exchanges | |
.anyExchange().authenticated() | |
) | |
.httpBasic(withDefaults()) | |
.formLogin(withDefaults()); | |
return http.build(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment