CAS通过数据库encode密码

CAS账号密码encode

添加依赖cas-server-support-jdbc

build.gradle 中加入

implementation "org.apereo.cas:cas-server-support-jdbc:${casServerVersion}"
cas.authn.accept.enabled=false
#server.ssl.keyStore=/etc/cas/server.keystore

cas.jdbc.show-sql=true
cas.jdbc.gen-ddl=true
cas.jdbc.case-insensitive=false

# 数据库连接
cas.authn.jdbc.query[0].user=root
cas.authn.jdbc.query[0].password=admin
cas.authn.jdbc.query[0].driverClass=com.mysql.cj.jdbc.Driver
cas.authn.jdbc.query[0].dialect=org.hibernate.dialect.MySQLDialect
cas.authn.jdbc.query[0].url=jdbc:mysql://localhost:3306/cas?serverTimezone=UTC

# 密码加密方式
cas.authn.jdbc.query[0].password-encoder.type=DEFAULT
cas.authn.jdbc.query[0].password-encoder.character-encoding=UTF-8
cas.authn.jdbc.query[0].password-encoder.encoding-algorithm=MD5
# cas.authn.jdbc.query[0].password-encoder.secret=test

# 获取盐值区域
# 加密算法
cas.authn.jdbc.encode[0].algorithm-name=MD5
# encode 1次
cas.authn.jdbc.encode[0].number-of-iterations=1
# 盐值字段
cas.authn.jdbc.encode[0].salt-field-name=salt
cas.authn.jdbc.encode[0].password-field-name=password
# cas.authn.jdbc.encode[0].staticSalt=.
cas.authn.jdbc.encode[0].sql=select * from users where username=?
cas.authn.jdbc.encode[0].url=jdbc:mysql://localhost:3306/cas?serverTimezone=UTC
cas.authn.jdbc.encode[0].dialect=org.hibernate.dialect.MySQLDialect
cas.authn.jdbc.encode[0].driverClass=com.mysql.cj.jdbc.Driver
cas.authn.jdbc.encode[0].user=root
cas.authn.jdbc.encode[0].password=admin

cas.authn.jdbc.query[0].sql=SELECT * FROM Users WHERE username=?
cas.authn.jdbc.query[0].field-password=password
cas.authn.jdbc.query[0].fieldExpired=expired
cas.authn.jdbc.query[0].fieldDisabled=disabled

由此,CAS账号的密码加密方式为: MD5(SALT + PASSWORD)