【发布时间】:2012-10-15 01:50:18
【问题描述】:
我需要使用密码比较对密码以 LDAP MD5 十六进制编码格式存储的用户进行弹簧安全认证。对于 LDAP SHA 编码,我可以使用LDAPShaPasswordEncoder。我应该为 LDAP MD5 编码使用哪个编码器?
【问题讨论】:
标签: spring-security ldap spring-ldap
我需要使用密码比较对密码以 LDAP MD5 十六进制编码格式存储的用户进行弹簧安全认证。对于 LDAP SHA 编码,我可以使用LDAPShaPasswordEncoder。我应该为 LDAP MD5 编码使用哪个编码器?
【问题讨论】:
标签: spring-security ldap spring-ldap
<bean id="ldapAuthenticationProvider"
class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
<constructor-arg>
<bean class="org.springframework.security.ldap.authentication.PasswordComparisonAuthenticator">
<constructor-arg ref="contextSource" />
<property name="passwordEncoder">
<bean class="org.springframework.security.authentication.encoding.Md5PasswordEncoder" />
</property>
<property name="userDnPatterns">
<list>
<value>uid={0},ou=people</value>
</list>
</property>
</bean>
</constructor-arg>
<constructor-arg>
<bean
class="org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator">
<constructor-arg ref="contextSource" />
<constructor-arg value="ou=groups" />
<property name="groupSearchFilter" value="(member={0})" />
<property name="rolePrefix" value="ROLE_" />
<property name="searchSubtree" value="true" />
<property name="convertToUpperCase" value="true" />
</bean>
</constructor-arg>
</bean>
【讨论】:
没有一个支持 MD5。你必须自己实现PasswordEncoder。您可以使用LdapShaPasswordEncoder 作为指导。它应该非常简单,尤其是在不涉及盐的情况下。
您可能应该开始考虑迁移到一个更安全的系统,该系统在哈希中包含盐。例如,也许您的目录可以支持多种格式,并且您可以将 SSHA 用于新用户或密码更改。
【讨论】: