CAS配置数据库,实现数据库用户认证
1、建库建表
说明:自己创建数据库,以下为建表SQL语句
DROP TABLE IF EXISTS `t_cas`;
CREATE TABLE `t_cas` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`password` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of t_cas
-- ----------------------------
INSERT INTO `t_cas` VALUES (1, 'java1234', '123456');
2、修改cas配置
修改文件:cas\WEB-INF\classes\application.properties
1、注释掉原有配置用户:
#cas.authn.accept.users=casuser::Mellon
2、新增mysql配置
cas.authn.jdbc.query[0].url=jdbc:mysql://101.36.111.83:3306/db_sso?serverTimezone=GMT
cas.authn.jdbc.query[0].user=root
cas.authn.jdbc.query[0].password=******
cas.authn.jdbc.query[0].sql=select * from t_cas where username=?
cas.authn.jdbc.query[0].fieldPassword=password
cas.authn.jdbc.query[0].driverClass=com.mysql.jdbc.Driver
下载地址:https://download.csdn.net/download/Asia1752/13144821
3、下载并导入如下jar包
导入位置:cas\WEB-INF\lib 下
3、启动服务并验证
略
end