这个问题是https://github.com/spring-cloud/spring-cloud-gateway/issues/3636问题的后续问题,该问题还附加了MCVE。
正确配置它的推荐方法是什么。
访问http://dummy.traefik.me/login时不经过安全过滤链,如果是这样的话我想可以这样做
private ServerWebExchangeMatcher getSecurityMatcher() {
return exchange -> {
URI uri = exchange.getRequest().getURI();
if (uri.getHost().equals("dummy.traefik.me")) {
return ServerWebExchangeMatcher.MatchResult.notMatch();
}
return ServerWebExchangeMatcher.MatchResult.match();
};
}
@Bean
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
http
.securityMatcher(getSecurityMatcher())
.authorizeExchange(authorizeRequests -> authorizeRequests
.anyExchange()
.authenticated()
)
.formLogin(withDefaults())
.logout(withDefaults());
return http.build();
}