CAS 5.3.1系列之支持JDBC認(rèn)證登錄(二)

      網(wǎng)友投稿 872 2025-03-31

      CAS 5.3.1系列之支持JDBC認(rèn)證登錄(二)

      在項(xiàng)目中,我們肯定是不能用默認(rèn)的靜態(tài)賬號(hào)密碼,所以我們需要實(shí)現(xiàn)對(duì)jdbc或者其它認(rèn)證方式的支持,將cas-overlay-template-5.2\pom.xml復(fù)制到項(xiàng)目里,將application.properties復(fù)制到resources文件夾

      org.apereo.cas cas-server-support-jdbc ${cas.version} org.apereo.cas cas-server-support-jdbc-drivers ${cas.version}

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      14

      注意5.3.1版本的cas-server-support-jdbc-drivers數(shù)據(jù)庫(kù)驅(qū)動(dòng)是mysql8左右的,所以如果是mysql5版本的,就不使用自適配驅(qū)動(dòng),自己加上:

      mysql mysql-connector-java 5.1.27

      1

      2

      3

      4

      5

      ok,然后需要在application.properties加上:

      ## # JDBC Authentication # # 查詢(xún)賬號(hào)密碼SQL,必須包含密碼字段 cas.authn.jdbc.query[0].sql=select * from sys_user where username=? # 指定上面的SQL查詢(xún)字段名(必須) cas.authn.jdbc.query[0].fieldPassword=password # 指定過(guò)期字段,1為過(guò)期,若過(guò)期不可用 cas.authn.jdbc.query[0].fieldExpired=expired # 為不可用字段段,1為不可用,需要修改密碼 cas.authn.jdbc.query[0].fieldDisabled=disabled # 數(shù)據(jù)庫(kù)連接 cas.authn.jdbc.query[0].url=jdbc:mysql://192.168.0.159:3306/jeeplatform?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8 # 數(shù)據(jù)庫(kù)dialect配置 cas.authn.jdbc.query[0].dialect=org.hibernate.dialect.MySQLDialect # 數(shù)據(jù)庫(kù)用戶名 cas.authn.jdbc.query[0].user=root # 數(shù)據(jù)庫(kù)用戶密碼 cas.authn.jdbc.query[0].password=root # 數(shù)據(jù)庫(kù)事務(wù)自動(dòng)提交 cas.authn.jdbc.query[0].autocommit=false # 數(shù)據(jù)庫(kù)驅(qū)動(dòng) cas.authn.jdbc.query[0].driverClass=com.mysql.jdbc.Driver # 超時(shí)配置 cas.authn.jdbc.query[0].idleTimeout=50000 # 默認(rèn)加密策略,通過(guò)encodingAlgorithm來(lái)指定算法,默認(rèn)NONE不加密 # NONE|DEFAULT|STANDARD|BCRYPT|SCRYPT|PBKDF2 cas.authn.jdbc.query[0].passwordEncoder.type=NONE #cas.authn.jdbc.query[0].passwordEncoder.type=org.muses.jeeplatform.cas.authentication.encode.MD5PasswordEncoder # 字符類(lèi)型 cas.authn.jdbc.query[0].passwordEncoder.characterEncoding=UTF-8 # 加密算法 #cas.authn.jdbc.query[0].passwordEncoder.encodingAlgorithm=MD5 # 加密鹽 #cas.authn.jdbc.query[0].passwordEncoder.secret= # 加密字符長(zhǎng)度 #cas.authn.jdbc.query[0].passwordEncoder.strength=16

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      14

      15

      16

      17

      18

      19

      20

      21

      22

      23

      24

      25

      26

      27

      28

      CAS 5.3.1系列之支持JDBC認(rèn)證登錄(二)

      29

      30

      31

      32

      33

      34

      35

      36

      37

      38

      39

      然后啟動(dòng)項(xiàng)目,訪問(wèn),暫時(shí)不用密碼加密方式,如果要MD5密碼可以如下設(shè)置

      # NONE|DEFAULT|STANDARD|BCRYPT|SCRYPT|PBKDF2 cas.authn.jdbc.query[0].passwordEncoder.type=DEFAULT cas.authn.jdbc.query[0].passwordEncoder.encodingAlgorithm=MD5

      1

      2

      3

      4

      也可以自定義加密方式:

      import org.springframework.security.crypto.password.PasswordEncoder; /** *

       * 自定義PasswordEncoder * 
      * *
       * @author mazq * 修改記錄 * 修改后版本: 修改人: 修改日期: 2020/04/24 17:02 修改內(nèi)容: * 
      */ public class MD5PasswordEncoder implements PasswordEncoder { @Override public String encode(CharSequence charSequence) { return charSequence.toString(); } @Override public boolean matches(CharSequence charSequence, String s) { String encodeStr = charSequence.toString() + "aa"; if (encodeStr.equals(s)) { return true; } return false; } }

      1

      2

      3

      4

      5

      6

      7

      8

      9

      10

      11

      12

      13

      14

      15

      16

      17

      18

      19

      20

      21

      22

      23

      24

      25

      26

      27

      28

      29

      30

      然后修改配置:

      cas.authn.jdbc.query[0].passwordEncoder.type=org.muses.jeeplatform.cas.authentication.encode.MD5PasswordEncoder

      1

      代碼例子參考:github下載鏈接

      詳情可以參考官方文檔:https://apereo.github.io/cas/5.3.x/installation/Configuration-Properties.html

      優(yōu)質(zhì)參考博客:

      https://www.cnblogs.com/jpeanut/tag/CAS/

      https://blog.csdn.net/anumbrella/category_7765386.html

      JDBC

      版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請(qǐng)聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。

      版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實(shí)的內(nèi)容,請(qǐng)聯(lián)系我們jiasou666@gmail.com 處理,核實(shí)后本網(wǎng)站將在24小時(shí)內(nèi)刪除侵權(quán)內(nèi)容。

      上一篇:如何恢復(fù)未保存excel文件的方法
      下一篇:優(yōu)秀項(xiàng)目經(jīng)理必會(huì)的一大絕技——甘特圖!教你 5分鐘搞定一張產(chǎn)品研發(fā)排期表(免費(fèi)領(lǐng)6套甘特圖模版)
      相關(guān)文章
      亚洲精品无码Av人在线观看国产 | 精品亚洲AV无码一区二区三区| 在线播放亚洲精品| 亚洲综合小说另类图片动图| 久久久无码精品亚洲日韩京东传媒| 亚洲国产精品特色大片观看完整版| 国产亚洲色婷婷久久99精品91| 亚洲中文字幕丝袜制服一区| 亚洲精品无码AV中文字幕电影网站| 激情小说亚洲色图| 国产亚洲视频在线播放大全| 亚洲AV成人精品日韩一区| 亚洲JIZZJIZZ妇女| 精品亚洲视频在线| www.亚洲色图| 国产精品亚洲а∨无码播放麻豆| 无码一区二区三区亚洲人妻| 午夜在线亚洲男人午在线| 日韩成人精品日本亚洲| 亚洲国产精品人人做人人爽| 亚洲色一色噜一噜噜噜| 国产亚洲美女精品久久久2020| 亚洲午夜久久久影院伊人| 亚洲国产综合无码一区| 亚洲∧v久久久无码精品| 久久久亚洲欧洲日产国码aⅴ| 亚洲一本综合久久| 亚洲成人在线免费观看| 亚洲一级视频在线观看| 欧洲 亚洲 国产图片综合| 亚洲经典千人经典日产| 亚洲AV中文无码乱人伦在线视色| 亚洲区日韩区无码区| 亚洲人成网站在线观看播放| 亚洲a一级免费视频| 亚洲日产2021三区在线 | 亚洲午夜精品一级在线播放放 | 自拍偷自拍亚洲精品被多人伦好爽| 国产亚洲一区二区在线观看| 午夜亚洲国产理论秋霞| 亚洲性一级理论片在线观看|