Spring 如何将自定义ProviderManager注入AuthenticationManagerBuilder

Spring 如何将自定义ProviderManager注入AuthenticationManagerBuilder,spring,spring-security,Spring,Spring Security,在我的Spring Boot应用程序中,我推出了我的定制MyProviderManager,我想在其中控制方法身份验证 但是,我现在很难将自定义的MyProviderManager注入AuthenticationManagerBuilder,这样AuthenticationManagerBuilder中的performBuild()方法将返回MyProviderManager,而不是Spring Security中的默认方法 我甚至试着拿出我的自定义MyAuthenticationManager

在我的Spring Boot应用程序中,我推出了我的定制
MyProviderManager
,我想在其中控制方法
身份验证

但是,我现在很难将自定义的
MyProviderManager
注入AuthenticationManagerBuilder,这样AuthenticationManagerBuilder中的
performBuild
()方法将返回
MyProviderManager
,而不是Spring Security中的默认方法

我甚至试着拿出我的自定义
MyAuthenticationManagerBuilder
exends
AuthenticationManagerBuilder
并重写
performBuild
()方法,但我面临着如何将自定义AuthenticationManagerBuilder注入Spring Boot的同样问题


如果有人能在这里阐明这些问题,或者有更好的替代方案来解决我的特殊需求,我将不胜感激

如果您有一个自定义的AuthenticationManager实现,您将不再使用AuthenticationManager Builder(这是构建AuthenticationManager的方法,但您已经有了AuthenticationManager)。而是将AuthenticationManager作为bean公开,并且不使用AuthenticationManagerBuilder

@Bean
CustomAuthenticationManager customAuthenticationManager() {
    return new CustomAuthenticationManager();
}

这回答了你的问题吗?ProviderManager迭代所有AuthenticationProvider(包括自定义AuthenticationProvider)。我希望有一个自定义ProviderManager,在这里我可以更好地控制哪个AuthenticationProvider将用于哪个URL路径它是否指示我不应覆盖
受保护的无效配置(AuthenticationManagerBuilder auth)
受保护的无效配置(AuthenticationManagerBuilder auth)
在扩展了
websecurityconfig适配器的MySecurityConfig中
?相反,
CustomAuthenticationManager
应该自己实例化所有必要的
AuthenticationProvider
列表,对吗?
@Bean
CustomAuthenticationManager customAuthenticationManager() {
    return new CustomAuthenticationManager();
}