在 spring-mvc 中可以扩展 from WebSecurityConfigurerAdapter,覆盖configure(WebSecurity web)并做一些这样的思考:
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers(AUTH_WHITE_LIST);
}
Run Code Online (Sandbox Code Playgroud)
这种方法的主要好处是 spring-security 甚至不会尝试解码传递的令牌。是否可以使用 webflux 做几乎相同的事情?
我知道我可以这样做:
@Bean
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) throws Exception {
http.csrf().disable()
.authorizeExchange().pathMatchers(AUTH_WHITE_LIST).permitAll()
.anyExchange().authenticated();
return http.build();
}
Run Code Online (Sandbox Code Playgroud)
但是这样,据我所知,spring-security 将首先尝试解析提供的令牌。