繁体   English   中英

如何在登录屏幕上重定向Spring安全性并发会话控制“消息”?

[英]How to redirect Spring security concurrent session control 'message' on login screen?

我有web应用程序,其中我使用了Spring框架。 对于并发会话控制,我使用spring功能,一旦用户登录到另一个会话,将只为1个用户维护1个登录会话,他/她之前的会话将过期。

现在,在这种情况下,我收到此消息“ 此会话已过期(可能是由于多个并发登录尝试作为同一用户)。

但我在浏览器的完整白页上收到此消息。 我希望此消息仅在我的登录屏幕上显示。

这是我的spring security xml的一部分,我处理了用户的并发会话。

<security:session-management invalid-session-url="/login.jsp?error=sessionExpired" session-authentication-error-url="/login.jsp?error=alreadyLogin">
                    <security:concurrency-control max-sessions="1" error-if-maximum-exceeded="false" />
</security:session-management>

任何专门用于自定义此消息并在所需Web应用程序页面上重定向此消息的链接将不胜感激。

提前致谢。

spring-security.xml中的原始XML条目

<security:session-management session-authentication-error-url="/login.jsp?error=alreadyLogin">
                    <security:concurrency-control max-sessions="1" error-if-maximum-exceeded="false" />
</security:session-management>

您只需在xml中添加以下参数即可重定向登录过期操作或无效会话URL

expired-url =“url value”

invalid-session-url =“url value”

修改后的XML条目

<security:session-management invalid-session-url="/login.jsp?error=sessionExpired" session-authentication-error-url="/login.jsp?error=alreadyLogin">
                    <security:concurrency-control max-sessions="1" expired-url="/login.jsp?error=sessionExpiredDuplicateLogin" error-if-maximum-exceeded="false" />
</security:session-management>

在jar spring-security-core中有.properties文件。

您需要在应用程序中使用自定义消息覆盖所需的属性。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM