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:
parent
2acb4f47cc
commit
ca638c5b7e
@ -74,6 +74,8 @@ export async function resolveGatewayRuntimeConfig(params: {
|
|||||||
const canvasHostEnabled =
|
const canvasHostEnabled =
|
||||||
process.env.CLAWDBOT_SKIP_CANVAS_HOST !== "1" && params.cfg.canvasHost?.enabled !== false;
|
process.env.CLAWDBOT_SKIP_CANVAS_HOST !== "1" && params.cfg.canvasHost?.enabled !== false;
|
||||||
|
|
||||||
|
const trustedProxies = params.cfg.gateway?.trustedProxies ?? [];
|
||||||
|
|
||||||
assertGatewayAuthConfigured(resolvedAuth);
|
assertGatewayAuthConfigured(resolvedAuth);
|
||||||
if (tailscaleMode === "funnel" && authMode !== "password") {
|
if (tailscaleMode === "funnel" && authMode !== "password") {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@ -89,6 +91,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 {
|
return {
|
||||||
bindHost,
|
bindHost,
|
||||||
controlUiEnabled,
|
controlUiEnabled,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user