Fix canvas WebView2 surface auth via plugin-node cap URL#588
Fix canvas WebView2 surface auth via plugin-node cap URL#588christineyan4 wants to merge 1 commit into
Conversation
The Windows tray's Canvas WebView2 was hitting 401 when navigating to /__openclaw__/canvas/* paths because it built URLs against the gateway origin only, omitting the plugin-node capability token the gateway requires for cross-node plugin surface routes. The gateway already advertises a cap-scoped surface URL in its hello-ok response (pluginSurfaceUrls.canvas), e.g. http://<gateway>/__openclaw__/cap/<token> This change plumbs that URL through to CanvasWindow and uses it as the base for /__openclaw__/canvas/* rewrites, and as an additional trusted origin prefix in IsUrlSafe so a cap URL whose host doesn't match _trustedGatewayOrigin (e.g. 127.0.0.1 cap vs localhost origin) is not rejected by the safety check. Also clears the cached cap URL when a subsequent hello-ok/health update omits the canvas key, so a rotated/revoked token doesn't leave the node using a stale URL. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Codex review: needs real behavior proof before merge. Reviewed May 29, 2026, 5:24 PM ET / 21:24 UTC. Summary Reproducibility: no. high-confidence live reproduction is included. Source inspection shows current master rewrites relative canvas paths to the bare gateway origin and does not read Review metrics: 2 noteworthy metrics.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Validate the advertised cap URL as an absolute http(s) cap route, propagate surface removals to existing canvas windows, add focused regression coverage for happy-path and removal cases, then attach redacted real behavior proof. Do we have a high-confidence way to reproduce the issue? No high-confidence live reproduction is included. Source inspection shows current master rewrites relative canvas paths to the bare gateway origin and does not read Is this the best way to solve the issue? No for the current branch. The cap-scoped routing approach is likely the right narrow fix, but it needs URL validation and complete stale-cap clearing before it is safe to merge. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 64b650cb3313. Label changesLabel changes:
Label justifications:
Evidence reviewedSecurity concerns:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
Problem
The Windows tray's Canvas WebView2 hits 401 Unauthorized when navigating to
/__openclaw__/canvas/*paths because it builds URLs against the gateway origin only, omitting the plugin-node capability token the gateway requires for cross-node plugin surface routes.Fix
The gateway already advertises a cap-scoped surface URL in its
hello-okresponse underpluginSurfaceUrls.canvas(e.g.http://<gateway>/__openclaw__/cap/<token>). This PR plumbs that URL through toCanvasWindowand uses it as the base for/__openclaw__/canvas/*rewrites.Additionally:
IsUrlSafeso a cap URL whose host doesn't match_trustedGatewayOrigin(e.g.127.0.0.1cap vslocalhostorigin) isn't rejected by the safety check.hello-ok/healthupdate omits the canvas key, so a rotated/revoked token doesn't leave the node using a stale URL.Files changed
src/OpenClaw.Shared/Models.cspluginSurfaceUrls.canvasfromhello-oksrc/OpenClaw.Shared/WindowsNodeClient.csCanvasSurfaceUrl; clear when canvas key absentsrc/OpenClaw.Tray.WinUI/Services/NodeService.csCanvasWindowon connect + on updatesrc/OpenClaw.Tray.WinUI/Windows/CanvasWindow.xaml.cs/__openclaw__/canvas/*via cap base; trust asIsUrlSafeprefixNet: +128 / -14 across 4 files. No new files, no API changes outside the tray.
Testing
net10.0-windows10.0.22621.0 / win-arm64(0 warnings, 0 errors)canvas.presentwith/__openclaw__/canvas/generative-art.htmlnow renders the real content instead of the dashboard SPA shell / 401 page.Known limitations (deferred)
canvas.presentand the dispatcher-enqueuedSetTrustedGatewayOrigin— theoretical, never observed.https://gw/__openclaw__/canvas/*) still go through the gateway origin path; gateway doesn't currently emit those.