搭建单点登录系统之五:CAS服务端增加通过手机号登录的功能

搭建好CAS服务端后,用户希望不仅能通过账号登录,也能通过手机号登录。

在我们系统的用户表中sys_user,有account(账号)和手机号(mobile)字段。

可以在cas server的 application.properties中增加如下配置实现该功能:

# 增加通过手机号查询账号密码的sql
cas.authn.jdbc.query[1].sql=select * from sys_user where fromtype = 0 and mobile = ?
cas.authn.jdbc.query[1].fieldPassword=PASSWORD
cas.authn.jdbc.query[1].fieldExpired=ISEXPIRED
cas.authn.jdbc.query[1].fieldDisabled=ISLOCK
cas.authn.jdbc.query[1].dialect=org.hibernate.dialect.MySQLDialect
cas.authn.jdbc.query[1].driverClass=com.mysql.jdbc.Driver
cas.authn.jdbc.query[1].url=jdbc:mysql://10.1.1.23:3306/jk2_uat?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=round&allowMultiQueries=true
cas.authn.jdbc.query[1].user=root
cas.authn.jdbc.query[1].password=123
#返回的用户属性字段
cas.authn.jdbc.query[1].principalAttributeList=account

#默认加密策略,通过encodingAlgorithm来指定算法,默认NONE不加密
cas.authn.jdbc.query[1].passwordEncoder.type=com.hanchen.cas.CustomPasswordEncoder
cas.authn.jdbc.query[1].passwordEncoder.characterEncoding=UTF-8
cas.authn.jdbc.query[1].passwordEncoder.encodingAlgorithm=SHA-256

 

 

posted @ 2020-03-18 15:17  gaopengpy  阅读(696)  评论(0编辑  收藏  举报