【发布时间】:2021-03-15 15:25:05
【问题描述】:
我正在阅读这篇春季 LDAP 集成文章:https://spring.io/guides/gs/authenticating-ldap/
本文包含一个示例 LDIF 文件,其中密码以明文形式显示。
dn: uid=bob,ou=people,dc=springframework,dc=org
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: Bob Hamilton
sn: Hamilton
uid: bob
userPassword: bobspassword
但是这个用户的密码是加密的
dn: uid=ben,ou=people,dc=springframework,dc=org
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: Ben Alex
sn: Alex
uid: ben
userPassword: $2a$10$c6bSeWPhg06xB1lvmaWNNe4NROmZiSpYhlocU/98HNr2MhIOiSt36
只是想知道,这是否可以在 LDAP 服务器上进行配置。为什么一个用户的密码被加密而其他用户的密码不被加密?
然而,我看到这个例子中的 spring security 被配置为使用 BCrypt 密码编码器。
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth
.ldapAuthentication()
.userDnPatterns("uid={0},ou=people")
.groupSearchBase("ou=groups")
.contextSource()
.url("ldap://localhost:8389/dc=springframework,dc=org")
.and()
.passwordCompare()
.passwordEncoder(new BCryptPasswordEncoder())
.passwordAttribute("userPassword");
}
建议登录的演示用户为ben,密码为benpassword。只是想知道如果我以另一个用户身份登录会发生什么,我想我应该被拒绝,因为 spring 使用 bcrypt 并且 ldap 中其他用户的密码没有被编码。
【问题讨论】:
标签: spring-security ldap spring-ldap spring-security-ldap