Skip to content

Commit c49af9e

Browse files
committed
Gateway: scope node pending drain to nodes
1 parent 54536e4 commit c49af9e

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/gateway/method-scopes.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ describe("method scope resolution", () => {
1818
expect(resolveLeastPrivilegeOperatorScopesForMethod("poll")).toEqual(["operator.write"]);
1919
});
2020

21+
it("leaves node-only pending drain outside operator scopes", () => {
22+
expect(resolveLeastPrivilegeOperatorScopesForMethod("node.pending.drain")).toEqual([]);
23+
});
24+
2125
it("returns empty scopes for unknown methods", () => {
2226
expect(resolveLeastPrivilegeOperatorScopesForMethod("totally.unknown.method")).toEqual([]);
2327
});

src/gateway/method-scopes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const CLI_DEFAULT_OPERATOR_SCOPES: OperatorScope[] = [
2222
const NODE_ROLE_METHODS = new Set([
2323
"node.invoke.result",
2424
"node.event",
25+
"node.pending.drain",
2526
"node.canvas.capability.refresh",
2627
"node.pending.pull",
2728
"node.pending.ack",
@@ -78,7 +79,6 @@ const METHOD_SCOPE_GROUPS: Record<OperatorScope, readonly string[]> = {
7879
"last-heartbeat",
7980
"node.list",
8081
"node.describe",
81-
"node.pending.drain",
8282
"chat.history",
8383
"config.get",
8484
"config.schema.lookup",

src/gateway/role-policy.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("gateway role policy", () => {
2424
expect(isRoleAuthorizedForMethod("node", "node.pending.drain")).toBe(true);
2525
expect(isRoleAuthorizedForMethod("node", "status")).toBe(false);
2626
expect(isRoleAuthorizedForMethod("operator", "status")).toBe(true);
27-
expect(isRoleAuthorizedForMethod("operator", "node.pending.drain")).toBe(true);
27+
expect(isRoleAuthorizedForMethod("operator", "node.pending.drain")).toBe(false);
2828
expect(isRoleAuthorizedForMethod("operator", "node.event")).toBe(false);
2929
});
3030
});

src/gateway/role-policy.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { isNodeRoleMethod } from "./method-scopes.js";
22

33
export const GATEWAY_ROLES = ["operator", "node"] as const;
4-
const SHARED_ROLE_METHODS = new Set(["node.pending.drain"]);
54

65
export type GatewayRole = (typeof GATEWAY_ROLES)[number];
76

@@ -17,9 +16,6 @@ export function roleCanSkipDeviceIdentity(role: GatewayRole, sharedAuthOk: boole
1716
}
1817

1918
export function isRoleAuthorizedForMethod(role: GatewayRole, method: string): boolean {
20-
if (SHARED_ROLE_METHODS.has(method)) {
21-
return true;
22-
}
2319
if (isNodeRoleMethod(method)) {
2420
return role === "node";
2521
}

0 commit comments

Comments
 (0)