git地址:
https://github.com/apereo/cas-overlay-template.git
切换到5.3版本。
最新版本,下载下来后,无法通过编译。
运行
build.cmd package
创建src/main/resources目录,如下,并且把target/cas/META-INF文件、target/cas/services、target/cas/application.properties,这三个文件拷贝到resources中。
修改文件HTTPSandIMAPS-10000001.json,支持http
{
"@class" : "org.apereo.cas.services.RegexRegisteredService",
"serviceId" : "^(https|http|imaps)://.*",
"name" : "HTTPS and IMAPS",
"id" : 10000001,
"description" : "This service definition authorizes all application urls that support HTTPS and IMAPS protocols.",
"evaluationOrder" : 10000
}
同时,需要启用记载JSON配置文件
打开文件cas\WEB-INF\classes\application.properties
增加如下配置
cas.tgc.secure=false
cas.serviceRegistry.initFromJson=true
cas服务端配置mysql
<dependencies>
<!--数据库认证相关 start-->
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-jdbc</artifactId>
<version>${cas.version}</version>
</dependency>
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-jdbc-drivers</artifactId>
<version>${cas.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.29</version>
</dependency>
<!--数据库认证相关 end-->
</dependencies>
application.properties 配置文件, 添加与mysql的链接
cas.authn.jdbc.query[0].driverClass=com.mysql.cj.jdbc.Driver
cas.authn.jdbc.query[0].url=jdbc:mysql://127.0.0.1:3306/ry?useUnicode=true&characterEncoding=utf-8
cas.authn.jdbc.query[0].user=root
cas.authn.jdbc.query[0].password=123456
cas.authn.jdbc.query[0].sql=select password from sys_user where user_name = ?
cas.authn.jdbc.query[0].fieldPassword=password
#开启自定义密码验证
cas.authn.jdbc.query[0].passwordEncoder.type=DEFAULT
cas.authn.jdbc.query[0].passwordEncoder.characterEncoding=UTF-8
cas.authn.jdbc.query[0].passwordEncoder.encodingAlgorithm=MD5
注释掉cas默认的帐号密码,不然这个账号密码也是可以登录的
#cas.authn.accept.users=casuser::Mellon
mysql取md5:
select MD5('123456')
重新运行:
build.cmd package
将target/cas.war放到tomcat容器中,启动tomcat
我的tomcat端口是8888
访问: http://localhost:8888/cas