Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/authentication/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Authentication 删除其中一个Web API';他穿着弹簧靴_Authentication_Spring Security_Spring Boot - Fatal编程技术网

Authentication 删除其中一个Web 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

我的项目有两个API。第一个需要身份验证,第二个不需要

我成功地为第一个API添加了基于令牌的身份验证过滤器
/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/**");
}