fix(auth): revoke web sessions on logout#2351
Closed
jeanduplessis wants to merge 5 commits intomainfrom
Closed
Conversation
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (17 files)
Reviewed by gpt-5.4-20260305 · 1,374,800 tokens |
135e8ce to
017ce17
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Code-related pentest M2 session-handling findings are addressed with scoped web-session revocation and route-level admin authorization checks.
M2: Web session revocation after logout
kilocode_users.web_session_version, stores that version in the NextAuth JWT/session at sign-in, and rejects requests ingetUserFromAuthwhen the session version no longer matches the database row.POST /api/auth/revoke-web-sessionand call it from normal sign-out, auto sign-out, and dev account nuke flows before client-side sign-out.0while the database row is still0, avoiding a blanket logout on rollout.web_session_versionin user/admin API-token reset flows along withapi_token_pepper, so “reset token and sign out everywhere” semantics remain true for web sessions.M2: Route-level admin API authorization
getUserFromAuth({ adminOnly: true })checks to credit category admin API endpoints that previously relied on middleware as the effective auth boundary.Verification
pnpm test -- apps/web/src/lib/web-session-revocation.test.tspnpm formatVisual Changes
N/A
Reviewer Notes
0104_thin_hedge_knight.sqlbefore routing traffic to this web build.kilocode_users.web_session_version integer DEFAULT 0 NOT NULL.getUserFromAuthrejects stale web sessions when the session version no longer matches the database row.POST /api/auth/revoke-web-session; endpoint is intentionally idempotent and only increments web session state.web_session_versionin the same transaction asapi_token_pepperrotation.web_session_version, 5xx on/api/auth/revoke-web-session,Reauthentication required401 spikes, login/signout conversion.