spring-projects / spring-projects/spring-security

SEC-3184: PersistentTokenBasedRememberMeServices.logout doesn't work properly with SessionCreationPolicy.STATELESS

Open
#3,390 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug type: jira
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

Scott Albertine (Migrated from SEC-3184) said:

In the PersistentTokenBasedRememberMeServices.logout method, there's a clause that (as it should) deletes all persisted tokens for the current user, assuming we know who the current user is. This is great! However, in my application, I'm using SessionCreationPolicy.STATELESS, to disable in-memory sessions, for clustering purposes. Thus, on any POST to /logout, the only authentication the user has is the RememberMe token that we're trying to clear. This is a problem, because due to the ordering of filters set in FilterComparator, the LogoutFilter that triggers this handler happens BEFORE the RememberMeAuthenticationFilter, which means that there is no way for the LogoutFilter to know which user we're authenticated as, and thus we never remove the user tokens.

This can be fixed by re-ordering the filters in FilterComparator to put the LogoutFilter after the RememberMeAuthenticationFilter.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with FilterComparator and PersistentTokenBasedRememberMeServices.logout to trace the filter ordering during a stateless POST to /logout. Verify that the ordering lets the remember-me authentication identify the user before logout clears persisted tokens, and confirm that the reported token-removal behavior is fixed.

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
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.