spring-projects / spring-projects/spring-security
Remember me login fired multiple times
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
Summary
We're handling the InteractiveAuthenticationSuccessEvent to determine when a user logged in. However, this event is getting fired multiple times, causing unexpected behavior in our application.
It seems when accessing a page requiring full authentication, the security context is cleared in the ExceptionTranslationFilter, causing a partially authenticated user to be in effect logged out. The user will then be redirected to the login page, where remember me login kicks in again (the cookie is still present).
Seems to be a side effect of the fix for this issue.
Actual Behavior
- User accesses any page. Remember-me kicks in and user is logged in automatically. InteractiveAuthenticationSuccessEvent is published.
- User accesses page requiring full authentication and is redirected to login page*. Remember-me kicks in again and InteractiveAuthenticationSuccessEvent is published.
*Login page itself is not the issue, since remember-me will kick in regardless of which page we redirect to.
Expected Behavior
- InteractiveAuthenticationSuccessEvent should be fired only once, in step 1.
- Logout/login should not be repeated in circles behind the scenes.
Configuration
A mix of authenticated and fullyAuthenticated urls.
Persistent token based remember-me enabled:
.and().rememberMe()
.key(REMEMBER_ME_CRYPTO_KEY)
.alwaysRemember(true)
.tokenValiditySeconds(REMEMBER_ME_TOKEN_VALIDITY)
.userDetailsService(userDetailsService)
.rememberMeServices(rememberMeServices)
.tokenRepository(rememberMeTokenRepository)
.useSecureCookie(true)
The overall configuration is too customized to describe here. If others haven't experienced/can't reproduce this issue, I will try to provide a sample. Just didn't have time at the moment.
Version
5.0.7.RELEASE
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with ExceptionTranslationFilter.java at the linked security-context clearing lines, then trace the remember-me authentication flow using the mixed authenticated and fullyAuthenticated URL configuration described here. Reproduce the redirect scenario and verify that InteractiveAuthenticationSuccessEvent is published once without repeated logout/login behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- authentication, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100