How to redirect Spring security control of a concurrent message session to the login screen?

I have a web application in which I used the Spring framework. To manage a parallel session, I use the Spring function, where only one session during a session will be supported for 1 user, as soon as this user logs into another session, his previous session will expire.

Now in this case, I get this message "This session has expired (possibly due to attempts to log in as a single user at the same time).

But I get this message on a full white page in the browser. I want this message to appear only on my login screen.

Here is the part of my Spring security xml where I was handling a parallel session for the user.

<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> 

Any links specifically designed to customize this message and redirect this message to the desired page of the web application will be appreciated.

Thanks in advance.

+7
source share
2 answers

Original XML entry in spring -security.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> 

You just need to add the following parameter in xml in order to redirect expired action or invalid session url

expired-url = "url value"

invalid-session-url = "url value"

Modified XML Record

 <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> 
+7
source

There are .properties files in the spring-security-core bank.

You need to override the properties you want using your custom messages in your application.

0
source

All Articles