Prompt users before an inactive session expires

What does this MR do and why?

The backend reports the session deadline on the X-Gitlab-Session-Expires-At header. This reads it from every response, through both the axios interceptor and an Apollo link, and rebroadcasts it so the session-expiry modal pushes its countdown back while the user is active.

It also switches the modal's deadline to the activity-based value from Gitlab::Sessions::Expiry, so on SAML instances a page left open prompts the user to sign in again instead of silently serving a dead session. The page renders that deadline before the request saves its session, so it predicts the value the save will store, using the session store's own write rule, and matches the header. Documentation for the setting is included.

This is the third of three MRs split out from !247910 (closed).

Dependencies

  • Stacked on and targets MR2: !257367 (merged). GitLab retargets this MR to master once MR2 merges.

References

Closes #607513 (closed)

How to set up and validate locally

Setup

  1. Configure a SAML OmniAuth provider so Gitlab::Auth::Saml::Config.enabled? is true.
  2. Enable the flag: Feature.enable(:session_expire_modal_on_saml_instances).
  3. Admin area > Settings > General > Account and limit: set Session duration to a few minutes, then restart GitLab (the duration is read at boot for the Redis TTL and the activity deadline).

Activity mode (this MR's path): deadline slides with activity

  1. Leave Expire from time of last session activity selected. Sign in, open a page, and idle. The modal appears at about the duration and its "Sign in" action navigates to the login page.
  2. Confirm it does not appear while actively browsing, including a page driven entirely by GraphQL and one driven by /api/v4 requests.
  3. Reload discriminator: set the duration to 2 hours, restart, sign in, reload at about 1h30. The modal should appear at about 3h30 (1h30 + 2h), not 2h, because the reload extended the deadline.
  4. Confirm an instance without SAML gets no modal.

Cross-tab

Open two tabs and confirm activity in one pushes back the other's countdown.

Screenshots or screen recordings

The modal itself is the existing session_expire_modal.vue. What is new is that it appears at all when a session expires from inactivity. On master the same page in the same state renders no modal, banner, or error, which is the reported problem, so there is no meaningful "before".

Mode Session expired from inactivity, on an instance with SAML configured
Light Session expired modal, light mode
Dark Session expired modal, dark mode
Edited by Eduardo Sanz García

Merge request reports

Loading
Loading