Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

spring security session timeout

I use Spring Security 3 in my JSF2 webapp.

I have a security rule to provide session timeouts:

<session-management invalid-session-url="/faces/paginas/autenticacion/login.xhtml?error=1" />

So that when the session has expired and the user clicks on any link, he is redirected to the login page. In this page I check for the error param, and show a message to the user saying the session has expired.

But I have 2 problems:

(1) When I startup the app the first time (it tries to show the home page), I'm redirected to the login page saying session has expired. I think that this may be happening because the 1st time you run the app, the session is a new one, and Spring Security perhaps "thinks" he has expired (doesn't distinguish betwen a new session and a timeout).

(2) If the session has expired for anonymous users (not yet authenticated), I'm redirected to the login page timeout too. I don't want this behaviour for non-authenticated users, I just want to check the timeouts for authenticated users.

How can I solve both of these problems?

Thank you in advance.

like image 618
choquero70 Avatar asked Jan 23 '12 23:01

choquero70


1 Answers

You want to use the expired-session-url property for expired sessions, not the invalid-session-url. They are for two different things.

like image 148
cdeszaq Avatar answered Oct 09 '22 17:10

cdeszaq