Repository navigation
Commit ea36b12
Harden gateway connection and pairing flows (#741)
* Harden gateway connection and pairing flows
Consolidate the connection/pairing hardening work into one validated change set.
Connection and credential handling:
- keep gateway credentials registry-backed and preserve strict credential precedence: device token, shared gateway token, then bootstrap token
- force fresh setup-code bootstrap credentials for immediate QR/setup-code pairing while preserving shared gateway tokens for HTTP/dashboard paths
- dedupe loopback-equivalent gateway URLs so localhost and 127.0.0.1 records do not split pairing state
- validate replacement shared tokens before disconnecting or clearing durable device tokens
- clear stale bootstrap tokens only after required role tokens are durably readable
- recover stale operator device-token mismatches by falling back to bootstrap when recovery material is still present
Operator/node pairing and token lifecycle:
- keep operator clients in the operator role during bootstrap while preserving explicit node bootstrap behavior
- persist role-specific handoff tokens from hello-ok auth.deviceTokens[] for both operator and node roles
- forward WindowsNodeClient node-token receipt through NodeConnector so GatewayConnectionManager can complete bootstrap cleanup after the node token becomes durable
- request operator.pairing with normal shared-token operator connects so node trust approvals can be reached
- wait for node/device pair approval responses instead of treating a sent frame as success
- fall back from node.pair.approve to device.pair.approve only when admin authority is available
- guard node connection events by client generation so stale clients cannot mutate current state
- abort node handshake when pre-connect capability binding fails, preventing caps=0/cmds=0 registrations
Tray, MCP, and browser-control behavior:
- expose connection-control MCP tools only through local MCP, not the gateway node transport
- route MCP setup-code and shared-token connection tools through GatewayConnectionManager
- refresh gateway node state when local node connected/paired events arrive
- register browser.proxy only when a live gateway client and shared gateway token are available, and use the shared token for browser-control HTTP auth
Setup and reliability:
- add bounded retry for transient WSL startup timing when validating /etc/wsl.conf after WSL terminate/apply-config
- keep invalid wsl.conf content validation strict after the read succeeds
- preserve SSH tunnel behavior for operator and node connection paths
Maintainability simplifications:
- reuse setup-code gateway lookup state in GatewayConnectionManager
- centralize delayed reconnect scheduling with generation/disposal guards
- centralize response-aware pair approval RPC handling
- consolidate operator scope helper literals and checks
Validation:
- build.ps1 passed
- OpenClaw.Shared.Tests passed
- OpenClaw.Tray.Tests passed
- OpenClaw.Connection.Tests passed
- OpenClaw.SetupEngine.Tests passed
- full OpenClaw.E2ETests passed with OPENCLAW_RUN_E2E=1 and win-arm64 runtime
- targeted QR/setup-code E2E tests passed after audit follow-up
- Copilot autoreview passed with no accepted/actionable findings
- dual-model protocol audit completed; accepted multi-role handoff finding fixed
Co-authored-by: Copilot <[email protected]>
* Harden clean gateway pairing flows
Co-authored-by: Copilot <[email protected]>
* Checkpoint connection page test changes
Co-authored-by: Copilot <[email protected]>
* Clean up setup and connect E2E tests
Co-authored-by: Copilot <[email protected]>
* Move app capability handlers to partial class
Co-authored-by: Copilot <[email protected]>
* Remove invalid external QR E2E
The removed test used an admin fixture to approve node pairing, so it did not represent the QR-only external scenario it claimed to cover and could leave pending node approvals that broke later setup/connect tests.
Co-authored-by: Copilot <[email protected]>
---------
Co-authored-by: Copilot <[email protected]>
Co-authored-by: ranjeshj <ranjeshj@DESKTOP-D683G7P>1 parent 913ba4e commit ea36b12
40 files changed
Lines changed: 4450 additions & 378 deletions
File tree
- .github/workflows
- docs
- src
- OpenClaw.Connection
- OpenClaw.SetupEngine
- OpenClaw.Tray.WinUI
- Pages
- Services
- tests
- OpenClaw.Connection.Tests
- OpenClaw.E2ETests
- Setup
- OpenClaw.SetupEngine.Tests
- OpenClaw.Tray.Tests
- Connection
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
285 | | - | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
286 | 296 | | |
287 | 297 | | |
288 | 298 | | |
| |||
323 | 333 | | |
324 | 334 | | |
325 | 335 | | |
326 | | - | |
| 336 | + | |
327 | 337 | | |
328 | 338 | | |
329 | 339 | | |
| |||
334 | 344 | | |
335 | 345 | | |
336 | 346 | | |
337 | | - | |
338 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
339 | 350 | | |
340 | 351 | | |
341 | | - | |
| 352 | + | |
342 | 353 | | |
343 | 354 | | |
344 | | - | |
| 355 | + | |
345 | 356 | | |
346 | 357 | | |
347 | 358 | | |
348 | 359 | | |
349 | 360 | | |
350 | 361 | | |
351 | 362 | | |
352 | | - | |
| 363 | + | |
353 | 364 | | |
354 | 365 | | |
355 | 366 | | |
| |||
0 commit comments