https://blog.csdn.net/joker_2007/article/details/82736183
pring5增加了reactive web模块,相应的在spring security中也增加了 [webflux-web-security] 模块,相对于spring security 在配置和使用方面有略微的差异,下面主要说明简单的配置和自定义用户信息的配置。
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
import org.springframework.security.config.web.server.ServerHttpSecurity;
import org.springframework.security.web.server.SecurityWebFilterChain;
@Configuration
@EnableWebFluxSecurity
public class WebFluxSecurityConfig{
@Bean
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
http
.authorizeExchange()
//.pathMatchers("/loginPage").permitAll() //无需进行权限过滤的请求路径
.anyExchange().authenticated()
.and()
.httpBasic().and()
.formLogin()
//.loginPage("/loginPage") //自定义的登陆页面
;
return http.build();
}
}