Sessions that work across replicas (sealed cookies) #103

Closed
opened 2026-11-18 05:14:40 +00:00 by jcoffey-dev · 3 comments
Owner

K-W1 · size M · part of inbuxa for Kubernetes (tracking issue in inbuxa-charts)

Sessions live in a per-process Map today, so only one replica can run. Seal the session into an encrypted, signed cookie keyed from APP_SECRET, with a key list for rotation. SESSION_FILE stays for single-node installs.

Done when

  • Two replicas behind a round-robin balancer: sign in on one, keep working on the other
  • Key rotation tested
  • Cookie size within the limit found by S3
  • Single-node behaviour unchanged

Depends on: S3

**K-W1** · size M · part of inbuxa for Kubernetes (tracking issue in inbuxa-charts) Sessions live in a per-process Map today, so only one replica can run. Seal the session into an encrypted, signed cookie keyed from APP_SECRET, with a key list for rotation. SESSION_FILE stays for single-node installs. **Done when** - Two replicas behind a round-robin balancer: sign in on one, keep working on the other - Key rotation tested - Cookie size within the limit found by S3 - Single-node behaviour unchanged **Depends on:** S3
jcoffey-dev added this to the 27.1 milestone 2026-11-18 05:14:40 +00:00
jcoffey-dev added the
priority
p1
enhancement
labels 2026-11-18 05:14:40 +00:00
jcoffey-dev self-assigned this 2026-11-18 06:28:58 +00:00
Author
Owner

Scope settled (spike S3, decided 2026-11-17):

  • New SessionBackend implementation that carries the record in the cookie (the interface in server/src/sessions.ts was written for this). Chosen by config, for example SESSION_BACKEND=cookie; the default stays the in-memory/SESSION_FILE store.
  • OAuth sessions only in cookie mode. Password sign-in is refused there with a clear message, since a sealed password can't be revoked.
  • listForUser returns only the current session, and the UI hides the sessions list and 'sign out other sessions' when the backend says it can't enumerate.
  • destroyAllForUser on password or app-password change: the server already invalidates every token for the account (credential version), so the webmail only has to drop its own cookie.
  • Key rotation through a list of keys derived from APP_SECRET values (newest seals, all open).
  • Cookie size: well under 1 KB expected; checked against a real token in the lab.
**Scope settled (spike S3, decided 2026-11-17):** - New `SessionBackend` implementation that carries the record in the cookie (the interface in `server/src/sessions.ts` was written for this). Chosen by config, for example `SESSION_BACKEND=cookie`; the default stays the in-memory/`SESSION_FILE` store. - OAuth sessions only in cookie mode. Password sign-in is refused there with a clear message, since a sealed password can't be revoked. - `listForUser` returns only the current session, and the UI hides the sessions list and 'sign out other sessions' when the backend says it can't enumerate. - `destroyAllForUser` on password or app-password change: the server already invalidates every token for the account (credential version), so the webmail only has to drop its own cookie. - Key rotation through a list of keys derived from `APP_SECRET` values (newest seals, all open). - Cookie size: well under 1 KB expected; checked against a real token in the lab.
Author
Owner

Fixed in #109, merged to main; ships in the next 27.1 release candidate.

Fixed in #109, merged to main; ships in the next 27.1 release candidate.
Author
Owner

Follow-up: a sign-in itself still couldn't cross replicas (the pending OAuth state lived in the process). Fixed in #113, merged; it ships in the next 27.1 release candidate.

Follow-up: a sign-in itself still couldn't cross replicas (the pending OAuth state lived in the process). Fixed in #113, merged; it ships in the next 27.1 release candidate.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: inbuxa/inbuxa-webmail#103