Skip to content

Expire session from time of creation

What does this MR do and why?

Expire session from time of creation

Adds a new application setting, hidden behind a feature flag. If enabled, sessions expire after the "default session duration" time specified in application settings. The sessions expire even if a user is actively browsing GitLab, causing the user to have to sign in again. For some organizations running GitLab, this is a necessary security control.

Part 1 of 2: next MR will include frontend elements so a user is notified that their session has ended and they must log in again.

Co-authored-by: @johnwparent

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After
Screenshot_2025-03-04_at_9.04.16_PM Screenshot_2025-03-04_at_9.00.12_PM

How to set up and validate locally

  1. Enable the feature flag on the Rails console: Feature.enable :session_expire_from_init
  2. Go to Admin Area ➡️ Settings ➡️ General ➡️ Account and Limit - https://gdk.test:3443/admin/application_settings/general#js-account-settings
  3. Set a short Session duration (minutes) - 2 or 3 minutes
  4. Enable the Expire session from creation date checkbox
  5. Save your changes
  6. Log out
  7. Restart GitLab locally - gdk restart rails-web (changes to default session duration only apply after restart)
  8. Log in again once the app has rebooted
  9. Browse the site for 3 or 4 minutes
  10. After the default session duration, you should be automatically logged out, and your next request will take you to the sign-in page.

Related to #395038 (closed)

Merge request reports

Loading