cosven / cosven.github.io

个人零碎笔记,博客草稿,阅读笔记
10 stars 0 forks source link

OpenLDAP 实践笔记 #33

Closed cosven closed 5 years ago

cosven commented 8 years ago

LDAP - Lightweight Directory Access Protocol

OpenLDAP install

自己编译安装 OpenLDAP

为啥要自己编译安装:mac 可以 brew install openldap,但是找不到 slapd 程序 Ubuntu 可以安装 slapd 和 ldap-utils,但是教程太少。比如说找不到该有的配置文件。

参考教程:http://www.linuxidc.com/Linux/2016-05/130997.htm

  1. download and install Berkeley Db 5.1
  2. compile them

configure 需要 enable 的模块: CPPFLAGS="-I/usr/local/BerkeleyDB.5.1/include" LDFLAGS="-L/usr/local/BerkeleyDB.5.1/lib" ./configure --enable-crypt --enable-ppolicy --enable-modules 正解:这个说 configure 的时候要加入 ppolicy 字段 http://xacmlinfo.org/2015/06/25/enable-hash-passwords-in-openldap/ 要支持 Group,还需要 --enable-memberof

OpenLDAP vs Apache Directory

并没有比出什么东西来

X500 authorization

ApacheDS

OpenLDAP Directory Services

The first form is 'attribute=value' used when it is part of a DN, and the other form is 'attribute: value' when it is used elsewhere in an Entry

conclusion-1: We know, now, that attribute is a basic piece of data, that objectclass is a packaging of attributes into useful forms, and that attributes and objectclasses are physically contained in schema file.

各种各样的 attribute 简写: http://www.zytrax.com/books/ldap/ape/

Basic Concept

  1. objectclass

    objectclasses may be STRUCTURAL, in which case they can be used to create entries objectclasses may be AUXILIARY, in which case they may be added into any convenient entry objectclasses may be ABSTRACT, a non-existent 'thingie'

    objectclass 是一组 attribute

  2. attributes
    • 每个 attribute 在 schema 中定义
    • 每个 attribute 被包含在一个或者多个 objectclass 中
  3. entries

    group sets of objectclass within a DIT

    Authentication using LDAP

使用 nis.schema 进行身份验证 设置 replication 在使用一个集中的身份验证数据库时,应该通过使用复制技术采用第二个 LDAP 服务器提供高可用性

GSSAPI is an application programming interface for programs to access security services Kerberos is a computer network authentication protocol

SASL

Simple Authentication and Security Layer (SASL) framework

Python LDAP Client

https://www.python-ldap.org/docs.html

python searchs filter 包含 userPassword 时,需要传输 hash 之后的值

实际应用概述

  1. 如果是这种 wifi 验证,是可以做到

    https://supportforums.cisco.com/document/104756/how-configure-wireless-lan-controller-wlc-lightweight-directory-access-protocol-ldap

    • 但是存在问题:密码在 WiFi 上可不可以加密传输 ?
    • 不知道会有些什么潜在的问题?比如 扩展
  2. 如果是 OpenVPN 类似这个

    https://www.howtoforge.com/setting-up-an-openvpn-server-with-authentication-against-openldap-on-ubuntu-10.04-lts

  3. 目前状态
    1. 整个安装过程知道。就两个坑:一个是安装 Berkeley DB,一个是系统源的都不好用。
    2. 它的一套客户端工具怎么使用查文档知道大概有什么用:比如 ldapadd, ldapmodify, ldapsearch
    3. 一些基础概念:比如 schema、attribute、entry。 搞清楚了一些它的简写的意义(对看懂一些文档有作用)
    4. 知道怎样使用 Python-LDAP 库对 OpenLDAP server 进行一些简单的查询操作
    5. 知道要做复杂的 Authentication 是要用 SASL,它使用的技术是 Kerberos V…(细节正在看,感觉有点复杂)最后发现,这种需求貌似较少。或者说这种需求可以考虑 Oauth2.0 那样的协议
  4. OpenVPN & OpenLDAP

    openvpn 使用 openldap 做验证 搭建 openvpn 服务

  5. openldap 常见命令
    • ldapadd -x -D "dc=example,dc=com" -W -f example.ldif
    • slappasswd -h {MD5} -s mypassword

      坑 !!!

  6. schema include 顺序会影响 slapd 启动

    OpenLDAP 主从同步

  7. 主从配置方法

    一定要加 overlay syncrepl

    官方文档阅读

http://www.openldap.org/doc/admin24/replication.html

之前版本 master 从 client 接受更新,slave 只从一个 master 接受更新,它们的角色非常固定。 现在比较灵活,一个 slave 从 master 同步之后,slave 之间也可以更新 总共 4 种同步复制技术

  1. LDAP Sync Replication - syncrepl

    consumer 连接到 replication provider,定时 polling、 当数据改变时也会更新。 它提供一个有状态的复制,支持 pull-based 和 push-based 同步、不授权使用历史储存。 因为没有历史储存,所以他不需要维护更新日志。 原理:…通过 synchroization cookies 结果:通过 syncrepl,一个 consumer server 可以在不改变 provider 的配置,不重启 provider 的情况下生成一份复制。

  2. Delta-syncrepl

    syncrepl 缺点:一个 object 的任意一个 attribute 改变时,它需要处理整个 object,无论其他 attribute 是否改变。\ 所以当多个 object 都改变的时候,数据量会比较大,server 有可能挂掉

    Delta-syncrepl 维护一个 changelog,然后复制时只传输改变的 attribute。

  3. N-Way Multi-Master replication
  4. MirrorMode replication

    两个 provider 互相复制,两个都是 master,都提供服务。

  5. Group 配置

    https://www.rainingpackets.com/ldap-posixgroup-groupofnames/

    posixGroup: Uses the memberUid attribute which contains only the value of the UID of a users full DN. For example:

    cn=SomeGroup,ou=Groups,dc=example,dc=com memberUID: someuser

    groupofNames: Uses the member attribute which contains the full DN of the user. For example:

    cn=SomeGroup,ou=Groups,dc=example,dc=com member: uid=someuser,ou=People,dc=example,dc=com

    OpenLDAP 权限控制

把握两个顺序:权限控制 从上到下从细到粗