zoukankan      html  css  js  c++  java
  • Openldap基于digestmd5方式的SASL认证配置

    1. openldap编译

    如果需要openldap支持SASL认证,需要在编译时加上–enable-spasswd选项
    安装完cyrus-sasl,openssl(可选),BDB包后执行:

    注:
    /usr/local/lib为 libsasl2.so.2所在目录
    /usr/local/BerkeleyDB.4.8/lib为 libdb-4.8.so所在目录
    /lib/i386-linux-gnu/为 libssl.so.1.0.0所在目录

    安装完毕后

    输出:

    可以看到默认已经提供DIGEST-MD5方式 的SASL机制。

    2. slapd.conf配置

    配置输出:

    2.1 用户密码相关配置

    参考http://www.openldap.org/doc/admin24/sasl.html#DIGEST-MD5
    This section describes the use of the SASL DIGEST-MD5 mechanism using secrets stored either in the directory itself or in Cyrus SASL’s own database.
    这里提到了两种管理用户密码的方式
    a.对于第一种:
    To use secrets stored in sasldb, simply add users with the saslpasswd2 command:

    The passwords for such users must be managed with the saslpasswd2 command.
    b.对于第二种:
    To use secrets stored in the LDAP directory, place plaintext passwords in the userPassword attribute. It will be necessary to add an option to slapd.conf to make sure that passwords set using the LDAP Password Modify Operation are stored in plaintext:

    Passwords stored in this way can be managed either with ldappasswd(1) or by simply modifying the userPassword attribute. Regardless of where the passwords are stored, a mapping will be needed from authentication request DN to user’s DN.
    在 这里,我采用了第二种。根据文档说明,这种方式的密码是存在userPassword属性中的,因此每个需要进行认证的用户都必须有一个 userPassword属性。并且通过在slapd.conf文件中通过指定password-hash {CLEARTEXT}来确保密码存储为明文的文本格式。
    由于每个认证用户都必须有一个userPassword属性,因此对应的条目必须具有一个含有userPassword 属性的objectclass,我采用 simpleSecurityObject这个objectclass,这是一个辅助objectclass(区别于structual objectclass),仅包含一个必要属性userPassword.
    参见core.schema:

    因此可以将管理员用户的ldif数据文件配置为:
    manager.ldif:

    2.2 认证ID与实际条目映射

    参考http://www.openldap.org/doc/admin24/sasl.html#Mapping%20Authentication%20Identities
    The DIGEST-MD5 mechanism produces authentication IDs of the form:

    If the default realm is used,the realm name is omitted from the ID, giving:

    对于我们的例子,配置管理员认证ID为:

    认证ID与实际的LDAP条目之间有两种映射方式:direct mapping和search-based mappings.
    Where possible, direct mapping of the authentication request DN to the user’s DN is generally recommended. Aside from avoiding the expense of searching for the user’s DN, it allows mapping to DNs which refer to entries not held by this server.
    基于以上原因,采用direct mapping方式。
    The LDAP administrator will need to tell the slapd server how to map an authentication request DN to a user’s authentication DN. This is done by adding one or more authz-regexp directives to the slapd.conf(5) file. This directive takes two arguments:

    Suppose the authentication request DN is written as:

    and the user’s actual LDAP entry is:

    then the following authz-regexp directive in slapd.conf(5) would provide for direct mapping.

    对于我们的例子则是:

    依据正则表达式的语法,([^,]*)匹配直到遇到逗号之前的字符,$1反向引用([^,]*)中的内容。

    3 导入管理员用户信息

    采 用这种方式时认证用户包括管理员的密码都是存储在ldap目录中的,也就是说,管理员本身的信息也是需要导入的,而在这种方式下rootdn的配置不满足 suffix的要求,不能设置rootpw选项,也就不能绑定管理员用户使用ldapadd命令进行管理员信息导入了,那管理员本身的信息如何导入呢?可 以通过以下命令:

    4 数据操作

    开启openldap服务器

    导入ldif数据文件,添加数据

    manager:管理员用户的DN为AstAccountName=manager,ou=accounts,dc=com,根据映射关系,对应的uid就是这里的AstAccountName属性的值manager。
    grandstream:对应userPassword属性的值,即管理员密码。
    gs_phonebook.ldif:要导入的ldif数据文件。
    查询数据

    删除数据

    或递归删除

  • 相关阅读:
    【Vue教程系列:第一篇】Win7 搭建Vue开发环境
    MVC 之 WebAPI 系列二
    MVC 之 WebAPI 系列一
    Javascript 截取2位小数
    Javascript 处理时间大全
    SpringBoot是如何动起来的?
    超全、超详的Spring Boot配置讲解笔记
    Java数据结构-ArrayList最细致的解析笔记
    Redis 到底是怎么实现“附近的人”这个功能的?
    02--Java Jshell的使用 最适合入门的Java教程
  • 原文地址:https://www.cnblogs.com/lijingcheng/p/4454802.html
Copyright © 2011-2022 走看看