Repository navigation
fix(gateway): keep auth-none local clients connected after pairing - #124545
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 8:01 AM ET / 12:01 UTC. ClawSweeper reviewWhat this changesThe PR names Control UI pairing exemptions so auth-none local backend and TUI sessions remain connected after a narrower paired-device record exists, without widening durable device tokens. Merge readinessKeep open for maintainer review: the patch cleanly separates local auth-none session admission from durable paired-token scope limits, with focused regression coverage and isolated Gateway proof. Its deliberate authorization-boundary change needs explicit maintainer acceptance before merge. Priority: P2 Review scores
Verification
How this fits togetherGateway WebSocket admission evaluates authentication, locality, role, and device pairing before a client can use operator methods. Device-pairing records also retain metadata and constrain reusable device-token scopes. flowchart LR
A[Local client] --> B[Gateway handshake]
B --> C[Authentication and locality]
C --> D[Pairing exemption reason]
D --> E[Session admission]
E --> F[Paired-device metadata]
F --> G[Durable token scope bound]
Decision needed
Why: This is a deliberate Gateway authorization-policy decision; source confirms durable tokens remain scoped, but automation should not choose the intended session trust boundary. Before merge
Agent review detailsSecurityNone. PR surfaceSource +19, Tests +128. Total +147 across 9 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the closed exemption reason and separate session admission from durable-token issuance; merge only after the owner accepts this bounded trust-policy change and exact-head checks complete. Do we have a high-confidence way to reproduce the issue? Yes: current-main source shows a paired record always reaches the scope-cap authorization path, and the PR supplies focused before/after tests plus an isolated real Gateway trace. Is this the best way to solve the issue? Yes, subject to maintainer policy acceptance: the patch fixes the owner boundary and preserves the independent durable-token cap rather than widening paired scopes or adding a fallback. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against bba57301d9c5. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
ClawSweeper rank-up move resolved:
No ClawSweeper findings remain, and its Tailscale/durable-token boundary checks match the local review and live proof. |
|
Merged via squash.
|
What Problem This Solves
Fixes an issue where local Gateway backend calls and TUI sessions on a loopback
gateway.auth.mode: "none"Gateway could connect until any narrower pairing row existed for the same device identity. After that row appeared, the identical connection was rejected as an unapprovable scope upgrade even though locality plus the configured auth mode—not the pairing record—was the authority for that session class.This PR is AI-assisted; the implementation and evidence were reviewed against the complete Gateway connect path and its durable device-token boundary.
Why This Change Was Made
The Control UI pairing policy now returns a closed reason (
auth-none,tailscale-device, or no exemption) instead of collapsing two different trust boundaries into one boolean. Local backend self-calls and auth-none operator UIs bypass stored pairing access checks both before and after a row exists, while paired reconnects still refresh last-seen metadata and retain the row as the durable token baseline.ensureDeviceTokenremains unchanged and continues to reject token scopes beyond that approved baseline.The Tailscale Control UI path is intentionally not hoisted: an existing pairing row remains its access cap. The device-approval recovery path also requests only
operator.pairingwhen reading the pairing list.Production LOC: +35/-16 (net +19) | Tests: +189/-61. The production growth encodes the closed auth-boundary reason and the explicit separation between session admission, metadata refresh, and durable grant issuance; the obsolete paired-backend rejection test was removed rather than preserved as compatibility.
User Impact
Operators running an auth-none loopback Gateway can keep using local
gateway-clientbackend calls and the TUI after another command has created a narrower pairing row for the shared device identity. Existing durable device tokens are not widened, remote/non-loopback clients are unchanged, and paired Tailscale Control UI sessions remain capped by their approved scopes.Evidence
Pre-fix owner-boundary proof (new regression test retained, production changes stashed):
PAIRING_REQUIRED,reason: scope-upgradeFocused and boundary suites:
node scripts/run-vitest.mjs src/gateway/server/ws-connection/— 58 files, 584 tests passednode scripts/run-vitest.mjs src/gateway/server.auth*.test.ts— 7 files, 135 tests passednode scripts/run-vitest.mjs src/gateway/server.device-scope-upgrade.test.ts— 10 tests passednode scripts/run-vitest.mjs src/gateway/server.silent-scope-upgrade-reconnect.poc.test.ts— 7 tests passedpnpm format <changed paths>— passedpnpm check:changed— passed on trusted remote Linuxpnpm build— passed on trusted remote LinuxLive isolated Gateway proof used a fresh state directory, port 19435, and config:
{"gateway":{"mode":"local","port":19435,"auth":{"mode":"none"}}}After seeding the shared device identity with an approved
operator.pairingrow, the patched built Gateway was started with:The real
gateway-client/backendconnection requestedoperator.writeand returned:{"verdict":"admitted","pairedBaseline":["operator.pairing"],"requestedScopes":["operator.write"],"healthOk":true,"storedTokenScopes":["operator.pairing"],"lastSeenReason":"connect"}Gateway log excerpt:
The isolated Gateway was stopped cleanly and port 19435 was verified free afterward.
Known gap / follow-up
Plain
cli/cliclients remain non-exempt by design. On an auth-none install, the first CLI command can still pair the shared identity at a narrow scope and a later differently scoped command can become an unapprovable scope upgrade. That is a separate client-identity ownership issue:src/gateway/call.ts:445(shouldOmitDeviceIdentityForGatewayCall) requires shared-secret auth forisLocalCliSharedAuth, so auth-none CLI calls attach an identity while token-authenticated local CLI calls omit it. This PR does not change that policy,shouldAllowSilentLocalPairing, scope-upgrade silence, browser origins, browser-copilot checks, or remote behavior.