Skip to content

Commit a909019

Browse files
committed
fix: align gateway run auth modes (#27469) (thanks @s1korrrr)
1 parent 1087033 commit a909019

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Docs: https://docs.openclaw.ai
6868
- 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)
6969
- 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.
7070
- 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.
71+
- 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.
7172
- 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.
7273
- 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.
7374
- 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.

src/cli/gateway-cli/run.option-collisions.test.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const runGatewayLoop = vi.fn(async ({ start }: { start: () => Promise<unknown> }
1818
await start();
1919
});
2020

21-
const { defaultRuntime, resetRuntimeCapture } = createCliRuntimeCapture();
21+
const { runtimeErrors, defaultRuntime, resetRuntimeCapture } = createCliRuntimeCapture();
2222

2323
vi.mock("../../config/config.js", () => ({
2424
getConfigPath: () => "/tmp/openclaw-test-missing-config.json",
@@ -152,4 +152,40 @@ describe("gateway run option collisions", () => {
152152
}),
153153
);
154154
});
155+
156+
it("accepts --auth none override", async () => {
157+
await runGatewayCli(["gateway", "run", "--auth", "none", "--allow-unconfigured"]);
158+
159+
expect(startGatewayServer).toHaveBeenCalledWith(
160+
18789,
161+
expect.objectContaining({
162+
auth: expect.objectContaining({
163+
mode: "none",
164+
}),
165+
}),
166+
);
167+
});
168+
169+
it("accepts --auth trusted-proxy override", async () => {
170+
await runGatewayCli(["gateway", "run", "--auth", "trusted-proxy", "--allow-unconfigured"]);
171+
172+
expect(startGatewayServer).toHaveBeenCalledWith(
173+
18789,
174+
expect.objectContaining({
175+
auth: expect.objectContaining({
176+
mode: "trusted-proxy",
177+
}),
178+
}),
179+
);
180+
});
181+
182+
it("prints all supported modes on invalid --auth value", async () => {
183+
await expect(
184+
runGatewayCli(["gateway", "run", "--auth", "bad-mode", "--allow-unconfigured"]),
185+
).rejects.toThrow("__exit__:1");
186+
187+
expect(runtimeErrors).toContain(
188+
'Invalid --auth (use "none", "token", "password", or "trusted-proxy")',
189+
);
190+
});
155191
});

src/cli/gateway-cli/run.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,14 @@ async function runGatewayCommand(opts: GatewayRunOpts) {
186186
}
187187
const authModeRaw = toOptionString(opts.auth);
188188
const authMode: GatewayAuthMode | null =
189-
authModeRaw === "token" || authModeRaw === "password" ? authModeRaw : null;
189+
authModeRaw === "none" ||
190+
authModeRaw === "token" ||
191+
authModeRaw === "password" ||
192+
authModeRaw === "trusted-proxy"
193+
? authModeRaw
194+
: null;
190195
if (authModeRaw && !authMode) {
191-
defaultRuntime.error('Invalid --auth (use "token" or "password")');
196+
defaultRuntime.error('Invalid --auth (use "none", "token", "password", or "trusted-proxy")');
192197
defaultRuntime.exit(1);
193198
return;
194199
}

0 commit comments

Comments
 (0)