我是靠谱客的博主 顺心黑米,这篇文章主要介绍spring security 在 spring webflux 中的使用,现在分享给大家,希望可以做个参考。

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();
}
}

 

最后

以上就是顺心黑米最近收集整理的关于spring security 在 spring webflux 中的使用的全部内容,更多相关spring内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(55)

评论列表共有 0 条评论

立即
投稿
返回
顶部