CAS configuration database to realize database user authentication
1. Build database and table
Description: Create a database by yourself, the following is the SQL statement to build a table
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. Modify the cas configuration
Modify the file: cas\WEB-INF\classes\application.properties
1. Comment out the original configuration user:
#cas.authn.accept.users=casuser::Mellon
2. Add mysql configuration
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
Download address: https://download.csdn.net/download/Asia1752/13144821
3. Download and import the following jar package
Import location: cas\WEB-INF\lib
3. Start the service and verify
slightly
end