Repository navigation
feat(server): revoke the current session on DELETE /api/session - #200
Conversation
Auth.owner returned 401 for an expired session but kept its row, so every sign-in that was never revoked left a dead row behind. Remove the row when it is found expired. Also applies biome formatting to the session-logout test.
The expiry cleanup delete runs before the 401 is thrown; a failing remove would surface as a 5xx instead of the intended 401. Make the cleanup best-effort so rejection is unaffected.
jerelvelarde
left a comment
There was a problem hiding this comment.
Reviewed 640ef0d261aeb2f0f523d0a0149184c87009057a.
Value and template fit: Adds a useful server-side session revocation endpoint and opportunistic expired-row cleanup. Fits existing hashed-session storage and auth middleware. Client sign-out wiring and periodic expired-row sweeping are explicitly out of scope.
Security review: Verified DELETE is behind bearer authentication; signed-file URL exceptions cannot authorize this path. Revocation targets only the supplied token digest, other sessions remain valid, and cleanup failure still rejects expired tokens. No actionable security finding. Existing signed links have their own expiry and are not revoked by this endpoint.
Verification: 13 API tests passed, including revoked-token rejection, other-session survival, expiry cleanup and cleanup failure. Executed on this exact head in a read-only, network-disabled Linux container using Node 24.17.0 and tsx, with telemetry disabled. All seven GitHub CI jobs passed for this head.
Limits: local dependencies were installed from the main manifest rather than the pnpm lockfile; lockfile-based lint/types/full tests/builds are covered by GitHub CI. No live providers or native devices exercised. No actionable blocker found. Merge remains subject to current-head and integration checks.
Closes #199
What
Adds
DELETE /api/session. It runs behind the existing/api/*auth middleware, so only a valid session can call it, and it deletes the caller's own session row (system/sessions, keyed by the token digest, the same lookupAuth.owneruses). Once revoked, the token returns 401 on every route. Other sessions are untouched.Also cleans up expired sessions. Before this change,
Auth.ownerreturned 401 for an expired session but kept its row, so every sign-in that was never revoked left a dead row behind permanently. It now deletes the row when it rejects it as expired, best-effort so a failed cleanup still returns the intended 401. This is housekeeping, not a security fix. A row that expires and is never presented again still stays; a periodic sweep would cover that case but needs newStoresurface, so it's out of scope here.apps/server/src/auth.ts:Auth.revoke(authorization), which usesdb.remove;Auth.ownerremoves a session row it finds expiredapps/server/src/app.ts: the route, registered after the auth middlewaretests/api.test.ts:/api/workspaceand on a repeatDELETE, while the original session still gets 200auth.ts.Client sign-out wiring is left for a follow-up.
Tested
pnpm lint,tsc --noEmitpnpm test: 490 passed, 0 failed