Skip to content

Commit ec2f0c6

Browse files
authored
fix(gateway): restore session attach grant revocation (#106487)
1 parent 8898118 commit ec2f0c6

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎src/gateway/mcp-grant-store.test.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
resolveAttachGrant,
88
resolveMcpLoopbackClientGrant,
99
revokeAttachGrant,
10+
revokeAttachGrantsForSession,
1011
revokeMcpLoopbackClientGrant,
1112
revokeMcpLoopbackClientGrantsForRuntime,
1213
} from "./mcp-grant-store.js";
@@ -58,6 +59,17 @@ describe("mcp-grant-store", () => {
5859
expect(revokeAttachGrant(g.token)).toBe(false);
5960
});
6061

62+
it("revokes every attach grant for one session", () => {
63+
const first = mintAttachGrant({ sessionKey: "agent:main:first", nowMs: T0 });
64+
const second = mintAttachGrant({ sessionKey: "agent:main:first", nowMs: T0 });
65+
const other = mintAttachGrant({ sessionKey: "agent:main:other", nowMs: T0 });
66+
67+
expect(revokeAttachGrantsForSession(" agent:main:first ")).toBe(2);
68+
expect(resolveAttachGrant(first.token, T0)).toBeUndefined();
69+
expect(resolveAttachGrant(second.token, T0)).toBeUndefined();
70+
expect(resolveAttachGrant(other.token, T0)?.sessionKey).toBe("agent:main:other");
71+
});
72+
6173
it("clamps TTL: default for non-positive, ceiling at 12h", () => {
6274
const def = mintAttachGrant({ sessionKey: "s", nowMs: T0 });
6375
expect(def.expiresAtMs).toBe(T0 + 60 * 60 * 1000);

0 commit comments

Comments
 (0)