CAS增加免登陸(Remember Me)功能

2021-06-17 00:33:56 字數 3260 閱讀 9434

**:

cas可以通過配置,實現免登陸功能,在版本3.4.10 , 3.4.11中,具體需要在如下幾個檔案進行修改配置。

1)deployerconfigcontext.xml

authenticationmanager 的bean中增加

name

="authenticationmetadatapopulators"

>

class

="org.jasig.cas.authentication.principal.remembermeauthenticationmetadatapopulator"

/>

2)login-webflow.xml

在該檔案定位

viewloginform

,可以找到:

id="viewloginform"

view

="casloginview"

model

="credentials"

>

property

="username"

/>

property

="password"

/>

name

="viewscope.commandname"

value

="'credentials'"

/>on=

"submit"

bind

="true"

validate

="true"to=

"realsubmit"

>

expression

="authenticationviaformaction.dobind(flowrequestcontext, flowscope.credentials)"

/>

的binder中增加:

property

="rememberme"

/>

3)ticketexpirationpolicies.xml 將

grantingticketexpirationpolicy的bean替換為:

id="grantingticketexpirationpolicy"

class

="org.jasig.cas.ticket.support.remembermedelegatingexpirationpolicy"

>

name

="sessionexpirationpolicy"

>

class

="org.jasig.cas.ticket.support.timeoutexpirationpolicy"

>

index

="0"

value

="******xx"

/>

name

="remembermeexpirationpolicy"

>

class

="org.jasig.cas.ticket.support.timeoutexpirationpolicy"

>

index

="0"

value

="******xx"

/>

其中的

******xx為毫秒數。

4) ticketgrantingticketcookiegenerator.xml

在ticketgrantingticketcookiegenerator的bean中增加

p:remembermemaxage="******x" ,要注意的是這裡的

******x為秒數。並且要注意和ticketexpirationpolicies.xml中設定的保持一致。

5)casloginview.jsp

在該登陸頁面增加:

type

="checkbox"

name

="rememberme"id=

"rememberme"

value

="true"

/>

for=

"rememberme"

>

remember me

到此,配置完成。

需要注意的是,在cas之前的版本中,

login-webflow.xml中的

viewloginform是如下樣子的:

id="viewloginform"

view

="casloginview"

model

="credentials"

>

name

="credentials"

class

="org.jasig.cas.authentication.principal.usernamepasswordcredentials"

/>

property

="username"

/>

property

="password"

/>

name

="viewscope.commandname"

value

="'credentials'"

/>on=

"submit"

bind

="true"

validate

="true"to=

"realsubmit"

>

name

="flowscope.credentials"

value

="credentials"

/>

expression

="authenticationviaformaction.dobind(flowrequestcontext, flowscope.credentials)"

/>

如果使用上面的**並增加

,在版本3.4.10 , 3.4.11中,會引起使用者名稱密碼輸入錯誤的情況下,重返回登陸頁面時,使用者名稱是不能回顯的,這點需要注意。

CAS單點登陸

1 主要是兩個應用server和client 2 server一般單獨部署。client跟應用一起,通過filter的方式監控,保護受保護的資源 3 流程 客戶端先傳送請求受保護的資源 需要登陸才能獲取到的東西 發現沒有登陸 http請求中沒有service ticket,一般登陸成功後會返回這個s...

ssh免賬號登陸

1 在當前使用者目錄下建立.ssh目錄,生成key mkdir ssh ssh keygen t dsa p f ssh id dsa 2 儲存認證鍵值到authorized keys檔案 cat ssh id dsa.pub ssh authorized keys 3 改變.ssh下檔案屬性,以及...

SSh 免密碼登陸

有機器a 192.168.1.155 b 192.168.1.181 現想 a通過ssh免密碼登入到b。操作步驟 進入主機a的 cmd介面 1 產生金鑰,命令如下 ssh keygen t rsa p 截圖如下 在輸入上面的命令後,它會在 users chenlb 下生產.ssh 目錄,ssh 下有...