[英]Spring Security Https - Error when try to login with https
當用戶單擊登錄/注冊頁面(/ user / add)時,我想從http切換為https,並保持https會話直到注銷。 主頁不帶https。 我在security.xml中的代碼:
<http auto-config="true">
<intercept-url pattern="/home*" access="ROLE_USER" />
<intercept-url pattern="/user/add*" access="ROLE_USER" requires-channel="https"/>
<form-login login-page="/user/add" default-target-url="/" authentication-failure-url="/user/add" />
<port-mappings>
<port-mapping http="8080" https="8181"/>
</port-mappings>
</http>
我正在使用Glassfish 4.0,Spring MVC和Spring Security 3.0
當我單擊按鈕轉到頁面/ user / add時,出現此錯誤:
ERR_TOO_MANY_REDIRECTS
有什么建議么?
由於將登錄頁面設置為“ / user / add”(當然,它不是頁面-您應將此地址設置為真實的登錄頁面),因此重定向過多。 但是,當用戶到達此地址時,他將被阻止,因為在您將“ / user / add *”定義為需要驗證的安全資源之前的行。 驗證失敗,然后將用戶重定向到“ / user / add”,因為這被定義為“ authentication-failure-url”。
這就是解釋。
希望有幫助:-)
PS,如果您想查看如何做所需的示例,請在此處查看 (搜索“ form-login”)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.