Spring Security WebSecurityConfig需要安全区域和不安全区域

问题描述:

试图让我的WebSecurityConfigurerAdapter将某些过滤器放置在“/ secured /”上下文中,然后其他URL不在这些过滤器后面。Spring Security WebSecurityConfig需要安全区域和不安全区域

这里是我到目前为止,但一切都打到TokenFilter

protected void configure(HttpSecurity http) throws Exception { 
    http.antMatcher("/secured/**").addFilterBefore(new TokenAuthenticationFilter(tokenAuthService, environment), 
      ExceptionTranslationFilter.class). 
      addFilterBefore(new RequestContentBufferFilter(), TokenAuthenticationFilter.class) 
      .antMatcher("/**").anonymous() 
      .and().csrf().disable(); 

} 

任何帮助吗?

我结束了使用WebSecurity范畴内增添端点安全的黑名单忽略这样的:

public void configure(WebSecurity web) throws Exception { 
    web 
    .ignoring() 
     .antMatchers("/metrics**") 
     .antMatchers("/health**") 
     .antMatchers("/logfile**") 
     .antMatchers("/systemcheck**"); 
}