Skip to content

19.0 fw 534 session_redis absolute expiration - #540

Open
leemannd wants to merge 5 commits into
19.0from
19.0-fw-534-session_redis-absolute-expiration
Open

leemannd wants to merge 5 commits into
19.0from
19.0-fw-534-session_redis-absolute-expiration

Conversation

@leemannd

@leemannd leemannd commented Nov 3, 2026

Copy link
Copy Markdown
Member

vvrossem and others added 5 commits November 3, 2026 17:57
ODOO_SESSION_REDIS_EXPIRATION_ABSOLUTE=1 makes authenticated sessions expire
ODOO_SESSION_REDIS_EXPIRATION seconds after the login, whatever the activity.

Default mode: SET … EX instead of SET then EXPIRE, so a failed EXPIRE can no
longer leave a key without TTL. rotate() also resets should_rotate, as
odoo.http.FilesystemSessionStore does.
In 19.0, the store reuses odoo.http.FilesystemSessionStore.rotate, which
saves the session under a new key without marking it as new:

* login, logout and MFA (hard rotation): SET … XX on the new key failed,
  so the session was never stored and the user could not log in
* soft rotation, every odoo.http.SESSION_ROTATION_INTERVAL: the data
  moves to a new key, so KEEPTTL could not carry the TTL over

rotate() now saves the new key as a new session (full TTL, as the 17.0
rotate did) and, on a soft rotation in absolute mode, gives it the
remaining TTL of the old key, read before the old key gets its
deletion_time. A request following a soft rotation already done by a
concurrent one keeps the TTL of the new key.

The old key of a soft rotation (deletion_time) no longer takes the
KEEPTTL path.
On a soft rotation, odoo.http keeps the old session with a deletion_time,
a timestamp (time.time() + SESSION_DELETION_TIMER), but save() used it as
a TTL. Being a float, it was then replaced by the 3 hours of the anonymous
sessions: the old session id stayed valid for 3 hours instead of 2 minutes.

The TTL is now the time left until deletion_time.
ODOO_SESSION_REDIS_EXPIRATION and ODOO_SESSION_REDIS_EXPIRATION_ANONYMOUS
are read as strings, and save() replaced any expiration that is not an
int by the 3 hours of the anonymous sessions: whatever their value, all
the sessions expired after 3 hours of inactivity.

The expirations are now converted to int when the store is created
(unset, empty or 0 meaning the default), and the workaround in save()
is removed.
get_missing_session_identifiers() looked for "session::session:<id>*"
instead of the "session:<id>*" keys built by the store, so every session
was reported missing, and res.device.log._update_revoked() flagged the
device logs of still valid sessions as revoked.

The pattern is now built with build_key(), as the keys are.
@leemannd leemannd changed the title 19.0 fw 534 session redis absolute expiration 19.0 fw 534 session_redis absolute expiration Nov 3, 2026
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