【发布时间】:2018-05-07 18:52:04
【问题描述】:
我希望我的 Web 应用程序的用户通过 LDAP 和其他自定义身份验证进行身份验证。这是一个用 Kotlin 编写的 Spring Boot 应用程序。我已将 AuthenticationManagerBuilder 配置如下
@Autowired
lateinit var authenticationProvider: CustomAuthenticationProvider
override fun configure(auth: AuthenticationManagerBuilder) {
auth
.authenticationProvider(authenticationProvider)
auth
.ldapAuthentication()
.userDnPatterns("uid={0},ou=people")
.groupSearchBase("ou=groups")
.contextSource()
.url("ldap://localhost:8389/dc=example,dc=com")
.and()
.passwordCompare()
.passwordEncoder(PlaintextPasswordEncoder())
.passwordAttribute("userPassword")
}
我想链接身份验证,以便如果 CustomAuthenticationProvider 成功进行身份验证(函数身份验证不抛出),身份验证继续使用 LDAP 身份验证提供程序。
如果 CustomAuthenticationProvider 成功通过身份验证,则不会评估 LDAP 身份验证(以及任何后续身份验证提供程序)。仅当 CustomAuthenticationProvider 抛出时,才会执行 LDAP 身份验证。
我已经阅读了许多文章(例如 Multiple Authentication Providers in Spring Security),其中详细说明了具有多个身份验证提供程序但具有 OR 行为而不是 AND 行为。有什么建议吗?
【问题讨论】:
-
这怎么可能?如果您的身份验证提供程序公开身份验证,为什么要 LDAP 进行身份验证,您已经通过身份验证。唯一的方法是,您的身份验证提供程序不会公开身份验证。所以你还没有通过身份验证。
标签: spring authentication spring-security kotlin