【发布时间】:2019-10-04 12:31:13
【问题描述】:
我正在尝试使用 Kotlin 将 2 个身份验证提供程序与 Spring Boot 一起使用:
这个方法在一个类中:
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
@Import(SecurityProblemSupport::class)
class SecurityConfiguration(
...
) : WebSecurityConfigurerAdapter() {
@Throws(Exception::class)
override fun configure(auth: AuthenticationManagerBuilder) {
//super.configure(auth); DON'T DO THIS - for sure...
val dap = DaoAuthenticationProvider()
dap.setUserDetailsService(domanUserDetailsService)
auth.authenticationProvider(LegacyUserDaoAuthenticationProvider(legacyUserService)) .
auth.authenticationProvider(dap)
// Breakpoint here shows that both authentication providers are in the builder
}
...
}
当我在应用程序运行后运行调试器时,ProviderManager 只有 1 个提供程序。不知何故,AuthenticationManagerBuilder 没有使用这里添加的 2 个authenticationProviders。我验证了我的 configure 方法正在被调用,并且 AuthenticationManagerBuilder 在此方法之后有 2 个身份验证提供程序。
在我在这里完成的设置上发生了一些事情(或者 Spring 没有使用我设置的 AuthenticationManagerBuilder。
有人知道为什么吗?
【问题讨论】:
标签: spring spring-boot kotlin