Skip to content

feat: require a per-home token on the RPC listener - #173

Open
sanchitrk wants to merge 1 commit into
feat-oauth-clerkfrom
feat/local-door
Open

sanchitrk wants to merge 1 commit into
feat-oauth-clerkfrom
feat/local-door

Conversation

@sanchitrk

@sanchitrk sanchitrk commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #171. It lands in canary once #171 merges.

What changes

A CodeWork server no longer accepts any local caller. It keeps a token per home and refuses a WebSocket upgrade that does not carry it.

  • Token. Created once in <home>/token (mode 0600) and copied into service.json at each start. Delete the file and restart to replace it.
  • Door. Runs before the upgrade. A missing or wrong token gets 401. A foreign Host (on a loopback bind) or Origin gets 403.
  • Transport. The client offers Sec-WebSocket-Protocol: codework, <token>. The server selects codework, so the token is never echoed.
  • CLI. Sends the token only to the server its home registered. A loopback alias with the same port and path reaches that server; any other --server URL is refused with a plain error and hint. --home now works with --server.
  • App server. Takes its own token per start, printed in its ready line and handed to the renderer over the preload bridge. Each remote server row stores a token, which is never returned to the renderer.
  • server.info reports the machine id.

Also in here

  • The OrbStack machine fixtures install from the checkout under test instead of a pinned commit.
  • A reads test assumed a reply's first chunk always arrives as a delta. It can arrive in the draft message instead. The test now accepts both; no production code changed.

Breaking

  • A remote server row saved before this change has no token and is refused until it is added again.
  • A client that connects without the token is refused, on loopback too.

Verified

Check Result
vp check, vp run typecheck, knip exports pass
packages/codework tests 151 passed, 23 skipped
apps/server tests, three runs 42 passed each
Live sync suite on four OrbStack machines, three runs 12 passed each
Live usage, recovery and daemon suites 6, 5 and 1 passed

Also driven by hand: the upgrade matrix from the Mac and between three OrbStack machines, the Electron app through setup, connect and a real prompt, and each CLI --server case.

Known gaps

  • The token travels in clear over ws:// to a non-loopback host.
  • The desktop app has no screen yet for adding a remote server with its token.
  • The live machine suites share a machine, so they run one file at a time.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

A server now keeps a token in <home>/token and refuses a WebSocket
upgrade that does not offer it, or that comes from a foreign Host or
Origin. The token is published in service.json, and the CLI, the app
server and the desktop renderer send it when they connect.

- The CLI sends the token only to the server its home registered, and
  prints a plain error for any other --server URL.
- The app server takes its own token per start and stores one on each
  remote server row.
- server.info reports the machine id.
- Machine test fixtures install from the checkout under test.
- Fix a reads test that assumed the first chunk arrives as a delta.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant