refactor!: configure the session lifetime as a policy object - #6658
Merged
Conversation
The four `session_*` keys describe one thing — how long a backend session lives
and when the user is warned — so they become a `SessionPolicy` next to the login
and password policies:
BackendLogin::$sessionPolicy = new SessionPolicy(duration: 1800, warningTime: 60);
`Login` stops reading `session_max_overall_duration` on its own. The base class
is used for frontend logins as well, which silently inherited the backend's
value; the property keeps the four weeks as its default now, and `BackendLogin`
sets both durations from its policy. A login outside the backend that wants a
limit of its own sets it on its own class.
The keep alive and warning times are only passed on to the backend js, the two
durations are additionally used by `UserSession`, `HistoryLogin` and the session
status api function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removes
session_duration,session_keep_alive,session_max_overall_durationandsession_warning_timefrom theconfig.yml. They describe one thing — how long a backend session lives and when the user gets warned — so they become one object, next to the two policies that moved in #6655:keepAliveandwarningTimeare only handed to the backend js;durationandmaxOverallDurationare additionally used byBackendLogin,UserSession,HistoryLoginand the session status api function.The base class stops reading global config
Login::__construct()readsession_max_overall_duration— andLoginis the base class for frontend logins too, which therefore silently inherited the backend's limit. The property now carries the four weeks as its default, andBackendLoginsets both durations from its policy.This is a behaviour change: a project that configured
session_max_overall_durationalso affected addon frontend logins until now. Those fall back to the default; a login outside the backend that wants its own limit sets$sessionMaxOverallDurationon its own class.No validation
Unlike
LoginPolicy, which rejects zeros because a zero silently locks everyone out of the backend,SessionPolicytakes the values as they are:keepAlive: 0is a meaningful "no keep alive", and the js treats it that way.Not in here
session.*— the cookie parameters and the save path — stays for now. It is the block that should be answered together with issue #2065 (Login::startSession()implies a login) and with the question whether the session mechanics move ontosymfony/http-foundation's session, which is already a direct dependency and whoseNativeSessionStoragetakes exactly these options. Migrating that block into a REDAXO object first would mean migrating projects twice.Verified
The four values reach
rex.session_*in the backend js, both with the defaults and with a project policy (duration: 900, keepAlive: 0, warningTime: 60), and the session status api reportsrest_overall_timefrom the configuredmaxOverallDuration.