1.cas请求流程原理
2.tomcat中使用HTTPS
参考利用Tomcat服务器配置HTTPS双向认定
3.CasServer搭建
1.服务器搭建
下载地址:https://github.com/apereo/cas-overlay-template/
2.一套调整好的项目下载
链接:https://pan.baidu.com/s/1StvscOzTN5zhcLJDAS0kPg
提取码:0jtw
3.修改内容
3.1 log4j2.xml
这里主要修改日志的路径,放到你想要的位置
3.2 application.properties
1).修改https认证的证书路径
server.ssl.key-store=/WorkSoftWare/java/tomcat/HTTPS/tomcat.keystore
server.ssl.key-store-password=123456
server.ssl.key-password=123456
2).注释掉默认登录账户密码,设置jdbc连接,以及配置密码使用MD5加密匹配
##
# CAS Authentication Credentials
#
#cas.authn.accept.users=casuser::Mellon
#jdbc设置
cas.authn.jdbc.query[0].url=jdbc:mysql://localhost:3306/casdb?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
cas.authn.jdbc.query[0].user=root
cas.authn.jdbc.query[0].password=123456
#根据username用户名字段去匹配
cas.authn.jdbc.query[0].sql=select * from cas where username=?
#密码对应的列名
cas.authn.jdbc.query[0].fieldPassword=password
cas.authn.jdbc.query[0].driverClass=com.mysql.jdbc.Driver
#MD5设置
cas.authn.jdbc.query[0].passwordEncoder.type=DEFAULT
#密码的编码方式如果需要自实现,可以写成包名.类名方式
#cas.authn.jdbc.query[0].passwordEncoder.type==com.encoder.CustomPasswordEncoder
cas.authn.jdbc.query[0].passwordEncoder.characterEncoding=UTF-8
cas.authn.jdbc.query[0].passwordEncoder.encodingAlgorithm=MD5
3).重新打包
修改后使用 run maven -> clean -> run maven -> package 重新生成压缩包,然后将新生成的压缩包放到tomcat的webapps下。
4.浏览器访问
https://127.0.0.1:8443/cas/login
输入账号密码
登录成功