小编mir*_*man的帖子

Spring LDAP 身份验证 Salted SHA 类型中的错误凭据密码

我有一个使用 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 …

java spring spring-security spring-ldap ssha

5
推荐指数
1
解决办法
7459
查看次数

标签 统计

java ×1

spring ×1

spring-ldap ×1

spring-security ×1

ssha ×1