我需要进行弹簧安全身份验证,其中使用密码在LDAP MD5 HEX中存储的用户使用密码进行比较。对于LDAP SHA编码,我可以使用LDAPShaPasswordEncoder
。我应该将哪个编码器用于LDAP MD5编码?
<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用于新用户或密码更改。