10. CAS单点登录

1.cas请求流程原理

image

2.tomcat中使用HTTPS

参考利用Tomcat服务器配置HTTPS双向认定

3.CasServer搭建

1.服务器搭建

下载地址:https://github.com/apereo/cas-overlay-template/

2.一套调整好的项目下载
链接:https://pan.baidu.com/s/1StvscOzTN5zhcLJDAS0kPg 
提取码:0jtw 

3.修改内容
image
3.1 log4j2.xml

这里主要修改日志的路径,放到你想要的位置

image
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

image

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

image

3).重新打包

修改后使用 run maven -> clean -> run maven -> package 重新生成压缩包,然后将新生成的压缩包放到tomcat的webapps下。

image
image
4.浏览器访问

https://127.0.0.1:8443/cas/login

输入账号密码



image
登录成功



image

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

鱼鱼大头鱼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值