[codex] Reject websocket tokens after session expiry#1838
[codex] Reject websocket tokens after session expiry#1838juliusmarminge merged 1 commit intot3code/remote-auth-pairingfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
87848ec to
a289f76
Compare
a289f76 to
c5fc3f3
Compare
ApprovabilityVerdict: Needs human review This PR modifies authentication logic in the auth directory, adding session expiry validation for websocket tokens. Regardless of the change's simplicity, modifications to auth-related code require human review to ensure the security implications are properly evaluated. You can customize Macroscope's approvability policy. Learn more. |
de5ecce
into
t3code/remote-auth-pairing
Co-authored-by: Julius Marminge <julius@macmini.local>
What changed
Why
verifyWebSocketToken()validated only the websocket token claim expiry and revocation state. A websocket token could therefore outlive the underlying session row and still authenticate until its own shorter TTL elapsed.Validation
bun fmtbun lintbun typecheckcd apps/server && bun run test src/auth/Layers/SessionCredentialService.test.tsNote
Reject websocket tokens when the parent session has expired
Previously,
verifyWebSocketTokenonly checked if a session was revoked, not if it had expired. Now, after fetching the session row, it comparesexpiresAtagainst the current time and returns aSessionCredentialErrorwith message'Websocket session expired.'if the session is past its TTL. A test usingTestClockadvances time past a 1-second session TTL to verify the new rejection behavior.Macroscope summarized c5fc3f3.
Note
Medium Risk
Touches session authentication checks: websocket token verification now depends on the persisted session expiry, which could impact active websocket connections if clock/TTL handling is off. Change is small and covered by a new clock-driven regression test.
Overview
Websocket authentication now fails once the underlying session expires.
verifyWebSocketToken()now checks the parent auth session row’sexpiresAtagainst the current time and returns aSessionCredentialErrorwhen the session is expired, even if the websocket token’s ownexpis still valid.Adds a regression test using
TestClockthat issues a short-lived session, mints a websocket token, advances time past the session TTL, and asserts the websocket token is rejected.Reviewed by Cursor Bugbot for commit c5fc3f3. Bugbot is set up for automated code reviews on this repo. Configure here.