Authentication 删除其中一个Web API';他穿着弹簧靴
我的项目有两个API。第一个需要身份验证,第二个不需要 我成功地为第一个API添加了基于令牌的身份验证过滤器Authentication 删除其中一个Web API';他穿着弹簧靴,authentication,spring-security,spring-boot,Authentication,Spring Security,Spring Boot,我的项目有两个API。第一个需要身份验证,第二个不需要 我成功地为第一个API添加了基于令牌的身份验证过滤器/Auth/uploadFile 下面是来自SecurityConfig类的代码片段,该类扩展了WebSecurityConfigureAdapter @Override protected void configure(HttpSecurity http) throws Exception { http.addFilterBefore(tokenAuth
/Auth/uploadFile
下面是来自SecurityConfig类的代码片段,该类扩展了WebSecurityConfigureAdapter
@Override
protected void configure(HttpSecurity http) throws Exception {
http.addFilterBefore(tokenAuthenticationFilter, BasicAuthenticationFilter.class).authorizeRequests()
.antMatchers("/auth/uploadFile/").permitAll().anyRequest()
.authenticated().and().csrf().disable();
}
我还没有将我的第二个API/noauth/uploadFile
添加到antMatchers()中,但是当我对它进行POST调用时,它仍然会进入自定义的tokenAuthenticationFilter
当我调用第二个API
/noauth/uploadFile
时,如何避免输入我的自定义筛选器tokenAuthenticationFilter,即我的筛选器不应应用于第二个API?您可以在SecurityConfig类中重写/添加以下方法
public void configure(WebSecurity web) throws Exception {
web
.ignoring()
.antMatchers("/noauth/**");
}
您可以在SecurityConfig类中重写/添加以下方法
public void configure(WebSecurity web) throws Exception {
web
.ignoring()
.antMatchers("/noauth/**");
}