-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Describe the bug
When a user lands at /admin, Spring generates an anonymous session for such user and redirects him to the login page.
When a user passes authentication process, RedisIndexedSessionRepository persists the session identifier in two indexes:
session:index:org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME:nullsession:index:org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME:principalUsername
The issue is that session:index:org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME:null never cleanup: I see hundreds of identifiers under that index.
To Reproduce
- Start the sample.
- Sign-in using
user/passwordcredentials. - Click on the logout button.
- Check the index, you will see the record under the key
spring:session:index:org.springframework.session.FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME:nullthat will never cleanup.
Expected behavior
Do not persist session under null principal, or clean the identifier when the session changes its principal.
Sample
The issue can be reproduced using the sample you have in the repository: https://github.com/spring-projects/spring-session/tree/main/spring-session-samples/spring-session-sample-boot-redis.