下面是我的代码。当我评论@EnableGlobalMethodSecurity
时,
AADAuthenticationFilter
正确地自动接线,但是每当我尝试包含!EnableGlobalMethodSecurity
时,都会抛出错误,即找不到AADAuthenticationFilter
的bean
@EnableGlobalMethodSecurity
public class WebAuthentication extends WebSecurityConfigurerAdapter {
@Autowired
private AADAuthenticationFilter aadAuthFilter;
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/*").permitAll();
//http.authorizeRequests().antMatchers("/api/**").authenticated();
//http.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
// .logoutSuccessUrl("/").deleteCookies("JSESSIONID").invalidateHttpSession(true);
//http.authorizeRequests().anyRequest().permitAll();
//http.csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse());
http.addFilterBefore(aadAuthFilter, UsernamePasswordAuthenticationFilter.class);
}
}