1

I have tried each and every thread about implementing Spring Security Remember me option, persitent and token based, custom user detail service and built in one, but to no avail. I have followed almost all the threads on internet regarding spring security remember me, but to no avail. The remember me option does not work. By does not work, I mean, remember me cookie is not created in the browser, and thus when I close and reopen the browser or clear the session cookie, it gets logged out, hence remember me checkbox not working.

Following log is printed when I log-in:

RememberMeAuthenticationFilter [RememberMeAuthenticationFilter.java:154] SecurityContextHolder not populated with remember-me token, as it already contained: 'org.springframework.security.authentication.UsernamePasswordAuthenticationToken@b94642e7: Principal: org.springframework.security.core.userdetails.User@fd5a80ad: Username: ab@g.com; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_USER; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@1c07a: RemoteIpAddress: 127.0.0.1; SessionId: 7857308FEDBDF4A65DFAE6075EE22DD2; Granted Authorities: ROLE_USER'

I think the problem is that UsernamePasswordAuthenticationFilter some how gets executed before the RememberMeAuthenticationFilter, and thus the latter one tells that the request is already authenticated and it is going to do nothing. And thus no remember me cookie is created in the browser. Is there any way to disable UsernamePasswordAuthenticationFilter.?

My tools versions:

  • Spring boot: 1.5
  • Spring: 4.3
  • Spring Security: 4.2

I have tried following threads:

https://www.mkyong.com/spring-security/spring-security-remember-me-example/

http://websystique.com/spring-security/spring-security-4-remember-me-example-with-hibernate/

http://www.concretepage.com/spring/spring-security/remember-me-in-spring-security-example

Spring security Remember me is not working in spring MVC application.

Spring security Remember-me doesn't work

https://github.com/jhipster/generator-jhipster/issues/1366

And many more.

Community
  • 1
  • 1
Aqeel Ashiq
  • 1,988
  • 5
  • 24
  • 57

0 Answers0