我有一个使用 REST 服务进行 LDAP 身份验证的项目。我的 LDAP 配置具有 Salted SHA (SSHA) 密码哈希方法。在 Spring 的支持 SHA 方法的 LDAP 身份验证最佳实践指南中,当我使用该方法时,我得到了错误的凭据,而凭据却正常。
我的配置类参考:
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth
.ldapAuthentication()
.userSearchFilter("uid={0}")
.contextSource(contextSource())
.passwordCompare()
.passwordEncoder(new LdapShaPasswordEncoder())
.passwordAttribute("userPassword");
}
@Bean
public DefaultSpringSecurityContextSource contextSource() {
return new DefaultSpringSecurityContextSource(Arrays.asList("ldap://localhost:8389/"), "dc=springframework,dc=org");
}
}
Run Code Online (Sandbox Code Playgroud)
我的 ldif 配置;
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: {SSHA}pcFdFhO/NS98EhTRup60PMkHMWFRDkJ3jUu1Zg==
Run Code Online (Sandbox Code Playgroud)
我原来的密码是Test1234. 我的pom.xml …