mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 05:01:15 +00:00
feat(gateway): update runtime config guard for trusted-proxy
- Allow non-loopback bind with trusted-proxy auth mode - Reject trusted-proxy + loopback combination (nonsensical) - Require trustedProxies to be configured for trusted-proxy mode Part of #1560 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Peter Steinberger
parent
f3ec913489
commit
711fb49a98
@@ -85,6 +85,8 @@ export async function resolveGatewayRuntimeConfig(params: {
|
||||
const canvasHostEnabled =
|
||||
process.env.OPENCLAW_SKIP_CANVAS_HOST !== "1" && params.cfg.canvasHost?.enabled !== false;
|
||||
|
||||
const trustedProxies = params.cfg.gateway?.trustedProxies ?? [];
|
||||
|
||||
assertGatewayAuthConfigured(resolvedAuth);
|
||||
if (tailscaleMode === "funnel" && authMode !== "password") {
|
||||
throw new Error(
|
||||
@@ -100,6 +102,20 @@ export async function resolveGatewayRuntimeConfig(params: {
|
||||
);
|
||||
}
|
||||
|
||||
// Trusted-proxy mode validations
|
||||
if (authMode === "trusted-proxy") {
|
||||
if (isLoopbackHost(bindHost)) {
|
||||
throw new Error(
|
||||
"gateway auth mode=trusted-proxy makes no sense with bind=loopback; use bind=lan or bind=custom with gateway.trustedProxies configured",
|
||||
);
|
||||
}
|
||||
if (trustedProxies.length === 0) {
|
||||
throw new Error(
|
||||
"gateway auth mode=trusted-proxy requires gateway.trustedProxies to be configured with at least one proxy IP",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
bindHost,
|
||||
controlUiEnabled,
|
||||
|
||||
Reference in New Issue
Block a user