Tomcat: V8.5.xhtml
Java: 1.8 x64 java
MySQL: 5.5.x+mysql
OS: Win10 x64git
git clone https://github.com/apereo/cas-gradle-overlay-template.git
https://gradle.org/releases/github
1) extractweb
gradle-4.10.3-bin.zipspring
2) set system variablesql
$PATH=$PATH;%GRADLE_HOME%\binapache
File location: cas\build\libs\cas.war
1) config filejson
gradle.properties
cas.version=5.3.2 -> cas.version=5.3.11 gradle.version=4.8 -> gradle.version=4.10.3 springboot.version=1.5.14.RELEASE -> springboot.version=1.5.18.RELEASE
2) build
cd cas-gradle-overlay-template
$gradle build
1) genkey
keytool -genkey -keyalg RSA -alias thekeystore -keypass changeit -storepass changeit -keysize 2048 -keystore d:/etc/cas/thekeystore
info:
-dname "CN=localhost,OU=test.com,O=test,L=WH,ST=HB,C=CN"
2) export
keytool -export -alias thekeystore -file d:/etc/cas/cas5311.crt -keystore d:/etc/cas/thekeystore -storepass changeit
3) import
keytool -import -alias thekeystore -storepass changeit -file d:/etc/cas/cas5311.crt -keystore "%JAVA_HOME%\jre\lib\security\cacerts"
copy thekeystore file to $TOMCAT_HOME/conf
server.xml
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" maxThreads="150" SSLEnabled="true"> <SSLHostConfig> <Certificate certificateKeystoreFile="conf/thekeystore" keystorePass="changeit" type="RSA" /> </SSLHostConfig> </Connector>
(1) tomcat startup
startup.bat
(2) login
Enter username and password
casuser/Mellon
If you want to change the user/password, stop Tomcat and change it in Application.properties(webapps\cas\WEB-INF\classes).
##
# CAS Authentication Credentials
#
cas.authn.accept.users=casuser::Mellon
----Beautiful Split Line----
copy cas-gradle-overlay-template/etc to The drive letter where Tomcat is located.
For example:
e:\
cas.properties
Append the following Key-Value:
cas.serviceRegistry.initFromJson=true
cas.serviceRegistry.json.location=classpath:/services
webapps\cas\WEB-INF\classes\services
MySQL Connector/J is 5.x;
cas-server-support-jdbc for matching ' cas.server '.
If the cas.authn.jdbc.query[0].passwordEncoder.type is not NONE, add the cas-server-support-jdbc-authentication package.
https://mvnrepository.com/artifact/mysql/mysql-connector-java
https://mvnrepository.com/artifact/org.apereo.cas/cas-server-support-jdbc
https://mvnrepository.com/artifact/org.apereo.cas/cas-server-support-jdbc-authentication
***Copy the above three files (*.jar) to the lib(..\webapps\cas\WEB-INF\lib) folder.***
application.properties(..\webapps\cas\WEB-INF\classes)
##
# CAS Authentication Credentials
#
#cas.authn.accept.users=casuser::Mellon
# server.port = 8443 cas.server.name: https://localhost:8443 cas.server.prefix: https://localhost:8443/cas cas.adminPagesSecurity.ip=127\.0\.0\.1 logging.config: file:/etc/cas/config/log4j2.xml cas.serviceRegistry.initFromJson=true cas.serviceRegistry.json.location=classpath:/services # SSL # server.ssl.enabled=false cas.authn.accept.users= cas.authn.accept.name= #CAS Database Authentication Property #cas.authn.jdbc.query[0].sql=SELECT * FROM users WHERE email = ? cas.authn.jdbc.query[0].sql=SELECT * FROM app_user WHERE email = ? cas.authn.jdbc.query[0].url=jdbc:mysql://127.0.0.1:3306/test cas.authn.jdbc.query[0].dialect=org.hibernate.dialect.MySQLDialect cas.authn.jdbc.query[0].user=DBAdmin cas.authn.jdbc.query[0].password=xbfirst cas.authn.jdbc.query[0].ddlAuto=none cas.authn.jdbc.query[0].driverClass=com.mysql.jdbc.Driver ## mysql8+ #cas.authn.jdbc.query[0].driverClass=com.mysql.cj.jdbc.Driver cas.authn.jdbc.query[0].fieldPassword=password #cas.authn.jdbc.query[0].passwordEncoder.type=NONE cas.authn.jdbc.query[0].passwordEncoder.type=BCRYPT # cas.authn.jdbc.query[0].passwordEncoder.characterEncoding= # cas.authn.jdbc.query[0].passwordEncoder.encodingAlgorithm= # cas.authn.jdbc.query[0].passwordEncoder.secret= cas.authn.jdbc.query[0].passwordEncoder.strength=10
# server.port = 8443 cas.server.name: https://localhost:8443 cas.server.prefix: https://localhost:8443/cas cas.adminPagesSecurity.ip=127\.0\.0\.1 logging.config: file:/etc/cas/config/log4j2.xml cas.serviceRegistry.initFromJson=true cas.serviceRegistry.json.location=classpath:/services # SSL # server.ssl.enabled=false cas.authn.accept.users= cas.authn.accept.name= #CAS Database Authentication Property #cas.authn.jdbc.query[0].sql=SELECT * FROM users WHERE email = ? cas.authn.jdbc.query[0].sql=SELECT * FROM app_user WHERE email = ? #cas.authn.jdbc.query[0].url=jdbc:mysql://127.0.0.1:3306/test cas.authn.jdbc.query[0].url=jdbc:mysql://127.0.0.1:3306/test?serverTimezone=UTC cas.authn.jdbc.query[0].dialect=org.hibernate.dialect.MySQLDialect cas.authn.jdbc.query[0].user=DBAdmin cas.authn.jdbc.query[0].password=xbfirst cas.authn.jdbc.query[0].ddlAuto=none ##cas.authn.jdbc.query[0].driverClass=com.mysql.jdbc.Driver ## mysql8+ cas.authn.jdbc.query[0].driverClass=com.mysql.cj.jdbc.Driver cas.authn.jdbc.query[0].fieldPassword=password #cas.authn.jdbc.query[0].passwordEncoder.type=NONE cas.authn.jdbc.query[0].passwordEncoder.type=BCRYPT # cas.authn.jdbc.query[0].passwordEncoder.characterEncoding= # cas.authn.jdbc.query[0].passwordEncoder.encodingAlgorithm= # cas.authn.jdbc.query[0].passwordEncoder.secret= cas.authn.jdbc.query[0].passwordEncoder.strength=10
create table APP_USER ( id BIGINT NOT NULL AUTO_INCREMENT, sso_id VARCHAR(30) NOT NULL, password VARCHAR(100) NOT NULL, first_name VARCHAR(30) NOT NULL, last_name VARCHAR(30) NOT NULL, email VARCHAR(30) NOT NULL, state VARCHAR(30) NOT NULL, PRIMARY KEY (id), UNIQUE (sso_id) );
INSERT INTO APP_USER(sso_id, password, first_name, last_name, email, state) VALUES ('sam','$2a$10$4eqIF5s/ewJwHK1p8lqlFOEm2QIA0S8g6./Lok.pQxqcxaBZYChRm', 'Sam','Smith','samy@xyz.com', 'Active');
{ "@class" : "org.apereo.cas.services.RegexRegisteredService", "serviceId" : "^http://localhost:9000/login/cas", "name" : "CAS Spring Secured App", "description": "This is a Spring App that usses the CAS Server for it's authentication", "id" : 19991, "evaluationOrder" : 1 }
{ "@class" : "org.apereo.cas.services.RegexRegisteredService", "serviceId" : "^http://localhost:9080/loginInfo/", "name" : "Login Information", "id" : 10000004, "description" : "Sample service for Cas client", "evaluationOrder" : 1 }
1) configure
2. keytool - del
keytool -delete -alias thekeystore -keystore "%JAVA_HOME%\jre\lib\security\cacerts" -storepass changeit
3. bcrypt tool
End