![](/img/trans.png)
[英]Spring security - remember-me authentication with multiple authentication providers
[英]Disable Remember-Me in Spring Security & Tomcat
我想知道,有什么方法可以禁用 Spring 安全中的記住我功能嗎? 我想實現的場景很常見:關閉瀏覽器 window 后,我希望用戶的 session 過期。 看起來很奇怪,但它不適用於 Tomcat 7 & Spring Security 3.1。 我們在 Spring 安全配置文件中使用了 auto-config,但是沒有 remember-me 元素。
讓它工作的最佳解決方案是什么? 提前致謝!
更新這是澄清我的問題的使用場景:
鑒別診斷的新症狀:用戶可能被重新認證,因為 JSESSIONID 在瀏覽器關閉/打開之間相同。 我怎么能用 Tomcat 或 Spring 為每個瀏覽器 session 生成一個新的 session?
更新片段 Spring 安全配置:
<http auto-config="true">
<anonymous key="anonymous-security" />
<intercept-url pattern="/auth/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<intercept-url pattern="/**" access="ROLE_ADMIN" />
<form-login login-page="/auth/login.html"
default-target-url="/auth/default.html"
authentication-failure-url="/auth/failed.html" />
<logout logout-success-url="/auth/logout.html" delete-cookies="JSESSIONID" />
</http>
更新文檔聲稱自 3.0(我們使用 3.1)以來,auto-config="true" 中沒有默認的 remember-me 配置:
在 3.0 之前的版本中,此列表還包括記住我的功能。 這可能會導致某些配置出現一些令人困惑的錯誤,並在 3.0 中被刪除。
我的 web 應用程序出了什么問題?
為什么不通過重定向到/j_spring_security_logout 來注銷現有用戶?
在我最新的 Spring security 和 Tomcat 6 的實現中,我使用了以下配置:它與你的相似嗎?
<http use-expressions="true" access-denied-page="/Error.xhtml">
<intercept-url access="isAuthenticated()" pattern="/secure.xhtml"/>
<form-login />
<logout invalidate-session="true" logout-success-url="/search.xhtml"/>
</http>
您可以嘗試添加一個logouthandler
來終止本地 session:
<!-- Logout handler terminating local session -->
<bean id="logoutHandler" class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler">
<property name="invalidateHttpSession" value="true" />
</bean>
實際上,它默認為 true,因此您可能不需要設置該屬性。
我遇到了同樣的問題:我的瀏覽器會記住我的用戶。
通常:登錄訪問受限區域后,關閉瀏覽器,然后重新打開它並進入相同的受限區域,當我希望提示輸入憑據時,它會讓我訪問它。
試玩之后,我注意到一件重要的事情:這種行為在瀏覽器中並不一致:
可以測試更多瀏覽器類型和版本...
可能有更好的解決方案,如果我找到它,我會更新這個答案。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.