Fix tailscale allowTailscale bypass in token mode

This commit is contained in:
Roshan Singh
2026-01-13 03:55:04 +00:00
committed by Peter Steinberger
parent d4c205f8e1
commit 7616b02bb1
2 changed files with 39 additions and 24 deletions

View File

@@ -92,4 +92,26 @@ describe("gateway auth", () => {
expect(missingProxy.ok).toBe(false);
expect(missingProxy.reason).toBe("tailscale_proxy_missing");
});
it("allows tailscale identity to satisfy token mode auth", async () => {
const res = await authorizeGatewayConnect({
auth: { mode: "token", token: "secret", allowTailscale: true },
connectAuth: null,
req: {
socket: { remoteAddress: "127.0.0.1" },
headers: {
host: "gateway.local",
"x-forwarded-for": "100.64.0.1",
"x-forwarded-proto": "https",
"x-forwarded-host": "ai-hub.bone-egret.ts.net",
"tailscale-user-login": "peter",
"tailscale-user-name": "Peter",
},
} as never,
});
expect(res.ok).toBe(true);
expect(res.method).toBe("tailscale");
expect(res.user).toBe("peter");
});
});