fix(GRO-2234): bounded sliding expiration for SSO portal sessions #183
Reference in New Issue
Block a user
Delete Branch "flea-flicker/gro-2234-portal-session-sliding-ttl"
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?
GRO-2234 — Portal Book New: impersonation session TTL → waitlist submit 401
Problem
Slow-paced Book New wizard completions (~1–2 min) hit
401 {"error":"Unauthorized"}on the finalPOST /api/portal/waitlist; a freshly-minted session with the same payload returns 201. The SSO-bridge portal session minted at page load was a static window with no refresh-on-activity, so a deliberately-paced multi-step wizard could lapse mid-flow.Fix — bounded sliding expiration (preferred approach per triage)
src/middleware/portalSession.ts—validatePortalSessionnow slidesexpiresAtforward tonow + 30 minon each authenticated/api/portal/*request, bounded bystartedAt + 8h(absolute cap). A 60s threshold avoids a DB write on every rapid request. Sliding is scoped toreason="sso-bridge"sessions only, so staff-initiated impersonation sessions sharing this middleware are untouched (AC: no staff regression).src/routes/portal.ts— thesession-from-authSSO-bridge mint TTL is aligned to the 30-min idle window (matches the staff-console impersonation idle model inroutes/impersonation.ts). The dev-onlydev-sessionmint is unchanged.Security (Phase-3, Barkley)
TTL stays bounded and is tightened, not weakened: idle window 30 min (was a 24h static mint), absolute lifetime capped at 8h from
startedAt. Sliding only refreshes an already-valid active session — expired sessions are never resurrected (covered by test).Tests
src/__tests__/portalSessionSliding.test.ts— slide-on-activity, stays valid past the original window, bounded by max lifetime, no slide for staff sessions, no resurrection of expired sessions, sub-threshold write skip. Full suite green (64 tests), typecheck + lint clean.UAT_PLAYBOOK
Updated §4.8 — added TC-API-8.17 (SSO session slides on activity) and TC-API-8.18 (slow-wizard Book New submit returns 201).
Note for reviewer
The deployed mint was already 24h (not literally ~1 min), so this API-side sliding tightens/repairs the model but a companion groombook/web change (transparent re-mint on 401 in
CustomerPortal) carries the deterministic user-facing fix and ships alongside.cc @cpfarhood