CAS5.3 服务器集成MySQL8数据库
Posted 在奋斗的大道
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CAS5.3 服务器集成MySQL8数据库相关的知识,希望对你有一定的参考价值。
mysql 相关准备
1、安装MySQL8 并安装相关数据库实例
省略一千字***
2、新建ucas_auth_user表,并增加相关用户条记录
DROP TABLE IF EXISTS `ucas_auth_user`;
CREATE TABLE `ucas_auth_user` (
`sid` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
`user_pin` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '登录名',
`user_name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户名',
`password` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '密码',
`gender` varchar(4) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '性别(1:男,2:女)',
`tel` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '常用电话',
`phone` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '其他联系电话',
`email` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '电子邮件',
`state` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '2' COMMENT '状态(1:禁用,2:启用)',
`created_by` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人',
`created_dt` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`version` int(9) NULL DEFAULT 1 COMMENT '版本号',
`updated_by` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人',
`updated_dt` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
`zone_org_code` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '区域机构',
`organiztion_sid` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '部门sid',
`value1` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备用字段1',
`value2` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备用字段2',
`value3` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备用字段3',
`delete_flag` int(1) NULL DEFAULT 1 COMMENT '删除标识(1:未删除,2:已删除)',
`session_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '会话Id',
`user_category` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户类别(系统管理员\\\\安全保密管理员\\\\安全审计员\\\\普通用户)',
`unique_sid` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '操作日志记录uuid',
PRIMARY KEY (`sid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户表' ROW_FORMAT = Dynamic;
INSERT INTO `ucas_auth_user` VALUES ('1', 'admin', '超级管理员', 'e10adc3949ba59abbe56e057f20f883e', NULL, '13726252116', NULL, '123@1.com', '2', NULL, '2019-08-13 12:09:15', 38, NULL, '2020-04-07 15:57:33', NULL, '1', NULL, NULL, NULL, 1, 'TXJMgpVJc8Vtaox6Zg9qf2oSnnrh4pdV', 'SUPER_ADMIN,SYSTEM_ADMIN', NULL);
CAS5.3配置MySQL相关信息
1、CAS5.3 之pom.xml 文件添加MySQL8 驱动
properties节点中,新增MySQL驱动版本
<mysql.driver.version>8.0.13</mysql.driver.version>
cas-server-webapp${app.server}所在同级dependency节点中增加以下配置
<!--数据库认证相关 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>${mysql.driver.version}</version>
</dependency>
<!--数据库认证相关 end -->
修改CAS5.3之application.properties配置
打开cas-overlay-template-5.3\\src\\main\\resources\\application.properties文件
1)注释内存账户
##
# CAS Authentication Credentials
#
#cas.authn.accept.users=casuser::Mellon
2)增加MySQL用户查询配置
##
# CAS Authentication Credentials
#
#cas.authn.accept.users=casuser::Mellon
cas.authn.jdbc.query[0].url=jdbc:mysql://123.0.0.1:3306/ucas?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true
cas.authn.jdbc.query[0].user=root
cas.authn.jdbc.query[0].password=123456
cas.authn.jdbc.query[0].sql=select * from ucas_auth_user where user_pin =?
cas.authn.jdbc.query[0].fieldPassword=password
cas.authn.jdbc.query[0].driverClass=com.mysql.jdbc.Driver
cas.authn.jdbc.query[0].dialect=org.hibernate.dialect.MySQLDialect
#加密策略
#采用MD5加密
cas.authn.jdbc.query[0].passwordEncoder.type=DEFAULT
cas.authn.jdbc.query[0].passwordEncoder.characterEncoding=UTF-8
#MD5加密策略
cas.authn.jdbc.query[0].passwordEncoder.encodingAlgorithm=MD5
CAS5.3验证
切换至cas5.3 源码目录,再次执行脚本构建任务
D:\\cas\\cas-overlay-template-5.3>.\\build.cmd run
[INFO] Scanning for projects...
[INFO]
[INFO] Using the MultiThreadedBuilder implementation with a thread count of 5
[INFO]
[INFO] ---------------------< org.apereo.cas:cas-overlay >---------------------
[INFO] Building cas-overlay 1.0
[INFO] --------------------------------[ war ]---------------------------------
浏览器访问CAS
输入MySQL8 表中的用户名admin,密码123456(使用MD5加密)点击登录
至此,CAS5.3结合MySQL8搭建完成。
以上是关于CAS5.3 服务器集成MySQL8数据库的主要内容,如果未能解决你的问题,请参考以下文章
Native for MySQL 客户端连接MySQL8 提示10061错误解决方案
java.lang.ClassCastException 在 Wildfly 10 上部署 CAS 5.3.3 Maven Overlay WAR