@adtl/gateway 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -2
- package/dist/cedar.d.ts +27 -0
- package/dist/cedar.d.ts.map +1 -0
- package/dist/cedar.js +134 -0
- package/dist/cedar.js.map +1 -0
- package/dist/config.d.ts +45 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +25 -0
- package/dist/config.js.map +1 -1
- package/dist/gateway.d.ts +5 -5
- package/dist/gateway.d.ts.map +1 -1
- package/dist/gateway.js +14 -9
- package/dist/gateway.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/startup.d.ts +6 -1
- package/dist/startup.d.ts.map +1 -1
- package/dist/startup.js +24 -1
- package/dist/startup.js.map +1 -1
- package/package.json +15 -4
- package/src/cedar.ts +140 -0
- package/src/config.ts +26 -0
- package/src/gateway.ts +15 -11
- package/src/index.ts +1 -0
- package/src/startup.ts +22 -2
package/README.md
CHANGED
|
@@ -128,6 +128,7 @@ Rules match on `session.integrity`, `session.confidentiality`, `tool.egress` and
|
|
|
128
128
|
| `gateway.interceptors` | Custom interceptor server command (default: the bundled `@adtl/interceptors`) |
|
|
129
129
|
| `gateway.principal` | Who runs this gateway: `{ id, type?, claims? }`. `${VAR}` works in `id`. Default: anonymous. See [Authorization](#authorization). |
|
|
130
130
|
| `gateway.roles` | Who may use which tools, prompts and resources. Deny by default once present. See [Authorization](#authorization). |
|
|
131
|
+
| `gateway.cedar` | Cedar policies for attribute-based rules: `{ policies, entities?, timeZone? }`. See [Cedar policies](#cedar-policies). |
|
|
131
132
|
|
|
132
133
|
#### Checking the audit log
|
|
133
134
|
|
|
@@ -361,6 +362,57 @@ gateway:
|
|
|
361
362
|
- Over stdio the caller is whoever started the gateway, set with `gateway.principal`. Without it the caller is anonymous and only roles with `members: ["*"]` apply (the gateway warns at startup).
|
|
362
363
|
- `tools/list`, `prompts/list` and `resources/list` leave out what the caller may not use, so the agent doesn't try it. Hiding is a convenience, not the security boundary: a call to a hidden tool is still checked and denied. Lists are checked without arguments, and nothing is hidden in audit mode. Resource templates are always listed.
|
|
363
364
|
|
|
365
|
+
#### Cedar policies
|
|
366
|
+
|
|
367
|
+
For rules roles can't express (working hours, tool arguments, groups kept in another system), write [Cedar](https://www.cedarpolicy.com/) policies:
|
|
368
|
+
|
|
369
|
+
```sh
|
|
370
|
+
npm install @cedar-policy/cedar-wasm # optional dependency, only needed for gateway.cedar
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
```yaml
|
|
374
|
+
gateway:
|
|
375
|
+
principal: { id: "${USER}" }
|
|
376
|
+
cedar:
|
|
377
|
+
policies: ./adtl.cedar # relative to adtl.yaml
|
|
378
|
+
entities: ./entities.json # optional: groups and attributes, in Cedar's entities JSON
|
|
379
|
+
timeZone: Europe/Berlin # optional: for context.time (default: the gateway's)
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
```cedar
|
|
383
|
+
// Everyone may read issues.
|
|
384
|
+
permit (principal, action == Action::"tools/call", resource == Tool::"github.issue_read");
|
|
385
|
+
|
|
386
|
+
// Maintainers may use any GitHub tool, on weekdays during working hours.
|
|
387
|
+
permit (principal in Group::"maintainers", action, resource)
|
|
388
|
+
when { context.server == "github" && context.time.hour >= 9 && context.time.hour < 18
|
|
389
|
+
&& !["Sat", "Sun"].contains(context.time.weekday) };
|
|
390
|
+
|
|
391
|
+
// Anyone may comment in the orgs listed on their entity (entities.json: "attrs": { "orgs": ["acme"] }).
|
|
392
|
+
permit (principal, action == Action::"tools/call", resource == Tool::"github.add_issue_comment")
|
|
393
|
+
when { context.listing || (principal has orgs && principal.orgs.contains(context.arguments.owner)) };
|
|
394
|
+
|
|
395
|
+
// Nobody reads secrets files.
|
|
396
|
+
forbid (principal, action, resource == Tool::"github.get_file_contents")
|
|
397
|
+
when { context has arguments && context.arguments has path && context.arguments.path like "*secret*" };
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
Each call becomes a Cedar request:
|
|
401
|
+
|
|
402
|
+
| | |
|
|
403
|
+
|---|---|
|
|
404
|
+
| principal | `User::"<id>"`, `Service::"<id>"`, or `Anonymous::"anonymous"` without an id |
|
|
405
|
+
| action | `Action::"tools/call"`, `Action::"resources/read"` or `Action::"prompts/get"` |
|
|
406
|
+
| resource | `Tool::"<server>.<tool>"`, `Prompt::"<server>.<prompt>"` or `Resource::"<uri>"` |
|
|
407
|
+
| context | `server`, `principalId`, `listing`, `time: { hour, minute, weekday }`, and `arguments` |
|
|
408
|
+
|
|
409
|
+
- Cedar denies unless a policy permits, and a `forbid` beats any `permit`. The denial names the forbidding policy (`policy0`, `policy1`, … in file order).
|
|
410
|
+
- Lists are checked with `listing: true` and no `arguments`. Start a policy that reads arguments with `context.listing ||`, or the tool is hidden from lists (calls are still checked with arguments).
|
|
411
|
+
- Arguments are passed without nulls, with fractions as strings. Objects with `__entity` or `__extn` are passed as JSON strings, so a tool argument can't name an entity.
|
|
412
|
+
- With `roles` set too, both must allow. A policy file that doesn't parse stops the gateway at startup; an evaluation error denies the call.
|
|
413
|
+
|
|
414
|
+
#### Your own authorizer
|
|
415
|
+
|
|
364
416
|
Or your own `Authorizer` in code:
|
|
365
417
|
|
|
366
418
|
```ts
|
|
@@ -377,6 +429,8 @@ const readOnly: Authorizer = {
|
|
|
377
429
|
new AdtlGateway({ upstreams, invoker, authorizer: readOnly, principal: { type: "user", id: "alice" } });
|
|
378
430
|
```
|
|
379
431
|
|
|
432
|
+
Pass an array (`authorizer: [roles, readOnly]`) to ask several in turn: the first denial wins.
|
|
433
|
+
|
|
380
434
|
- It runs on every `tools/call`, `resources/read` and `prompts/get`, before the interceptors. A denial stops the call whatever the policy says; an allow still leaves the call to the policy.
|
|
381
435
|
- It gets `{ principal, event, server, tool | resource | prompt, arguments }`. The principal is also passed to the interceptors as SEP-2624 `context.principal`. Over stdio it is whoever started the gateway (anonymous unless set).
|
|
382
436
|
- Denials are audited with `denied: { by, reason }`. An authorizer that throws denies the call. In audit mode denials are logged and the call still runs.
|
|
@@ -388,8 +442,8 @@ The gateway fails closed. If an interceptor errors or times out, the call is sto
|
|
|
388
442
|
|
|
389
443
|
- Tools, resources and prompts are proxied. Resource subscriptions, `list_changed` notifications and completions are not passed through yet.
|
|
390
444
|
- Resources and prompts are labeled by server defaults (`servers.<id>.defaults`) or the global defaults; there are no per-resource or per-prompt rules yet. A resource URI that two upstreams could serve is refused rather than guessed.
|
|
391
|
-
- Approvals come from
|
|
392
|
-
- Session labels last for one agent session: one gateway process, or under Claude Code one Claude Code session (shared with the hooks). The [label ledger](#label-ledger) carries them into files, memory servers and sub-agents by content, but not across machines or other agents yet (v0.
|
|
445
|
+
- Approvals come from ntfy, email notices and, with `elicitation: true`, the MCP client. Authenticator-app codes (TOTP) are planned.
|
|
446
|
+
- Session labels last for one agent session: one gateway process, or under Claude Code one Claude Code session (shared with the hooks). The [label ledger](#label-ledger) carries them into files, memory servers and sub-agents by content, but not across machines or other agents yet (v0.8). Memory servers that extract facts or merge records on write return text the ledger cannot recognize; use [labels on records](#labels-on-records), or a strict rule for servers that don't keep metadata.
|
|
393
447
|
- The Claude Code hooks label tools by name, not by what they touched: a `Read` of a downloaded file is as trusted as a `Read` of your own code.
|
|
394
448
|
- Labels are set by your config. Servers' own trust claims can only make labels stricter, unless you set `acceptServerClaims: true`.
|
|
395
449
|
|
package/dist/cedar.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AuthorizationDecision, AuthorizationRequest, Authorizer } from "./authorizer.js";
|
|
2
|
+
import type { CedarConfig } from "./config.js";
|
|
3
|
+
type CedarValue = boolean | number | string | CedarValue[] | {
|
|
4
|
+
[key: string]: CedarValue;
|
|
5
|
+
};
|
|
6
|
+
export declare class CedarAuthorizer implements Authorizer {
|
|
7
|
+
private readonly cedar;
|
|
8
|
+
private readonly policies;
|
|
9
|
+
private readonly entities;
|
|
10
|
+
private readonly timeZone;
|
|
11
|
+
readonly name = "cedar";
|
|
12
|
+
private constructor();
|
|
13
|
+
/** Load the Cedar engine and the policy files. Throws on a missing package or files that don't parse. */
|
|
14
|
+
static load(cfg: CedarConfig, resolvePath: (p: string) => string): Promise<CedarAuthorizer>;
|
|
15
|
+
check(req: AuthorizationRequest): AuthorizationDecision;
|
|
16
|
+
}
|
|
17
|
+
/** Hour, minute and weekday ("Mon") in `timeZone`, for working-hours rules. */
|
|
18
|
+
export declare function clock(now: Date, timeZone: string | undefined): Record<string, CedarValue>;
|
|
19
|
+
/**
|
|
20
|
+
* Tool arguments as Cedar context values. Cedar has no null or fractions, so
|
|
21
|
+
* nulls are left out and fractions become strings. An object with `__entity`
|
|
22
|
+
* or `__extn` would be read as an entity or extension value, so the agent
|
|
23
|
+
* could name any entity; it is passed as a JSON string instead.
|
|
24
|
+
*/
|
|
25
|
+
export declare function toCedar(v: unknown): CedarValue | undefined;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=cedar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cedar.d.ts","sourceRoot":"","sources":["../src/cedar.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC/F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,KAAK,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,CAAC;AAY3F,qBAAa,eAAgB,YAAW,UAAU;IAI9C,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAN3B,QAAQ,CAAC,IAAI,WAAW;IAExB,OAAO;IAOP,yGAAyG;WAC5F,IAAI,CAAC,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAsBjG,KAAK,CAAC,GAAG,EAAE,oBAAoB,GAAG,qBAAqB;CAsCxD;AAED,+EAA+E;AAC/E,wBAAgB,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAIzF;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CAe1D"}
|
package/dist/cedar.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attribute-based authorization with Cedar (`gateway.cedar`):
|
|
3
|
+
*
|
|
4
|
+
* cedar:
|
|
5
|
+
* policies: ./adtl.cedar # Cedar policies, relative to adtl.yaml
|
|
6
|
+
* entities: ./entities.json # optional: Cedar entities (groups, attributes)
|
|
7
|
+
* timeZone: Europe/Berlin # optional: for context.time (default: the gateway's)
|
|
8
|
+
*
|
|
9
|
+
* Every call becomes a Cedar request:
|
|
10
|
+
*
|
|
11
|
+
* principal User::"alice", Service::"ci", or Anonymous::"anonymous" without an id
|
|
12
|
+
* action Action::"tools/call", Action::"resources/read" or Action::"prompts/get"
|
|
13
|
+
* resource Tool::"github.add_issue_comment", Prompt::"github.triage" or Resource::"<uri>"
|
|
14
|
+
* context { server, principalId, listing, time: { hour, minute, weekday }, arguments }
|
|
15
|
+
*
|
|
16
|
+
* Cedar denies unless a policy permits, and a `forbid` wins over any permit.
|
|
17
|
+
* Tool lists are filtered with `listing: true` and no `arguments`, so a policy
|
|
18
|
+
* on arguments should start with `context.listing ||`.
|
|
19
|
+
*
|
|
20
|
+
* Needs the optional dependency @cedar-policy/cedar-wasm, loaded only when
|
|
21
|
+
* `gateway.cedar` is set.
|
|
22
|
+
*/
|
|
23
|
+
import { readFileSync } from "node:fs";
|
|
24
|
+
export class CedarAuthorizer {
|
|
25
|
+
cedar;
|
|
26
|
+
policies;
|
|
27
|
+
entities;
|
|
28
|
+
timeZone;
|
|
29
|
+
name = "cedar";
|
|
30
|
+
constructor(cedar, policies, entities, timeZone) {
|
|
31
|
+
this.cedar = cedar;
|
|
32
|
+
this.policies = policies;
|
|
33
|
+
this.entities = entities;
|
|
34
|
+
this.timeZone = timeZone;
|
|
35
|
+
}
|
|
36
|
+
/** Load the Cedar engine and the policy files. Throws on a missing package or files that don't parse. */
|
|
37
|
+
static async load(cfg, resolvePath) {
|
|
38
|
+
let cedar;
|
|
39
|
+
try {
|
|
40
|
+
cedar = (await import("@cedar-policy/cedar-wasm/nodejs"));
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
throw new Error("gateway.cedar needs the Cedar engine: npm install @cedar-policy/cedar-wasm");
|
|
44
|
+
}
|
|
45
|
+
const policies = readFileSync(resolvePath(cfg.policies), "utf8");
|
|
46
|
+
const parsed = cedar.checkParsePolicySet({ staticPolicies: policies });
|
|
47
|
+
if (parsed.type === "failure")
|
|
48
|
+
throw new Error(`gateway.cedar.policies: ${parsed.errors.map((e) => e.message).join("; ")}`);
|
|
49
|
+
let entities = [];
|
|
50
|
+
if (cfg.entities) {
|
|
51
|
+
const json = JSON.parse(readFileSync(resolvePath(cfg.entities), "utf8"));
|
|
52
|
+
if (!Array.isArray(json))
|
|
53
|
+
throw new Error("gateway.cedar.entities: expected a JSON array of Cedar entities");
|
|
54
|
+
const ok = cedar.checkParseEntities({ entities: json });
|
|
55
|
+
if (ok.type === "failure")
|
|
56
|
+
throw new Error(`gateway.cedar.entities: ${ok.errors.map((e) => e.message).join("; ")}`);
|
|
57
|
+
entities = json;
|
|
58
|
+
}
|
|
59
|
+
return new CedarAuthorizer(cedar, policies, entities, cfg.timeZone);
|
|
60
|
+
}
|
|
61
|
+
check(req) {
|
|
62
|
+
const { principal } = req;
|
|
63
|
+
const [type, id] = req.event === "tools/call"
|
|
64
|
+
? ["Tool", `${req.server}.${req.tool}`]
|
|
65
|
+
: req.event === "prompts/get"
|
|
66
|
+
? ["Prompt", `${req.server}.${req.prompt}`]
|
|
67
|
+
: ["Resource", req.resource ?? ""];
|
|
68
|
+
const context = {
|
|
69
|
+
server: req.server,
|
|
70
|
+
listing: req.arguments === undefined,
|
|
71
|
+
time: clock(new Date(), this.timeZone),
|
|
72
|
+
...(principal.id !== undefined ? { principalId: principal.id } : {}),
|
|
73
|
+
...(req.arguments !== undefined ? { arguments: toCedar(req.arguments) ?? {} } : {}),
|
|
74
|
+
};
|
|
75
|
+
const answer = this.cedar.isAuthorized({
|
|
76
|
+
principal: principal.id === undefined
|
|
77
|
+
? { type: "Anonymous", id: "anonymous" }
|
|
78
|
+
: { type: principal.type === "service" ? "Service" : "User", id: principal.id },
|
|
79
|
+
action: { type: "Action", id: req.event },
|
|
80
|
+
resource: { type, id },
|
|
81
|
+
context,
|
|
82
|
+
policies: { staticPolicies: this.policies },
|
|
83
|
+
entities: this.entities,
|
|
84
|
+
});
|
|
85
|
+
if (answer.type === "failure")
|
|
86
|
+
throw new Error(answer.errors.map((e) => e.message).join("; "));
|
|
87
|
+
const { decision, diagnostics } = answer.response;
|
|
88
|
+
if (decision === "allow")
|
|
89
|
+
return { allow: true };
|
|
90
|
+
const who = principal.id ?? "an anonymous caller";
|
|
91
|
+
const what = `the ${type.toLowerCase()} ${id}`;
|
|
92
|
+
return {
|
|
93
|
+
allow: false,
|
|
94
|
+
reason: diagnostics.reason.length
|
|
95
|
+
? `Cedar policy ${diagnostics.reason.join(", ")} forbids ${who} to use ${what}`
|
|
96
|
+
: `No Cedar policy permits ${who} to use ${what}`,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/** Hour, minute and weekday ("Mon") in `timeZone`, for working-hours rules. */
|
|
101
|
+
export function clock(now, timeZone) {
|
|
102
|
+
const parts = new Intl.DateTimeFormat("en-US", { timeZone, hourCycle: "h23", hour: "numeric", minute: "numeric", weekday: "short" }).formatToParts(now);
|
|
103
|
+
const part = (t) => parts.find((p) => p.type === t)?.value ?? "";
|
|
104
|
+
return { hour: Number(part("hour")), minute: Number(part("minute")), weekday: part("weekday") };
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Tool arguments as Cedar context values. Cedar has no null or fractions, so
|
|
108
|
+
* nulls are left out and fractions become strings. An object with `__entity`
|
|
109
|
+
* or `__extn` would be read as an entity or extension value, so the agent
|
|
110
|
+
* could name any entity; it is passed as a JSON string instead.
|
|
111
|
+
*/
|
|
112
|
+
export function toCedar(v) {
|
|
113
|
+
if (v === null || v === undefined)
|
|
114
|
+
return undefined;
|
|
115
|
+
if (typeof v === "boolean" || typeof v === "string")
|
|
116
|
+
return v;
|
|
117
|
+
if (typeof v === "number")
|
|
118
|
+
return Number.isSafeInteger(v) ? v : String(v);
|
|
119
|
+
if (Array.isArray(v))
|
|
120
|
+
return v.map(toCedar).filter((x) => x !== undefined);
|
|
121
|
+
if (typeof v === "object") {
|
|
122
|
+
if ("__entity" in v || "__extn" in v)
|
|
123
|
+
return JSON.stringify(v);
|
|
124
|
+
const out = {};
|
|
125
|
+
for (const [k, x] of Object.entries(v)) {
|
|
126
|
+
const c = toCedar(x);
|
|
127
|
+
if (c !== undefined)
|
|
128
|
+
out[k] = c;
|
|
129
|
+
}
|
|
130
|
+
return out;
|
|
131
|
+
}
|
|
132
|
+
return String(v);
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=cedar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cedar.js","sourceRoot":"","sources":["../src/cedar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAgBvC,MAAM,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AS,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAC;IAC9D,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC1E,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAmB,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;IAC5F,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,IAAI,UAAU,IAAI,CAAC,IAAI,QAAQ,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC/D,MAAM,GAAG,GAA+B,EAAE,CAAC;QAC3C,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;YACvC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;YACrB,IAAI,CAAC,KAAK,SAAS;gBAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAClC,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* roles: # optional: who may use which tools (deny by default)
|
|
17
17
|
* maintainers: { members: [alice], tools: ["github.*"] }
|
|
18
18
|
* readers: { members: ["*"], tools: ["github.read_*", "github.get_*"] }
|
|
19
|
+
* cedar: { policies: ./adtl.cedar } # optional: attribute-based rules (see cedar.ts)
|
|
19
20
|
* approvals: # optional: make "ask" really ask
|
|
20
21
|
* timeoutSeconds: 50
|
|
21
22
|
* ntfy: { topic: "${ADTL_NTFY_TOPIC}" }
|
|
@@ -367,6 +368,23 @@ export declare const RoleSchema: z.ZodEffects<z.ZodObject<{
|
|
|
367
368
|
resources?: string[] | undefined;
|
|
368
369
|
}>;
|
|
369
370
|
export type RoleConfig = z.infer<typeof RoleSchema>;
|
|
371
|
+
export declare const CedarConfigSchema: z.ZodObject<{
|
|
372
|
+
/** Cedar policy file. Relative paths are resolved against the config file's directory. */
|
|
373
|
+
policies: z.ZodString;
|
|
374
|
+
/** Optional Cedar entities JSON file: groups (`parents`) and attributes. */
|
|
375
|
+
entities: z.ZodOptional<z.ZodString>;
|
|
376
|
+
/** IANA time zone for `context.time`, e.g. "Europe/Berlin". Default: the gateway's. */
|
|
377
|
+
timeZone: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
378
|
+
}, "strict", z.ZodTypeAny, {
|
|
379
|
+
policies: string;
|
|
380
|
+
entities?: string | undefined;
|
|
381
|
+
timeZone?: string | undefined;
|
|
382
|
+
}, {
|
|
383
|
+
policies: string;
|
|
384
|
+
entities?: string | undefined;
|
|
385
|
+
timeZone?: string | undefined;
|
|
386
|
+
}>;
|
|
387
|
+
export type CedarConfig = z.infer<typeof CedarConfigSchema>;
|
|
370
388
|
export declare const GatewayConfigSchema: z.ZodObject<{
|
|
371
389
|
upstreams: z.ZodEffects<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
|
372
390
|
command: z.ZodString;
|
|
@@ -678,6 +696,23 @@ export declare const GatewayConfigSchema: z.ZodObject<{
|
|
|
678
696
|
prompts?: string[] | undefined;
|
|
679
697
|
resources?: string[] | undefined;
|
|
680
698
|
}>>>;
|
|
699
|
+
/** Cedar authorization. With roles as well, both must allow. */
|
|
700
|
+
cedar: z.ZodOptional<z.ZodObject<{
|
|
701
|
+
/** Cedar policy file. Relative paths are resolved against the config file's directory. */
|
|
702
|
+
policies: z.ZodString;
|
|
703
|
+
/** Optional Cedar entities JSON file: groups (`parents`) and attributes. */
|
|
704
|
+
entities: z.ZodOptional<z.ZodString>;
|
|
705
|
+
/** IANA time zone for `context.time`, e.g. "Europe/Berlin". Default: the gateway's. */
|
|
706
|
+
timeZone: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
707
|
+
}, "strict", z.ZodTypeAny, {
|
|
708
|
+
policies: string;
|
|
709
|
+
entities?: string | undefined;
|
|
710
|
+
timeZone?: string | undefined;
|
|
711
|
+
}, {
|
|
712
|
+
policies: string;
|
|
713
|
+
entities?: string | undefined;
|
|
714
|
+
timeZone?: string | undefined;
|
|
715
|
+
}>>;
|
|
681
716
|
}, "strict", z.ZodTypeAny, {
|
|
682
717
|
mode: "active" | "audit";
|
|
683
718
|
upstreams: Record<string, {
|
|
@@ -738,6 +773,11 @@ export declare const GatewayConfigSchema: z.ZodObject<{
|
|
|
738
773
|
prompts: string[];
|
|
739
774
|
resources: string[];
|
|
740
775
|
}> | undefined;
|
|
776
|
+
cedar?: {
|
|
777
|
+
policies: string;
|
|
778
|
+
entities?: string | undefined;
|
|
779
|
+
timeZone?: string | undefined;
|
|
780
|
+
} | undefined;
|
|
741
781
|
}, {
|
|
742
782
|
upstreams: Record<string, {
|
|
743
783
|
command: string;
|
|
@@ -798,6 +838,11 @@ export declare const GatewayConfigSchema: z.ZodObject<{
|
|
|
798
838
|
prompts?: string[] | undefined;
|
|
799
839
|
resources?: string[] | undefined;
|
|
800
840
|
}> | undefined;
|
|
841
|
+
cedar?: {
|
|
842
|
+
policies: string;
|
|
843
|
+
entities?: string | undefined;
|
|
844
|
+
timeZone?: string | undefined;
|
|
845
|
+
} | undefined;
|
|
801
846
|
}>;
|
|
802
847
|
export type GatewayConfig = z.infer<typeof GatewayConfigSchema>;
|
|
803
848
|
export declare const TOOL_SEPARATOR = "__";
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgDhF,CAAC;AACZ,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC,qBAAa,iBAAkB,SAAQ,KAAK;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM;gBAAhB,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;CAIrD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAQtF;AAMD,wBAAgB,cAAc,CAAC,CAAC,SAAS,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,CAAC,CAY9F;AAED,gEAAgE;AAChE,wBAAgB,eAAe,CAAC,CAAC,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,eAAe,CAQ3F;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,QAAQ,GAAG,CAAC,IAAI,YAAY,CAE7D"}
|
package/dist/config.js
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* roles: # optional: who may use which tools (deny by default)
|
|
17
17
|
* maintainers: { members: [alice], tools: ["github.*"] }
|
|
18
18
|
* readers: { members: ["*"], tools: ["github.read_*", "github.get_*"] }
|
|
19
|
+
* cedar: { policies: ./adtl.cedar } # optional: attribute-based rules (see cedar.ts)
|
|
19
20
|
* approvals: # optional: make "ask" really ask
|
|
20
21
|
* timeoutSeconds: 50
|
|
21
22
|
* ntfy: { topic: "${ADTL_NTFY_TOPIC}" }
|
|
@@ -121,6 +122,28 @@ export const RoleSchema = z
|
|
|
121
122
|
.refine((r) => r.tools.length + r.prompts.length + r.resources.length > 0, {
|
|
122
123
|
message: "A role must grant at least one of tools, prompts or resources",
|
|
123
124
|
});
|
|
125
|
+
export const CedarConfigSchema = z
|
|
126
|
+
.object({
|
|
127
|
+
/** Cedar policy file. Relative paths are resolved against the config file's directory. */
|
|
128
|
+
policies: z.string().min(1),
|
|
129
|
+
/** Optional Cedar entities JSON file: groups (`parents`) and attributes. */
|
|
130
|
+
entities: z.string().min(1).optional(),
|
|
131
|
+
/** IANA time zone for `context.time`, e.g. "Europe/Berlin". Default: the gateway's. */
|
|
132
|
+
timeZone: z
|
|
133
|
+
.string()
|
|
134
|
+
.min(1)
|
|
135
|
+
.refine((tz) => {
|
|
136
|
+
try {
|
|
137
|
+
new Intl.DateTimeFormat("en-US", { timeZone: tz });
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
}, "Unknown time zone")
|
|
144
|
+
.optional(),
|
|
145
|
+
})
|
|
146
|
+
.strict();
|
|
124
147
|
export const GatewayConfigSchema = z
|
|
125
148
|
.object({
|
|
126
149
|
upstreams: z
|
|
@@ -149,6 +172,8 @@ export const GatewayConfigSchema = z
|
|
|
149
172
|
.record(RoleSchema)
|
|
150
173
|
.refine((r) => Object.keys(r).length > 0, "roles: needs at least one role (remove it to allow everyone)")
|
|
151
174
|
.optional(),
|
|
175
|
+
/** Cedar authorization. With roles as well, both must allow. */
|
|
176
|
+
cedar: CedarConfigSchema.optional(),
|
|
152
177
|
})
|
|
153
178
|
.strict();
|
|
154
179
|
export const TOOL_SEPARATOR = "__";
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src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GAAG,KAAK,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC/E,CAAC;AACJ,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,eAAe,CAAC,CAAkB,EAAE,GAAsB;IACxE,MAAM,IAAI,GAAG,CAAC,CAAU,EAAE,KAAa,EAAW,EAAE;QAClD,IAAI,OAAO,CAAC,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;QAC3D,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;YAAE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACxE,IAAI,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ;YAAE,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5H,OAAO,CAAC,CAAC;IACX,CAAC,CAAC;IACF,OAAO,IAAI,CAAC,CAAC,EAAE,mBAAmB,CAAoB,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,CAAW;IACxC,OAAO,KAAK,IAAI,CAAC,CAAC;AACpB,CAAC"}
|
package/dist/gateway.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { ApprovalBroker } from "./approvals.js";
|
|
|
5
5
|
import type { AuditSink } from "./audit.js";
|
|
6
6
|
import { type Authorizer, type Principal } from "./authorizer.js";
|
|
7
7
|
import type { InterceptorInvoker } from "./invoker.js";
|
|
8
|
-
export declare const GATEWAY_VERSION = "0.
|
|
8
|
+
export declare const GATEWAY_VERSION = "0.7.0";
|
|
9
9
|
/** `_meta` key on gateway-generated error results describing why a call was stopped. */
|
|
10
10
|
export declare const GATEWAY_DECISION_KEY = "adtl/gateway";
|
|
11
11
|
export interface GatewayLogger {
|
|
@@ -21,8 +21,8 @@ export interface AdtlGatewayOptions {
|
|
|
21
21
|
logger?: GatewayLogger;
|
|
22
22
|
/** Asks humans about "ask" decisions and sends notices. */
|
|
23
23
|
approvals?: ApprovalBroker;
|
|
24
|
-
/** Decides whether the caller may use a tool, resource or prompt at all, before the policy. */
|
|
25
|
-
authorizer?: Authorizer;
|
|
24
|
+
/** Decides whether the caller may use a tool, resource or prompt at all, before the policy. Several must all allow. */
|
|
25
|
+
authorizer?: Authorizer | Authorizer[];
|
|
26
26
|
/** The caller, passed to the authorizer and the interceptors. Default: anonymous. */
|
|
27
27
|
principal?: Principal;
|
|
28
28
|
/** Members of each role that policy rules name as `approvers:`. */
|
|
@@ -46,7 +46,7 @@ export declare class AdtlGateway {
|
|
|
46
46
|
private readonly audit;
|
|
47
47
|
private readonly log;
|
|
48
48
|
private readonly approvals;
|
|
49
|
-
private readonly
|
|
49
|
+
private readonly authorizers;
|
|
50
50
|
private readonly principal;
|
|
51
51
|
private readonly approverRoles;
|
|
52
52
|
private readonly elicitApprovals;
|
|
@@ -58,7 +58,7 @@ export declare class AdtlGateway {
|
|
|
58
58
|
private resourceRoutes;
|
|
59
59
|
private templateRoutes;
|
|
60
60
|
constructor(opts: AdtlGatewayOptions);
|
|
61
|
-
/** Ask
|
|
61
|
+
/** Ask each authorizer in turn. Returns the first denial; in audit mode the caller logs it and carries on. */
|
|
62
62
|
private authorize;
|
|
63
63
|
/** The downstream MCP server the agent connects to. */
|
|
64
64
|
createServer(): Server;
|
package/dist/gateway.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AAiCA,OA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BAAgB,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAQ7C;;;;OAIG;YACW,UAAU;IAWlB,SAAS,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAe5B,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAehC,aAAa,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAkBpC,qBAAqB,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAiB1D,wFAAwF;YAC1E,gBAAgB;IAkBxB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAQtD,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IAiBtF;;;;;OAKG;YACW,cAAc;IA6EtB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,cAAc,CAAC;IAoK5G,gFAAgF;YAClE,eAAe;CAY9B"}
|
package/dist/gateway.js
CHANGED
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
* unanswered or undeliverable calls are stopped. Without an approval channel,
|
|
22
22
|
* "ask" blocks.
|
|
23
23
|
*
|
|
24
|
-
*
|
|
25
|
-
* resource or prompt at all;
|
|
26
|
-
* The lists the agent sees leave out what
|
|
24
|
+
* Optional Authorizers decide first whether the caller may use the tool,
|
|
25
|
+
* resource or prompt at all; any denial stops the call before the policy runs.
|
|
26
|
+
* The lists the agent sees leave out what an authorizer would deny, so the
|
|
27
27
|
* agent doesn't try it; hiding is a convenience, and every call is still checked.
|
|
28
28
|
*
|
|
29
29
|
* In audit mode (the invoker runs every interceptor with `mode: "audit"`)
|
|
@@ -38,7 +38,7 @@ import { callBindingHash } from "@adtl/labels";
|
|
|
38
38
|
import { ElicitationChannel, supportsElicitation } from "./elicitation.js";
|
|
39
39
|
import { authorize } from "./authorizer.js";
|
|
40
40
|
import { TOOL_SEPARATOR } from "./config.js";
|
|
41
|
-
export const GATEWAY_VERSION = "0.
|
|
41
|
+
export const GATEWAY_VERSION = "0.7.0";
|
|
42
42
|
/** `_meta` key on gateway-generated error results describing why a call was stopped. */
|
|
43
43
|
export const GATEWAY_DECISION_KEY = "adtl/gateway";
|
|
44
44
|
const stderrLogger = {
|
|
@@ -87,7 +87,7 @@ export class AdtlGateway {
|
|
|
87
87
|
audit;
|
|
88
88
|
log;
|
|
89
89
|
approvals;
|
|
90
|
-
|
|
90
|
+
authorizers;
|
|
91
91
|
principal;
|
|
92
92
|
approverRoles;
|
|
93
93
|
elicitApprovals;
|
|
@@ -105,14 +105,19 @@ export class AdtlGateway {
|
|
|
105
105
|
this.audit = opts.audit;
|
|
106
106
|
this.log = opts.logger ?? stderrLogger;
|
|
107
107
|
this.approvals = opts.approvals;
|
|
108
|
-
this.
|
|
108
|
+
this.authorizers = opts.authorizer === undefined ? [] : [opts.authorizer].flat();
|
|
109
109
|
this.principal = opts.principal ?? { type: "anonymous" };
|
|
110
110
|
this.approverRoles = opts.approverRoles ?? new Map();
|
|
111
111
|
this.elicitApprovals = opts.elicitApprovals === true;
|
|
112
112
|
}
|
|
113
|
-
/** Ask
|
|
113
|
+
/** Ask each authorizer in turn. Returns the first denial; in audit mode the caller logs it and carries on. */
|
|
114
114
|
async authorize(request) {
|
|
115
|
-
|
|
115
|
+
for (const a of this.authorizers) {
|
|
116
|
+
const denied = await authorize(a, { principal: this.principal, ...request });
|
|
117
|
+
if (denied)
|
|
118
|
+
return denied;
|
|
119
|
+
}
|
|
120
|
+
return undefined;
|
|
116
121
|
}
|
|
117
122
|
/** The downstream MCP server the agent connects to. */
|
|
118
123
|
createServer() {
|
|
@@ -201,7 +206,7 @@ export class AdtlGateway {
|
|
|
201
206
|
* call: routes are kept, and a call to a hidden item is still authorized.
|
|
202
207
|
*/
|
|
203
208
|
async hideDenied(items, request) {
|
|
204
|
-
if (!this.
|
|
209
|
+
if (!this.authorizers.length || this.invoker.modeOverride === "audit")
|
|
205
210
|
return items;
|
|
206
211
|
const shown = await Promise.all(items.map(async (item) => {
|
|
207
212
|
const r = request(item);
|