From a909019078d28c0bf8b688eae49731a95f3a2e0f Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Thu, 26 Feb 2026 19:18:43 +0100 Subject: [PATCH] fix: align gateway run auth modes (#27469) (thanks @s1korrrr) --- CHANGELOG.md | 1 + .../gateway-cli/run.option-collisions.test.ts | 38 ++++++++++++++++++- src/cli/gateway-cli/run.ts | 9 ++++- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a677f771ff9..ac3f0f142c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,7 @@ Docs: https://docs.openclaw.ai - LINE/Inline directives auth: gate directive parsing (`/model`, `/think`, `/verbose`, `/reasoning`, `/queue`) on resolved authorization (`command.isAuthorizedSender`) so `commands.allowFrom`-authorized LINE senders are not silently stripped when raw `CommandAuthorized` is unset. Landed from contributor PR #27248 by @kevinWangSheng. (#27240) - Web tools/Proxy: route `web_search` provider HTTP calls (Brave, Perplexity, xAI, Gemini, Kimi), redirect resolution, and `web_fetch` through a shared proxy-aware SSRF guard path so gateway installs behind `HTTP_PROXY`/`HTTPS_PROXY`/`ALL_PROXY` no longer fail with transport `fetch failed` errors. (#27430) thanks @kevinWangSheng. - CLI/Gateway status: force local `gateway status` probe host to `127.0.0.1` for `bind=lan` so co-located probes do not trip non-loopback plaintext WebSocket checks. (#26997) thanks @chikko80. +- CLI/Gateway auth: align `gateway run --auth` parsing/help text with supported gateway auth modes by accepting `none` and `trusted-proxy` (in addition to `token`/`password`) for CLI overrides. (#27469) thanks @s1korrrr. - CLI/Daemon status TLS probe: use `wss://` and forward local TLS certificate fingerprint for TLS-enabled gateway daemon probes so `openclaw daemon status` works with `gateway.bind=lan` + `gateway.tls.enabled=true`. (#24234) thanks @liuy. - Gateway/Bind visibility: emit a startup warning when binding to non-loopback addresses so operators get explicit exposure guidance in runtime logs. (#25397) thanks @let5sne. - Podman/Default bind: change `run-openclaw-podman.sh` default gateway bind from `lan` to `loopback` and document explicit LAN opt-in with Control UI origin configuration. (#27491) thanks @robbyczgw-cla. diff --git a/src/cli/gateway-cli/run.option-collisions.test.ts b/src/cli/gateway-cli/run.option-collisions.test.ts index 343b740fce7..fd5afa1b785 100644 --- a/src/cli/gateway-cli/run.option-collisions.test.ts +++ b/src/cli/gateway-cli/run.option-collisions.test.ts @@ -18,7 +18,7 @@ const runGatewayLoop = vi.fn(async ({ start }: { start: () => Promise } await start(); }); -const { defaultRuntime, resetRuntimeCapture } = createCliRuntimeCapture(); +const { runtimeErrors, defaultRuntime, resetRuntimeCapture } = createCliRuntimeCapture(); vi.mock("../../config/config.js", () => ({ getConfigPath: () => "/tmp/openclaw-test-missing-config.json", @@ -152,4 +152,40 @@ describe("gateway run option collisions", () => { }), ); }); + + it("accepts --auth none override", async () => { + await runGatewayCli(["gateway", "run", "--auth", "none", "--allow-unconfigured"]); + + expect(startGatewayServer).toHaveBeenCalledWith( + 18789, + expect.objectContaining({ + auth: expect.objectContaining({ + mode: "none", + }), + }), + ); + }); + + it("accepts --auth trusted-proxy override", async () => { + await runGatewayCli(["gateway", "run", "--auth", "trusted-proxy", "--allow-unconfigured"]); + + expect(startGatewayServer).toHaveBeenCalledWith( + 18789, + expect.objectContaining({ + auth: expect.objectContaining({ + mode: "trusted-proxy", + }), + }), + ); + }); + + it("prints all supported modes on invalid --auth value", async () => { + await expect( + runGatewayCli(["gateway", "run", "--auth", "bad-mode", "--allow-unconfigured"]), + ).rejects.toThrow("__exit__:1"); + + expect(runtimeErrors).toContain( + 'Invalid --auth (use "none", "token", "password", or "trusted-proxy")', + ); + }); }); diff --git a/src/cli/gateway-cli/run.ts b/src/cli/gateway-cli/run.ts index a13b99ca200..07f80227a2a 100644 --- a/src/cli/gateway-cli/run.ts +++ b/src/cli/gateway-cli/run.ts @@ -186,9 +186,14 @@ async function runGatewayCommand(opts: GatewayRunOpts) { } const authModeRaw = toOptionString(opts.auth); const authMode: GatewayAuthMode | null = - authModeRaw === "token" || authModeRaw === "password" ? authModeRaw : null; + authModeRaw === "none" || + authModeRaw === "token" || + authModeRaw === "password" || + authModeRaw === "trusted-proxy" + ? authModeRaw + : null; if (authModeRaw && !authMode) { - defaultRuntime.error('Invalid --auth (use "token" or "password")'); + defaultRuntime.error('Invalid --auth (use "none", "token", "password", or "trusted-proxy")'); defaultRuntime.exit(1); return; }