fix (security/gateway): preserve control-ui scopes in bypass mode

This commit is contained in:
Vignesh Natarajan
2026-02-15 19:12:06 -08:00
parent a203430aa3
commit eed02a2b57
2 changed files with 4 additions and 1 deletions

View File

@@ -687,6 +687,7 @@ describe("gateway server auth/connect", () => {
};
const res = await connectReq(ws, {
token: "secret",
scopes: ["operator.read"],
device,
client: {
id: GATEWAY_CLIENT_NAMES.CONTROL_UI,
@@ -697,6 +698,8 @@ describe("gateway server auth/connect", () => {
});
expect(res.ok).toBe(true);
expect((res.payload as { auth?: unknown } | undefined)?.auth).toBeUndefined();
const health = await rpcReq(ws, "health");
expect(health.ok).toBe(true);
ws.close();
});
} finally {

View File

@@ -427,7 +427,7 @@ export function attachGatewayWsMessageHandler(params: {
close(1008, truncateCloseReason(authMessage));
};
if (!device) {
if (scopes.length > 0) {
if (scopes.length > 0 && !allowControlUiBypass) {
scopes = [];
connectParams.scopes = scopes;
}