fix: authenticate WebSockets with subprotocols - #370
Draft
Adamskiee wants to merge 1 commit into
Draft
Conversation
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
Sec-WebSocket-Protocol["sapot.jwt", "<access-token>"]and have the server selectsapot.jwtGET /ws/HTML test client and regenerate OpenAPI and Postman artifactsWhy
WebSocket JWTs were included in request URLs, which can expose credentials through browser history, proxies, access logs, and observability systems. The server and every supported client must adopt the new handshake together because query-token compatibility is intentionally removed.
Closes #225.
Impact
This is a coordinated breaking migration for the server, admin frontend, and mobile app. Updated clients send token-free URLs and authenticate through WebSocket subprotocol negotiation. Preview and production configurations reject plaintext
ws://origins, while explicit local development may still use them.Validation
pnpm run testAll: 132 suites and 1,113 tests passed; typecheck, lint, and Expo Doctor passedsapot.jwtand returned pongGET /ws/with no JWT in the pathgit diff --checkpassedRemaining manual checks
wss://.../ws/URL and negotiatessapot.jwtExisting baseline limitations
Full admin lint and TypeScript checks still report unrelated pre-existing repository errors. The modified admin file passes ESLint and the production build succeeds. The full server pytest suite has existing rate-limit, database, and test-isolation failures; all focused issue #225 regressions pass.