【问题标题】:Does LDAP store user password in clear text or as encoded text?LDAP 是以明文形式还是以编码文本形式存储用户密码?
【发布时间】:2021-03-15 15:25:05
【问题描述】:

我正在阅读这篇春季 LDAP 集成文章:https://spring.io/guides/gs/authenticating-ldap/

本文包含一个示例 LDIF 文件,其中密码以明文形式显示。

dn: uid=bob,ou=people,dc=springframework,dc=org
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: Bob Hamilton
sn: Hamilton
uid: bob
userPassword: bobspassword

但是这个用户的密码是加密的

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: $2a$10$c6bSeWPhg06xB1lvmaWNNe4NROmZiSpYhlocU/98HNr2MhIOiSt36

只是想知道,这是否可以在 LDAP 服务器上进行配置。为什么一个用户的密码被加密而其他用户的密码不被加密?


然而,我看到这个例子中的 spring security 被配置为使用 BCrypt 密码编码器。

@Override
  public void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth
      .ldapAuthentication()
        .userDnPatterns("uid={0},ou=people")
        .groupSearchBase("ou=groups")
        .contextSource()
          .url("ldap://localhost:8389/dc=springframework,dc=org")
          .and()
        .passwordCompare()
          .passwordEncoder(new BCryptPasswordEncoder())
          .passwordAttribute("userPassword");
  }

建议登录的演示用户为ben,密码为benpassword。只是想知道如果我以另一个用户身份登录会发生什么,我想我应该被拒绝,因为 spring 使用 bcrypt 并且 ldap 中其他用户的密码没有被编码。

【问题讨论】:

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


    【解决方案1】:

    这将取决于 LDAP 服务器,特别是如何处理密码。但是,是的,它们通常以某种加密/散列方式存储。例如,在 Oracle Directory Server 中,密码策略有一个“密码存储方案”,用于控制密码的存储方式。在某些目录服务器中,可能以明文形式存储用户密码。在这种情况下,任何对密码具有读取权限的人都可以从用户帐户中提取密码。不是我见过的在沙盒之外设置的东西。

    您正在查看的 LDIF 将密码以明文形式提供给服务器,但服务器会根据服务器/密码策略配置对值进行哈希/加密,然后再将其存储在对象上。

    【讨论】:

    • "Password storage scheme" 。 Gr8。这就是答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-18
    • 1970-01-01
    • 2015-04-15
    • 2018-03-25
    • 2023-01-31
    相关资源
    最近更新 更多