我想知道,如果Filter在Spring Boot中有一个类(用于Web应用程序)的注释?也许@Filter吧?
我想在我的项目中添加自定义过滤器.
Spring Boot Reference Guide提到了
FilterRegistrationBean,但我不知道如何使用它.
我有以下Spring Security配置:
httpSecurity
.csrf()
.disable()
.exceptionHandling()
.authenticationEntryPoint(unauthorizedHandler)
.and()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
.antMatchers("/api/**").fullyAuthenticated()
.and()
.addFilterBefore(authenticationTokenFilterBean(), UsernamePasswordAuthenticationFilter.class);
Run Code Online (Sandbox Code Playgroud)
该authenticationTokenFilterBean()甚至在不匹配的终端应用/api/**表现.我还尝试添加以下配置代码
@Override
public void configure(WebSecurity webSecurity) {
webSecurity.ignoring().antMatchers("/some_endpoint");
}
Run Code Online (Sandbox Code Playgroud)
但这仍然没有解决我的问题.如何告诉spring security仅在与安全URI表达式匹配的端点上应用过滤器?谢谢