添加@EnableGlobalMethodSecurity时无法自动装配AADAuthenticationFilter

时间:2019-07-08 13:24:13

标签: spring spring-boot spring-security autowired bean-validation

下面是我的代码。当我评论@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);
    }
}

0 个答案:

没有答案