Spring security 如何在没有身份验证的情况下允许spring security中的某些端点?

Spring security 如何在没有身份验证的情况下允许spring security中的某些端点?,spring-security,Spring Security,我正在使用Spring security开发一个应用程序 @Override public void configure(HttpSecurity http) throws Exception { // @formatter:off http.csrf().disable().authorizeRequests().antMatchers("/api/client/findByVariable?variable=").permitAll();

我正在使用Spring security开发一个应用程序

    @Override
    public void configure(HttpSecurity http) throws Exception {

        // @formatter:off
        http.csrf().disable().authorizeRequests().antMatchers("/api/client/findByVariable?variable=").permitAll();
        http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and().requestMatchers()
                .antMatchers("/api/**").and().authorizeRequests().antMatchers("/api/**")
                .access("#oauth2.hasScope('read') or (!#oauth2.isOAuth() and hasRole('USER'))");
        // @formatter:on
    }
我如何修改上述代码,使端点/api/client/findByVariable?variable=可以在不需要身份验证的情况下被访问,就像没有Spring安全性一样? 我尝试添加一行:

    http.csrf().disable().authorizeRequests().antMatchers("/api/client/findByVariable?variable=").permitAll();

但它不起作用

您可以忽略端点,并覆盖为您提供WebSecurity实例的configure方法:

@凌驾 公共无效配置web安全性web { web.ignering.antMatchers/api/client/findByVariable; } 我不确定是否也可以通过/api/client/findByVariable?variable之类的查询参数进行匹配=*