fix(server): verify session/machine ownership at websocket connection time#784
Open
ex3ndr-bot wants to merge 2 commits intoslopus:mainfrom
Open
fix(server): verify session/machine ownership at websocket connection time#784ex3ndr-bot wants to merge 2 commits intoslopus:mainfrom
ex3ndr-bot wants to merge 2 commits intoslopus:mainfrom
Conversation
added 2 commits
February 28, 2026 04:56
Moves the following packages from dependencies to devDependencies: - @types/cross-spawn - @types/http-proxy - @types/ps-list - @types/qrcode-terminal - @types/react - @types/tmp Fixes slopus#766
… time Fixes slopus#761: happy-agent send fails due to missing session claim in JWT The issue was that account tokens (used by happy-agent) don't have session claims, but the websocket should still work for session-scoped connections. Instead of requiring session claims in the JWT, we now verify session/machine ownership via database lookup at connection time. This approach: 1. Allows account tokens (from /v1/auth/account/request) to work with session-scoped connections 2. Maintains security by verifying the session belongs to the authenticated user 3. Adds consistent validation for machine-scoped connections as well The verification happens early in the connection flow, rejecting unauthorized connections before any handlers are registered.
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
This PR fixes issue #761 where
happy-agent sendfails because the agent.key token lacks a session claim that the websocket connection requires.Problem
/v1/auth/request) creates tokens WITH session claims:{ session: answer.id }/v1/auth/account/request) creates tokens WITHOUT session claimshappy-agentuses account auth, so its tokens don't have session claimsSolution
Instead of requiring session claims in the JWT (which wouldn't make sense for account-scoped tokens), we now verify session/machine ownership via database lookup at websocket connection time.
Changes
dbimport tosocket.tsThis approach:
/v1/auth/account/request) to work with session-scoped connectionsTesting
The fix adds proper authorization checks at the websocket connection layer. The existing tests for session operations (which verify
accountId: userId) continue to provide defense in depth.