cas 自定義數據庫用戶名、密碼驗證登錄


cas自帶QueryDatabaseAuthenticationHandler和SearchModeSearchDatabaseAuthenticationHandler這兩個類作為JDBC方式驗證用戶的處理器。這兩個處理類位於cas-server-support-jdbc這個擴展工程下。修改application.properties配置文件如下

 

cas.authn.jdbc.query[0].url=jdbc:mysql://127.0.0.1:3306/springdemo?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8
cas.authn.jdbc.query[0].user=root
cas.authn.jdbc.query[0].password=1111
cas.authn.jdbc.query[0].driverClass=com.mysql.jdbc.Driver
cas.authn.jdbc.query[0].sql=select password from user where name=?
cas.authn.jdbc.query[0].fieldPassword=password

下面一張圖是數據庫與配置文件的對應

 

 

底層實現流程:

步驟:進行斷點調試,斷點所在位置:

 build.cmd debug啟動項目,輸入登陸信息

 使用idea--run---attache the process 選擇當前項目,即可進入斷點位置

 流程分析:

實現自定義登錄,只需要實現org.jasig.cas.authentication.handler.AuthenticationHandler接口即可,    AuthenticationHandler認證處理程序

在界面輸入用戶名,密碼點擊登陸,系統進入以上位置進行驗證,此時傳輸的數值已經對密碼進行md5加密

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM