Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: session timeout in cluster #19648

Merged
merged 1 commit into from
Jan 16, 2025
Merged

fix: session timeout in cluster #19648

merged 1 commit into from
Jan 16, 2025

Conversation

netroms
Copy link
Contributor

@netroms netroms commented Jan 13, 2025

Problem

When using a clustered setup with Redis enabled, the session timeout setting is not honored.

Cause

Session timeout must be set on the RedisIndexedSessionRepository when enabled, rather than only in the DhisHttpSessionEventListener, which is ignored when Spring Session is used.

Fix

Set the session timeout directly on the RedisIndexedSessionRepository on startup.
Use the NonRedisSessionConfig to set the session timeout with an event listener, only when Redis is not enabled.
Remove the redundant DhisHttpSessionEventListener class.

Manual test (minimal setup)

  1. Start Redis locally
  2. Enable Redis in config, redis.enabled = true (will assume port 6379 and localhost)
  3. Set timeout to a low value, say 2 minutes, system.session.timeout = 120
  4. Log in, and wait 2 min
  5. Refresh the browser, observe you have to log in again.

Test without Redis enabled.

  1. Disable Redis in config, redis.enabled = true
  2. ... To the same as above

Manual test (multiple servers)

  1. Do the same as above, but use 2 instances
  2. Log in to one instance, observe you now are automatically logged in to the second instance
  3. Wait 2 min
  4. Refresh browser, observe you need to log in again in both instances.

JIRA: DHIS2-18460

Signed-off-by: Morten Svanaes <msvanaes@dhis2.org>
Copy link

sonarqubecloud bot commented Jan 13, 2025

@netroms netroms merged commit fcd65b6 into master Jan 16, 2025
17 checks passed
@netroms netroms deleted the DHIS2-18460 branch January 16, 2025 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants