Spring Security从定制过滤器中排除端点

ilo*_*una 5 spring spring-security spring-boot spring-java-config

具有以下弹簧安全配置:

http.antMatcher("/**/v1/public/company/employees/**")
                .authorizeRequests()
                .antMatchers(HttpMethod.OPTIONS, "/**/v1/public/company/employees/A").permitAll()
                .antMatchers(HttpMethod.POST, "/**/v1/public/company/employees/B").permitAll()
                .antMatchers("/**/v1/public/company/employees/**")
                .authenticated()
                .and()
                .csrf()
                .disable()
                .addFilterBefore(customFilter, AbstractPreAuthenticatedProcessingFilter.class);
Run Code Online (Sandbox Code Playgroud)

如何从中排除公共端点(ABcustomFilter

更新资料

使用方法:

@Override
    public void configure(WebSecurity web) throws Exception {
        web
                .ignoring()
                .antMatchers(HttpMethod.OPTIONS, "/**/v1/public/company/employees/A")
                .antMatchers(HttpMethod.POST, "/**/v1/public/company/employees/B")
        }
Run Code Online (Sandbox Code Playgroud)

似乎足够,但我仍然不知道这是否是推荐的方式