【问题标题】:How to avoid plain text LDAP password in spring security?如何避免春季安全中的纯文本LDAP密码?
【发布时间】:2016-03-01 08:27:42
【问题描述】:

我刚刚设法让我的 OpenLDAP + Spring Security 工作,一切正常,除了在 spring security xml 中的一个小问题,我必须在那里输入纯文本密码:

<beans:bean id="ldapContextSource" class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
    <beans:constructor-arg value="ldap://153.65.x.y:389/dc=example,dc=com" />
    <beans:property name="userDn" value="cn=Manager,dc=example,dc=com" />
    <beans:property name="password" value="secret" />
</beans:bean> 

有什么办法可以避免吗?


当我设置我的 OpenLDAP 时,我实际上可以在 slapd.conf 中添加摘要而不是纯文本密码:

rootpw {SSHA}ZMFfVNPAazmLcif1xC2l9y9SFdKd+x4

所以我希望 spring security 可以做类似的事情。


编辑:

我刚刚意识到这里没有必要放 LDAP 管理员名称和密码,只需提供 uri 就足以让 spring security 工作:

<beans:bean id="ldapContextSource" class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
    <beans:constructor-arg value="ldap://153.65.x.y:389/dc=example,dc=com" />
</beans:bean> 

我在这里有一些误解。 当我尝试编写此示例时,我从 google 获得的很多示例将管理器名称和密码放入 spring security xml 中。 所以我曾经认为这就像通过 JDBC 连接数据库一样,我们必须提供数据库用户名和密码。这不是真的,不需要管理员名称和密码。

【问题讨论】:

    标签: spring-security ldap spring-security-ldap


    【解决方案1】:

    您能够将 rootpw 存储为 LDAP 服务器上的 SSHA 的原因是因为它不需要知道您的原始密码来验证它 - 摘要(在这种情况下是 SSHA - 加盐安全哈希)就足够了。但是,客户端需要发送原始密码,以便服务器可以计算哈希并将其与存储的密码进行比较。

    spring 充其量可以为客户端的密码存储提供某种加密,但我对此并不熟悉。

    编辑:StackOverflow Encrypting a password within a Spring configuration file 链接到此:http://www.jasypt.org/spring3.html

    【讨论】:

    • 好的,digest 可能不是一个好主意,但我仍然希望 spring security 可以提供双向加密,这样我就可以将加密的密码放在 springsecurity.xml 中,spring security 可以自动解密并发送到 LDAP。
    猜你喜欢
    • 2017-11-30
    • 2012-11-30
    • 1970-01-01
    • 1970-01-01
    • 2021-08-20
    • 2016-04-16
    • 2013-12-22
    相关资源
    最近更新 更多