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.
- Feature issue: #395038 (closed)
- Broken out from original MR: !138572 (closed)
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 |
|---|---|
![]() |
![]() |
How to set up and validate locally
- Enable the feature flag on the Rails console:
Feature.enable :session_expire_from_init - Go to Admin Area
➡️ Settings➡️ General➡️ Account and Limit -https://gdk.test:3443/admin/application_settings/general#js-account-settings - Set a short Session duration (minutes) - 2 or 3 minutes
- Enable the Expire session from creation date checkbox
- Save your changes
- Log out
- Restart GitLab locally -
gdk restart rails-web(changes to default session duration only apply after restart) - Log in again once the app has rebooted
- Browse the site for 3 or 4 minutes
- 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)

