配置openldap自助修改密码服务

openldap 管理可以通过ldif文件导入配置和管理,也可以通过GUI界面的ldapadim工具,或者是phpldapadmin来管理,不过也有一个项目叫LDAP TOOL BOX PROJECT,能更好的使用openldap服务。项目有一句sologan,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配置php版本
yum-config-manager --enable remi-php74
# 更新源
yum make-cache
# 安装php,以及php依赖
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
# php74-php-ldap必须安装。

systemctl start php74-php-fpm.service
systemctl enable php74-php-fpm.service

安装apache

self service password的web管理页面,使用apache做容器。

1
yum install httpd

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
3
4
5
6
7
8
9
10
11
12
13
14
cd /etc/yum.repo.d
vim ltb-project.repo
[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

# 导入GPK证书
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
# Default language
$lang = "zh-CN";
显示菜单

是否显示顶部菜单。

1
$show_menu = true;
帮助信息

是否显示帮助信息。

1
$show_help = false;

自定义帮助信息示例。

1
2
$messages['passwordchangedextramessage'] = "Congratulations!";
$messages['changehelpextramessage'] = "Contact us if you are lost...";
安全

需要配置加密令牌的关键字。默认seret,需要自己更改,不然无法使用self service password。

1
$keyphrase = "secret";

更改令牌字符排除字符。

1
$login_forbidden_chars = "*()&|";

如果不更改默认配置,则默认只允许字母和数字。

ldap连接
server address

配置ldap连接地址:

1
2
$ldap_url = "ldap://localhost:389";
# url 后面接本地或远程ldap服务地址

多个ldap服务配置:

1
$ldap_url = "ldap://server1 ldap://server2";

openldap ssl密码:

1
$ldap_url = "ldaps://localhost";

openldap StartTLS配置:

1
$ldap_starttls = true;

证书文件配置:

1
TLS_CACERT /etc/ssl/ca.crt

证书检查配置:

1
TLS_REQCERT allow

如果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";
# 根据自己实际的ldap信息修改

谁能修改密码,manager或user。

1
$who_change_password = "user";

搜索参数:

1
2
$ldap_base = "dc=example,dc=com";
$ldap_filter = "(&(objectClass=pe名访问rson)(uid={login}))";

其它参考self service password配置文件说明。

安装结束,参考页面:
self-service-password


配置openldap自助修改密码服务
https://ywmy.xyz/2022/05/03/配置openldap自助修改密码服务/
作者
ian
发布于
2022年5月3日
许可协议