那么我们挑邮件发送验证,问题回答验证来进行简单的罗列一下,好给大家一个简单的介绍,当然了,这些界面是cas提供的,我们在上线的时候的一般需要自定义一套,有文章姐简单介绍了一下自定义主题
实战
==
配置说明
上面的流程已经明确出一些东西,其中包括:
-
根据用户名寻找邮箱/手机号
-
问题数据查找
-
邮箱/手机发送配置
-
密码重置策略配置(修改密码接口,加密策略)
application.properties
#密码管理 开始
#允许内置密码管理
cas.authn.pm.enabled=true
#发送邮件
spring.mail.host=smtp.qq.com
spring.mail.port=465
#邮箱用户名
spring.mail.username=huang.wenbin@foxmail.com
#邮箱授权码
spring.mail.password=judnarjvmhsfbdji
spring.mail.testConnection=false
spring.mail.properties.mail.smtp.auth=true
#必须ssl
spring.mail.properties.mail.smtp.ssl.enable=true
#邮箱查找
#根据用户名查找问题
cas.authn.pm.jdbc.sqlSecurityQuestions=select question, answer from sys_user_question where username=?
#根据用户名查找邮箱
cas.authn.pm.jdbc.sqlFindEmail=select email from sys_user where username=?
cas.authn.pm.jdbc.sqlChangePassword=update sys_user set password=? where username=?
cas.authn.pm.jdbc.url=${cas.authn.jdbc.query[0].url}
cas.authn.pm.jdbc.user=${cas.authn.jdbc.query[0].user}
cas.authn.pm.jdbc.password=${cas.authn.jdbc.query[0].password}
cas.authn.pm.jdbc.dialect=${cas.authn.jdbc.query[0].dialect}
cas.authn.pm.jdbc.driverClass=${cas.authn.jdbc.query[0].driverClass}
#密码修改加密规则,这个必须要和原始密码加密规则一致
cas.authn.pm.jdbc.passwordEncoder.type=${cas.authn.jdbc.query[0].passwordEncoder.type}
cas.authn.pm.jdbc.passwordEncoder.characterEncoding=${cas.authn.jdbc.query[0].passwordEncoder.characterEncoding}
cas.authn.pm.jdbc.passwordEncoder.encodingAlgorithm=${cas.authn.jdbc.query[0].passwordEncoder.encodingAlgorithm}
cas.authn.pm.jdbc.passwordEncoder.secret=${cas.authn.jdbc.query[0].passwordEncoder.secret}
#默认是false,不会提交update语句
cas.authn.pm.jdbc.autocommit=true
#重置信息 https://apereo.github.io/cas/5.1.x/installation/Configuration-Properties.html#password-management
cas.authn.pm.reset.from=${spring.mail.username}
#发送邮件标题
cas.authn.pm.reset.subject=SSO DEMO 重置密码
#邮件内容,必须要有%s,因为会生成一个连接并且带了token,否则无法打开链接,当然这个链接也和cas.server.prefix有关系
cas.authn.pm.reset.text=打开以下链接重置您的密码(SSO-DEMO): %s
#token失效分钟数
cas.authn.pm.reset.expirationMinutes=10
cas.authn.pm.reset.emailAttribute=mail
#是否开启问题回答
cas.authn.pm.reset.securityQuestionsEnabled=true
#新密码必须匹配表达式
cas.authn.pm.policyPattern=\d{3,10}
#密码管理 结束
注意要点
- 允许内置密码管理