SpringBoot2.* GateWay网关中关闭security验证
SpringBoot2.* GateWay网关中关闭security验证
·
package com.petkit.gateway.config;
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;
/**
* @author menglinjie
* @date Created in 2020/6/22 12:01
* @description: 注意:webflux环境下要生效必须用注解@EnableWebFluxSecurity使其生效
* cloud gateway采用的webflux技术(此处与web不同)
*/
@Configuration
@EnableWebFluxSecurity
public class WebSecurityConfig {
@Bean
SecurityWebFilterChain webFluxSecurityFilterChain(ServerHttpSecurity http) throws Exception {
http.authorizeExchange()
.anyExchange()
.permitAll();
// 一些配置
http
.csrf().disable()
.httpBasic().disable()
.logout().disable()
.formLogin().disable();
return http.build();
}
}
注意:gateway网关项目和普通springboot项目关闭security验证的方式不同。原因是gateway采用的webflux技术,不是servlet。
更多推荐
已为社区贡献4条内容
所有评论(0)