开发者

How to introduce 'Remember me' checkbox to existing project with Spring Security?

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.


I think the below links will be very useful,

  • Remember-Me Authentication
  • Configuring Spring Security Form Login with Remember-Me Enabled
  • 5 Minute Guide to Spring Security


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.


Here is a tutorial from mkyong that is good.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜