fix(auth): host-scope the OP session cookie by default; opt-in for cross-subdomain sharing #283
No reviewers
Labels
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
psa-systems/bunyip!283
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/BUNYIP-266-host-only-op-session-cookie"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
BUNYIP-266: when
COOKIE_DOMAINis set to a parent (e.g..a8n.systemson c-01,.psa.systemson nc-01), thebunyip_op_sessioncookie is sent to every sibling subdomain (mailpit, infisical, mokosh-apps, drillmark) on every request, widening the steal surface. The audit's recommendation is host-only by default with an explicit opt-in for the rare deployment that genuinely needs cross-subdomain sharing.Adds
cookie_shared_domain: bool(envBUNYIP_COOKIE_SHARED_DOMAIN, default false) toConfig, plus aConfig::op_session_cookie_domain()helper that returnsSome(cookie_domain)only when the flag is set. The cookie is then host-only by default regardless of howCOOKIE_DOMAINis configured. The hub access/refresh cookies still honourcookie_domainfor now; tightening those is a separate ticket.A startup
tracing::warn!fires whenCOOKIE_DOMAINis set withoutBUNYIP_COOKIE_SHARED_DOMAIN=trueso an operator who relied on the previous default is notified before the next login flips behaviour.The c-01/nc-01 staging/prod deployments set
BUNYIP_COOKIE_SHARED_DOMAIN=truein a sibling docker-repo PR to preserve the current behaviour; flipping it to host-only is a deliberate operator change after they've audited which siblings (if any) actually read the cookie.Existing user sessions are not invalidated: the old domain-scoped cookie keeps working until natural expiry (7 days), and the next login emits a host-scoped cookie. No forced logout.
The
__Host-cookie-prefix half of the audit recommendation is deferred to a follow-up because renaming the cookie would force every active user through/loginonce; that's a UX hit this PR is structured to avoid.#BUNYIP-266