CAS统一登录认证(15): 用户自助修改密码,忘记密码处理

    我的cas统一登录验证采用ldap存储和验证账号,用户修改密码或密码忘记了怎么办,当然,管理员可以重设用户密码,但为了解放管理员工作量,提高用户体验,需要用户自主维护账号密码。

   经过比较,最后采用 php的 self-service-password 软件。

官网地址: https://ltb-project.org/documentation/self-service-password

1.下载安装的是v1.3 简单配置即可使用

2. 软件提供四种方式修改密码

(1)自主密码服务: 通过输入原来密码验证输入新的密码

  (2) 预留问题及答案:回答预留问题,如生日等,回答正确即可直接输入新密码

  (3) 邮件修改密码: 会发送一个修改密码的带临时令牌的连接,点击即可输入新密码,可设置为自动发送到ldap数据库登记的第一个邮箱

 (4)短信验证码:发送一个短信验证码到预留在ldap数据库的手机号,输入验证码后即可设置新密码,推荐使用

3.连接ldap基本配置

# LDAP
$ldap_url = "ldap://author.linbsoft.com";
$ldap_starttls = false;
$ldap_binddn = "cn=admin,dc=linbsoft,dc=com";
$ldap_bindpw = "123456";
$ldap_base = "ou=people,dc=linbsoft,dc=com";
$ldap_login_attribute = "uid";
$ldap_fullname_attribute = "cn";
$ldap_filter = "(&(objectClass=person)($ldap_login_attribute={login}))";

4. 通过预留问题答案修改密码

因为需要把问题和答案加密后保存到ldap个人账号下,因此需要有写权限的用户身份

$who_change_password = "manager";

$use_questions = true;

修改 lang/zh-CN.inc.php文件

$messages['questions']['friend'] = "你朋友的名字?";

类似这种格式,其中['friend'] 可以修改为自己的,如['mobile']...

不限问题的个数

5. 邮箱修改密码

## Mail

$mail_address_use_ldap = true;    #通过ldap里的邮箱地址发送

$mail_from = "[email protected]";   # 发邮件的邮箱
$mail_from_name = "Self Service Password";
$mail_signature = "";

$mail_sendmailpath = '/usr/sbin/sendmail';
$mail_protocol = 'smtp';
$mail_smtp_debug = 2;
$mail_debug_format = 'error_log';
$mail_smtp_host = 'linbsoft.com';
$mail_smtp_auth = "login";
$mail_smtp_user = '[email protected]';   #发送邮件的邮箱账号
$mail_smtp_pass = '8888';   #发送邮件的邮箱登录密码
$mail_smtp_port = 25; 
$mail_smtp_timeout = 30;
$mail_smtp_keepalive = false;
$mail_smtp_secure = '';
$mail_smtp_autotls = true;
$mail_contenttype = 'text/plain';
$mail_wordwrap = 0;
$mail_charset = 'utf-8';
$mail_priority = 3;
$mail_newline = PHP_EOL;

5. 短信验证码修改密码

## SMS
$use_sms = true;   #开启短信验证
$sms_method = "api";  #使用api接口发短信
$sms_api_lib = "lib/smsapi.inc.php";  #接口api文件
$sms_attribute = "mobile";  #获取ldap的mobile栏预留的手机号
$sms_partially_hide_number = true;
$sms_message = "{smsresetmessage} {smstoken}";  #短信格式  
$sms_sanitize_number = false;
$sms_truncate_number = false;
$sms_truncate_number_length = 11;  #截取手机号长度
$sms_token_length = 6;   #验证码长度
$max_attempts = 3;    #连续可发三次

发送短信接口文件内容lib/smsapi.inc.php

<?php

function send_sms_by_api($mobile, $message) {
   $url = "http://www.XXXX.com/webservice/sms/Submit?account=abc&password=123456789&mobile=" . $mobile . "&content=" . urlencode("您的验证码是:【" . $message . "】。请不要把验证码泄露给其他人。如非本人操作,可不用理会!");
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL, $url);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_HEADER, 0);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
   $response = curl_exec($ch);
   curl_close($ch);
   return 1;

}

其中  http://www.XXXX.com/webservice/sms/Submit  这是你的短信注册服务商提供的发短信接口地址

account=abc&password=123456789   这是你在短信服务商的账号密码

这个api文件根据不同的短信服务商接口规范可能有所不同

配置好后,点击短信验证,输入你的账号,就会自动收到短信,如:

您的验证码是:〖 347894〗。请不要把验证码泄露给其他人。如非本人操作,可不用理会!【linbsoft】

输入验证码后即可录入新的密码。

  

猜你喜欢

转载自blog.csdn.net/oLinBSoft/article/details/82727040
今日推荐