openldap 管理可以通过 ldif 文件导入配置和管理,也可以通过 GUI 界面的 ldapadmin 工具,或者是 phpldapadmin 来管理。不过也有一个项目叫 LDAP TOOL BOX PROJECT,能更好的使用 openldap 服务。
项目有一句 slogan,BECAUSE EVEN LDAP ADMINISTRATORS NEED HELP。官方网站。Github 托管地址。
比如自助修改密码服务,需要自助修改 openldap 的登录信息,忘记密码重置等工作,可以部署 self service password 服务。官方的安装文档。
安装 php 7
由于 centos 7 默认源的 php 版本为 PHP 5.4.16,部署 LTB 服务需要 php 版本为 php 7 以上。可以从第三方源安装 php7。
1 2 3 4 5 6 7 8 9
| rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm rpm -Uvh https://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum-config-manager --enable remi-php74
yum makecache
yum install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysqlnd php-xml
|
安装的 php 版本为 PHP 7.4.29 (cli) (built: Apr 12 2022 10:55:38) ( NTS )。
安装 php-fpm,php-Smarty 等依赖:
1 2 3 4 5
| yum install php-Smarty php74-php-fpm php74-php-gd php74-php-json php74-php-mbstring php74-php-xmlrpc php74-php-opcache php74-php-ldap
systemctl start php74-php-fpm.service systemctl enable php74-php-fpm.service
|
安装 apache
self service password 的 web 管理页面,使用 apache 做容器。
apache 启动管理及防火墙配置:
1 2 3 4 5
| systemctl start httpd systemctl enable httpd firewall-cmd --permanent --add-service=http firewall-cmd --permanent --add-service=https firewall-cmd --complete-reload
|
添加 LTB 源
添加 ldap tool box 官方源,以及 self service password 源:
1 2
| cd /etc/yum.repos.d vim ltb-project.repo
|
repo 配置内容:
1 2 3 4 5 6
| [ltb-project-noarch] name=LTB project packages (noarch) baseurl=https://ltb-project.org/rpm/$releasever/noarch enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-LTB-project
|
导入 GPG 证书并更新源:
1 2 3 4 5
| rpm --import https://ltb-project.org/wiki/lib/RPM-GPG-KEY-LTB-project
yum makecache
|
安装 self service password
yum 安装 self service password:
1
| yum install self-service-password
|
配置 self service password
self service password 安装结束后,在 apache 配置目录生成对应的配置文件。配置文件如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| <VirtualHost *:80> ServerName ssp.example.com
DocumentRoot /usr/local/self-service-password/htdocs DirectoryIndex index.php
AddDefaultCharset UTF-8
<Directory /usr/local/self-service-password/htdocs> AllowOverride None <IfVersion >= 2.3> Require all granted </IfVersion> <IfVersion < 2.3> Order Deny,Allow Allow from all </IfVersion> </Directory>
Alias /rest /usr/local/self-service-password/rest
<Directory /usr/local/self-service-password/rest> AllowOverride None <IfVersion >= 2.3> Require all denied </IfVersion> <IfVersion < 2.3> Order Deny,Allow Deny from all </IfVersion> </Directory>
LogLevel warn ErrorLog /var/log/apache2/ssp_error.log CustomLog /var/log/apache2/ssp_access.log combined </VirtualHost>
|
nginx 配置可以见官方文档页面。
self service password 的配置文件在 /usr/share/self-service-password/ 目录下。
主要配置如下:
语言
显示菜单
是否显示顶部菜单:
帮助信息
是否显示帮助信息:
自定义帮助信息示例:
1 2
| $messages['passwordchangedextramessage'] = "Congratulations!"; $messages['changehelpextramessage'] = "Contact us if you are lost...";
|
安全
需要配置加密令牌的关键字。默认 secret,需要自己更改,不然无法使用 self service password。
1
| $keyphrase = "your-secret-key";
|
更改令牌字符排除字符:
1
| $login_forbidden_chars = "*()&|";
|
如果不更改默认配置,则默认只允许字母和数字。
LDAP 连接
Server Address
配置 LDAP 连接地址:
1 2
| $ldap_url = "ldap://localhost:389";
|
多个 LDAP 服务配置:
1
| $ldap_url = "ldap://server1 ldap://server2";
|
OpenLDAP SSL 配置:
1
| $ldap_url = "ldaps://localhost";
|
OpenLDAP StartTLS 配置:
证书文件配置:
1
| TLS_CACERT /etc/ssl/ca.crt
|
证书检查配置:
如果 SSP 和 LDAP 之间遇到 TLS 版本不匹配问题,可以配置以下选项:
1
| TLS_CIPHER_SUITE TLSv1+RSA
|
DN 配置
配置绑定域和密码:
1 2 3
| $ldap_binddn = "cn=ssp,ou=dsa,dc=example,dc=com"; $ldap_bindpw = "secret";
|
谁能修改密码,manager 或 user:
1
| $who_change_password = "user";
|
搜索参数:
1 2
| $ldap_base = "dc=example,dc=com"; $ldap_filter = "(&(objectClass=person)(uid={login}))";
|
其它参考 self service password 配置文件说明。
安装结束,参考页面:
