Repository navigation
feat(auth): implement session management for user devices - #789
Conversation
- Add SessionStore interface and Redis implementation for session management. - Introduce session handling in auth service, including session creation, listing, and revocation. - Implement HTTP handlers for session management, allowing users to view and manage their active sessions. - Enhance authentication middleware to check for revoked sessions. - Add tests for session management functionality, ensuring proper behavior for session creation, revocation, and listing.
There was a problem hiding this comment.
Important
The registry is the only input to "sign out all other devices", and one token-rotation path never writes it, so some live sessions are invisible in the UI and cannot be ended from it.
Approach: sound — sessions ride the existing refresh-token family, so revocation reuses one token lifecycle and one Authn chokepoint instead of introducing a second identity concept.
Reviewed changes
Read the full diff for 3ab10b8 (34 files): the Redis registry and session lifecycle, the access-token revocation check, the three self-service routes and handler, the web card with its locales, and the tests.
- Session registry — one hash per family plus a per-user sorted index scored by last activity, both expiring with the refresh token and pruning entries whose hash already expired.
- Lifecycle wiring — sessions recorded at password, MFA, passkey and SSO login, touched on refresh with adoption of pre-registry sessions, and forgotten on logout.
- Immediate revocation —
Authnnow rejects an access token whose family was signed out (fail-open on lookup errors), closing the up-to-15-minute window. - Self-service API — list, revoke one, and revoke all others, JWT-only and scoped to the caller's account with a uniform 404 for unknown or foreign ids.
- Web —
SessionsCardwith per-device and bulk sign-out behind confirmation, translated in all nine locales. - Tests — miniredis store tests, service and handler coverage, authn revocation including fail-open, the User-Agent parser, route coverage, and the card's component tests.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the delta from 3ab10b8 to 48c4090 (5 files), which addresses all four findings from the previous review.
- Index expiry is now atomic — the TTL read and conditional
PEXPIRErun in one Lua script inside the save transaction, so concurrent saves with different TTLs can only extend the per-user index. - Non-UUID session ids are rejected —
Get/Deletetreat malformed ids as not-found, soDELETE /users/me/sessions/{sessionId}returns the documented 404 instead of aWRONGTYPE500. - Annotation refresh keeps the registry current —
RefreshAnnotationnow callsrecordSession, so a family kept alive only by the extension stays listed and revocable. - Stale revoke error cleared — the dialog's
onSuccessresetsfailedbefore closing. - New tests — store coverage for non-UUID ids and non-shortening index expiry, plus a service test that annotation refresh re-registers a lapsed session.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the delta from 48c4090 to 180b147 (2 files), which adds Playwright coverage for the signed-in devices feature.
- Feature specification —
apps/e2e/features/auth/sessions.featurerecords the seven scenarios: listing, browser/system labels, logout removal, per-device sign-out, cancelling, sign-out all others, and cross-account/malformed-id 404s. - Browser coverage —
apps/e2e/tests/auth/sessions.spec.tsdrives each scenario with separate browser contexts and spoofed User-Agents, and verifies revocation with real API calls plus a reload-to-login check rather than UI state alone. - Isolation and conventions — throwaway users under a non-overlapping
E2E_SESSIONS_prefix, per-test cleanup, contexts closed infinally; helpers and selectors match the existing auth specs and the card's accessible names.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
…ved revocation handling
There was a problem hiding this comment.
ℹ️ No critical issues — one minor observation inline.
Reviewed changes
Reviewed the delta from 180b147 to 4c2b42a (7 files, +40/-10), a hardening pass over the session registry, revocation and client-info paths.
- Sign-in origin is now write-once — the Redis session hash keeps the first
ipanduser_agentviaHSetNXand records each refresh's address in a separatelast_ip, so a session used from elsewhere cannot rewrite where it began. - Bulk sign-out is resilient —
RevokeOtherSessionsskips families that are already revoked, keeps revoking the rest when oneRevokeFamilyfails, and returns the combined error; the handler also refuses to run when the caller's token carries no family id. - Outage logging is throttled — a failing revocation lookup now warns at most once a minute instead of once per authenticated request.
- User-Agent handling tightened — the Opera match requires
Opera/, and oversized headers are truncated on a valid UTF-8 boundary. - Store test updated — asserts the sign-in IP survives a refresh and the new address lands in
last_ip.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the delta from 4c2b42a to 176fab44 (3 files), which acts on the previous review's minor observation about the unused last_ip field.
LastIPremoved end to end — the domain field, thelast_iphash write inSave, its decode indecodeSession, and the store-test assertion are gone, so the session hash now carries only fields something reads.- Sign-in origin still write-once —
ipanduser_agentremainHSetNXandlast_active_atis the only field rewritten on a refresh; the store test still asserts a refresh from a new address cannot overwrite the recorded sign-in address. - No stragglers — nothing in the repo references
LastIP/last_ipany more, and unknown hash fields are ignored on read, so hashes written by4c2b42astay readable.
gofmt, go vet and the domain/auth, repository/redis and service/auth test packages are clean at 176fab44.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
Secondary text and hairlines were faded well past readability. The base tokens were fine on their own (muted text 4.7:1 on white), but components layered heavy opacity on top: ~380 uses of muted text at /30-/60 rendered at roughly 1.5-2.3:1, and borders at /10-/30 were close to invisible (1.04-1.12:1). Tokens (index.css): - --muted-foreground: #737373 -> #5f5f5f (light, 6.4:1), #888888 -> #a0a0a0 (dark, 7.6:1) - --border/--input: #d4d4d4 -> #c8c8c8 (light), #2a2a2a -> #3a3a3a (dark) - --sidebar-border: #e8e8e8 -> #dedede (light), #1e1e1e -> #2a2a2a (dark) Opacity floors across components (mechanical sweep): - text-muted-foreground /30-/60 -> /90 (>= 4.5:1 on background, muted and secondary surfaces in both themes; /85 would still fail at 4.48:1), /70-/90 -> full strength, so two tiers remain - text-sidebar-foreground /30-/50 -> /60 (4.94:1 light, 6.53:1 dark); the sidebar has its own foreground token - border/divide/ring/bg-border /10-/35 -> /50, /40 -> /60; Gantt gridlines /12 -> /30 so they stay lighter than row dividers. The dashed row dividers from Paca-AI#785 are left as tuned. The Gantt drag tests located groups by a border class; they now use a `data-gantt-group` attribute so styling changes don't break them. Rebuilt on current master (after Paca-AI#784, Paca-AI#785-Paca-AI#787, Paca-AI#789) so the new file-management components get the same treatment. Co-Authored-By: Claude Opus 5.5 <[email protected]>

Summary
Lets users see the browsers/devices their account is signed in on and sign any of them out (Account → Security → "Signed-in devices").
Login was stateless (JWTs plus a Redis refresh-token family per login) and nothing listed those families. Each family is now a session, tracked in a Redis registry.
Backend
SessionStoreinterface (domain/auth) with a Redis implementation (session:{familyId}hash + per-user sorted index, both expiring with the refresh token). No DB migration. Stores IP, User-Agent, created time and last-active time.IssueSessionnow takes actxto read client info), touched on every refresh (sessions that predate this change are adopted on their next refresh), and removed on logout.Authnnow also rejects access tokens whose family is revoked, viaManager.WithRevocationCheck. This adds one Redis lookup per authenticated request. If the lookup errors it fails open, so a Redis outage does not sign everyone out; refresh still fails closed.GET /users/me/sessionsDELETE /users/me/sessions/{sessionId}DELETE /users/me/sessions(all but the current one)404 SESSION_NOT_FOUND, same as an unknown one.Web
SessionsCardon the security page: device name, IP, last active, sign-in date; current device is badged and has no sign-out button (use normal logout). Per-device and "sign out all other devices" actions both confirm first.Notes
Testing
Authnrevocation (including fail-open), User-Agent parser, route coverage.SessionsCardtests,tsc -b, biome, locale parity test.