views:

230

answers:

3

I have a pretty standard project with Spring Security.

I have a login form and I need to add 'Remember me' checkbox there. How can I do that?

I can provide some code if necessary.

A: 

Roman,

Unfortunately I have no idea, and I would be interested, too.

I have been facing the similair problem, I have a checkbox on the login page, and I have some java beans in the applicationcontext.xml

my question is how can I make a connection between the two of them? What should I do in order to acheive that the remember-me function applies to one particular checkbox?

many thanks

ternero

ternero
A: 

So this is a complete WAG - but it's how I would do it, at least initially.

I would override the Spring SecurityContextPersistenceFilter so that it only saves the Authentication details (i.e. the SecurityContext) if that box is checked (you would know this by some attribute you included when you POST the Form for login). You could also, possibly, create a new Cookie if the box is checked and check for the existence of said Cookie before you try Authentication - if the cookie exists it contains the UserDetails and will authenticate, otherwise redirect to the login page.

Gandalf
+1  A: 

I think the below links will be very useful,

First link can be used as step-by-step manual, second link shows an example of what you should get, from 3rd one I took '_spring_security_remember_me' param.
Roman