【问题标题】:Spring Security and LDAP MD5 authenticationSpring Security 和 LDAP MD5 认证
【发布时间】:2012-10-15 01:50:18
【问题描述】:

我需要使用密码比较对密码以 LDAP MD5 十六进制编码格式存储的用户进行弹簧安全认证。对于 LDAP SHA 编码,我可以使用LDAPShaPasswordEncoder。我应该为 LDAP MD5 编码使用哪个编码器?

【问题讨论】:

    标签: spring-security ldap spring-ldap


    【解决方案1】:
    <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>
    

    【讨论】:

      【解决方案2】:

      没有一个支持 MD5。你必须自己实现PasswordEncoder。您可以使用LdapShaPasswordEncoder 作为指导。它应该非常简单,尤其是在不涉及盐的情况下。

      您可能应该开始考虑迁移到一个更安全的系统,该系统在哈希中包含盐。例如,也许您的目录可以支持多种格式,并且您可以将 SSHA 用于新用户或密码更改。

      【讨论】:

        猜你喜欢
        • 2016-08-11
        • 2012-03-28
        • 2013-05-08
        • 2012-02-18
        • 2013-01-26
        • 2018-11-03
        • 2015-03-26
        • 2019-05-11
        • 2015-10-12
        相关资源
        最近更新 更多