Skip to content

Commit 42cf32c

Browse files
steipeteSidQin-cyber
andcommitted
fix(browser): land PR #26015 query-token auth for /json relay routes
Align relay HTTP /json auth with websocket auth by accepting query-param tokens, add regression coverage, and update changelog. Landed from contributor @Sid-Qin (PR #26015). Co-authored-by: SidQin-cyber <[email protected]>
1 parent 77a3930 commit 42cf32c

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Docs: https://docs.openclaw.ai
1414
### Fixes
1515

1616
- Browser/Extension relay CORS: handle `/json*` `OPTIONS` preflight before auth checks, allow Chrome extension origins, and return extension-origin CORS headers on relay HTTP responses so extension token validation no longer fails cross-origin. Landed from contributor PR #23962 by @miloudbelarebia. (#23842)
17+
- Browser/Extension relay auth: allow `?token=` query-param auth on relay `/json*` endpoints (consistent with relay WebSocket auth) so curl/devtools-style `/json/version` and `/json/list` probes work without requiring custom headers. Landed from contributor PR #26015 by @Sid-Qin. (#25928)
1718
- Auth/Auth profiles: normalize `auth-profiles.json` alias fields (`mode -> type`, `apiKey -> key`) before credential validation so entries copied from `openclaw.json` auth examples are no longer silently dropped. (#26950) thanks @byungsker.
1819
- Cron/Hooks isolated routing: preserve canonical `agent:*` session keys in isolated runs so already-qualified keys are not double-prefixed (for example `agent:main:main` no longer becomes `agent:main:agent:main:main`). Landed from contributor PR #27333 by @MaheshBhushan. (#27289, #27282)
1920
- iOS/Talk mode: stop injecting the voice directive hint into iOS Talk prompts and remove the Voice Directive Hint setting, reducing model bias toward tool-style TTS directives and keeping relay responses text-first by default. (#27543) thanks @ngutman.

src/browser/extension-relay.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,19 @@ describe("chrome extension relay server", () => {
332332
ext.close();
333333
});
334334

335+
it("accepts /json endpoints with relay token query param", async () => {
336+
const port = await getFreePort();
337+
cdpUrl = `http://127.0.0.1:${port}`;
338+
await ensureChromeExtensionRelayServer({ cdpUrl });
339+
340+
const token = relayAuthHeaders(cdpUrl)["x-openclaw-relay-token"];
341+
expect(token).toBeTruthy();
342+
const versionRes = await fetch(
343+
`${cdpUrl}/json/version?token=${encodeURIComponent(String(token))}`,
344+
);
345+
expect(versionRes.status).toBe(200);
346+
});
347+
335348
it("accepts raw gateway token for relay auth compatibility", async () => {
336349
const port = await getFreePort();
337350
cdpUrl = `http://127.0.0.1:${port}`;

src/browser/extension-relay.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ export async function ensureChromeExtensionRelayServer(opts: {
399399
}
400400

401401
if (path.startsWith("/json")) {
402-
const token = getHeader(req, RELAY_AUTH_HEADER)?.trim();
402+
const token = getRelayAuthTokenFromRequest(req, url);
403403
if (!token || !relayAuthTokens.has(token)) {
404404
res.writeHead(401);
405405
res.end("Unauthorized");

0 commit comments

Comments
 (0)