【发布时间】:2019-12-29 04:35:15
【问题描述】:
我有一条需要为多个用户进行身份验证的路由。对 spring cloud gateway 服务进行集成测试,以测试所有路由的安全性是否按预期工作。如何向单个 pathMatcher/route 添加超过 1 个用户角色?
使用 Spring Boot 2.1.6、Spring Cloud Finchely.SR2、Spring Cloud Gateway、Spring WebFlux Security(Reactive Spring Security)
@EnableWebFluxSecurity
public class SecurityConfig {
@Bean
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
http.csrf().disable()
.formLogin().disable()
.logout().disable()
.authorizeExchange()
.pathMatchers(prefix + "/publish/**")
.hasRole("XYZ_ROLE") //Here i want to add more than one user role
.anyExchange()
.authenticated().and().httpBasic();
}
}
【问题讨论】:
标签: java spring-security spring-webflux spring-cloud-gateway