@astram/core 1.11.0 → 1.13.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/dist/authorization/delegation/operation-identity.d.ts.map +1 -1
- package/dist/authorization/delegation/operation-identity.js +19 -1
- package/dist/authorization/delegation/operation-identity.js.map +1 -1
- package/dist/authorization/index.d.ts +1 -0
- package/dist/authorization/index.d.ts.map +1 -1
- package/dist/authorization/index.js +2 -0
- package/dist/authorization/index.js.map +1 -1
- package/dist/authorization/record/permit-tier.d.ts +4 -0
- package/dist/authorization/record/permit-tier.d.ts.map +1 -1
- package/dist/authorization/record/permit-tier.js +13 -0
- package/dist/authorization/record/permit-tier.js.map +1 -1
- package/dist/authorization/record/separation-of-duties.d.ts +45 -0
- package/dist/authorization/record/separation-of-duties.d.ts.map +1 -0
- package/dist/authorization/record/separation-of-duties.js +72 -0
- package/dist/authorization/record/separation-of-duties.js.map +1 -0
- package/dist/database/framework-tables.d.ts.map +1 -1
- package/dist/database/framework-tables.js +1 -0
- package/dist/database/framework-tables.js.map +1 -1
- package/dist/metadata/index.d.ts +11 -0
- package/dist/metadata/index.d.ts.map +1 -1
- package/dist/metadata/index.js.map +1 -1
- package/dist-cjs/authorization/delegation/operation-identity.js +18 -0
- package/dist-cjs/authorization/index.js +2 -0
- package/dist-cjs/authorization/record/permit-tier.js +13 -0
- package/dist-cjs/authorization/record/separation-of-duties.js +76 -0
- package/dist-cjs/database/framework-tables.js +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-identity.d.ts","sourceRoot":"","sources":["../../../src/authorization/delegation/operation-identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAe,MAAM,0BAA0B,CAAC;AAG9F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"operation-identity.d.ts","sourceRoot":"","sources":["../../../src/authorization/delegation/operation-identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAe,MAAM,0BAA0B,CAAC;AAG9F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAStD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,2BAA2B,EAAG,mBAA4B,CAAC;AAExE;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+EAA+E;IAC/E,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,qEAAqE;IACrE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,WAAW,GAAG,gBAAgB,GAAG,SAAS,CAenF;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAMrF;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAMzF;AAyCD,oFAAoF;AACpF,MAAM,MAAM,8BAA8B,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAEnE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,GAAE,8BAAmC,GAC5C,mBAAmB,CAmErB"}
|
|
@@ -58,7 +58,8 @@
|
|
|
58
58
|
* context are injected via the pipeline's `GateContext`. Deterministic; no leak.
|
|
59
59
|
*/
|
|
60
60
|
import { gateAllow, gateContinue, gateDeny } from '../decision-authority.js';
|
|
61
|
-
import { denyMissingObjectTypeGrant, strictTrue } from '../reason-codes.js';
|
|
61
|
+
import { denyExplicitPolicy, denyMissingObjectTypeGrant, strictTrue } from '../reason-codes.js';
|
|
62
|
+
import { SEPARATION_OF_DUTIES_DENY_DETAIL, SEPARATION_OF_DUTIES_UNVERIFIED_DETAIL, evaluateSeparationOfDuties, isSeparationOfDutiesDeny, } from '../record/separation-of-duties.js';
|
|
62
63
|
/**
|
|
63
64
|
* The FROZEN `DecisionContext.attributes` bag key under which the enforcement
|
|
64
65
|
* adapter marks a decision as a DELEGATED internal step and names its operation +
|
|
@@ -134,11 +135,16 @@ export function isActionInScope(authority, actionKey) {
|
|
|
134
135
|
* Note: `explicit_deny_policy` (a deny-wins record-rule deny) IS a permission-tier
|
|
135
136
|
* deny and MAY be overridden by a valid in-scope delegated authority — the operation
|
|
136
137
|
* acts under its OWN identity, for which the caller-scoped rule deny is irrelevant.
|
|
138
|
+
* EXCEPT a separation-of-duties deny (G-025, ADR-0048): it binds the principal, delegated
|
|
139
|
+
* or not, so it is never overridable.
|
|
137
140
|
*/
|
|
138
141
|
function isOverridablePermissionDeny(baseline) {
|
|
139
142
|
if (baseline.effect !== 'deny') {
|
|
140
143
|
return false;
|
|
141
144
|
}
|
|
145
|
+
if (isSeparationOfDutiesDeny(baseline)) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
142
148
|
switch (baseline.reason) {
|
|
143
149
|
case 'tenant_mismatch':
|
|
144
150
|
case 'resource_not_registered':
|
|
@@ -206,6 +212,18 @@ export function createDelegationOverlay(_options = {}) {
|
|
|
206
212
|
!isActionInScope(authority, ctx.action.key)) {
|
|
207
213
|
return gateDeny(denyMissingObjectTypeGrant());
|
|
208
214
|
}
|
|
215
|
+
// (4b) SEPARATION OF DUTIES (G-025, ADR-0048). A delegated step is bound like any other
|
|
216
|
+
// principal. When gate 5 denied (no grant), gate 6 never ran, so the rule is checked here
|
|
217
|
+
// before the override; the same evaluator, so the outcome equals gate 6's.
|
|
218
|
+
if (ctx.resource.level === 'record') {
|
|
219
|
+
const sod = evaluateSeparationOfDuties(ctx);
|
|
220
|
+
if (sod === 'bound_principal') {
|
|
221
|
+
return gateDeny(denyExplicitPolicy(SEPARATION_OF_DUTIES_DENY_DETAIL));
|
|
222
|
+
}
|
|
223
|
+
if (sod === 'unverified') {
|
|
224
|
+
return gateDeny(denyExplicitPolicy(SEPARATION_OF_DUTIES_UNVERIFIED_DETAIL));
|
|
225
|
+
}
|
|
226
|
+
}
|
|
209
227
|
// (5) In-scope AND tenant OK. The step runs under the OPERATION's own declared,
|
|
210
228
|
// scoped, least-privilege authority — overriding the caller's permission-deny
|
|
211
229
|
// baseline. (The "on behalf of" audit — §10.5 — is the enforcement adapter's job,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-identity.js","sourceRoot":"","sources":["../../../src/authorization/delegation/operation-identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAGH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAG7E,OAAO,EAAE,0BAA0B,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"operation-identity.js","sourceRoot":"","sources":["../../../src/authorization/delegation/operation-identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAGH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAG7E,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChG,OAAO,EACL,gCAAgC,EAChC,sCAAsC,EACtC,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,mCAAmC,CAAC;AAE3C;;;;;;;;;;;;G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
|
162
162
|
export * from './record/owner-baseline.js';
|
|
163
163
|
export * from './record/permit-tier.js';
|
|
164
|
+
export * from './record/separation-of-duties.js';
|
|
164
165
|
export * from './record/list-scope.js';
|
|
165
166
|
export * from './gates/wiring.js';
|
|
166
167
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/authorization/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,aAAa,GAAG,QAAQ,CAAC;AAEjE;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,sBAAsB,GAAG,OAAO,CAAC;AAErE;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,UAAoB,CAAC;AAEvD;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,EAAE,OAAO,MAA4C,CAAC;AAE5F;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAA;CAAE,CAAC;AAEjF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAAG,GAAY,CAAC;AAErD;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,QAAsB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,aAAa,CAuBf;AAED;;;;GAIG;AACH,MAAM,WAAW,MAAM;IACrB,4EAA4E;IAC5E,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;I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AC;AAInC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,4BAA4B,CAAC;AAE3C,cAAc,oBAAoB,CAAC;AAEnC,cAAc,mCAAmC,CAAC;AAElD,cAAc,oCAAoC,CAAC;AAEnD,cAAc,4BAA4B,CAAC;AAE3C,cAAc,yBAAyB,CAAC;AAExC,cAAc,kCAAkC,CAAC;AAEjD,cAAc,wBAAwB,CAAC;AAEvC,cAAc,mBAAmB,CAAC"}
|
|
@@ -112,6 +112,8 @@ export * from './delegation/operation-identity.js';
|
|
|
112
112
|
export * from './record/owner-baseline.js';
|
|
113
113
|
// - INTEGRATION: the composed gate-6 record permit tier (baseline ∪ policy ∪ share, deny-wins):
|
|
114
114
|
export * from './record/permit-tier.js';
|
|
115
|
+
// - SEPARATION OF DUTIES: attribute name + pure evaluator (gate 6 step 0):
|
|
116
|
+
export * from './record/separation-of-duties.js';
|
|
115
117
|
// - LIST SCOPE: the decision-derived visible-set spec — sibling to decide() (Phase 1):
|
|
116
118
|
export * from './record/list-scope.js';
|
|
117
119
|
// - INTEGRATION: the production gate-set wiring + fully-wired DecisionAuthority factory:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/authorization/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAgBH;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAe,OAAO,CAAC;AAEvD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAkB,MAAM,CAAC,2BAA2B,CAAC,CAAC;AAc5F;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAY,CAAC;AAErD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,mBAAmB,CACjC,SAAiB,EACjB,OAAe,EACf,SAAiB;IAEj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AAI,CAC7F,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CACb,wBAAwB,IAAI,wBAAwB,cAAc,CAAC,MAAM,YAAY,GAAG,GAAG,CAC5F,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,GAAG,SAAS,GAAG,wBAAwB,GAAG,OAAO,GAAG,wBAAwB,GAAG,SAAS,EAAmB,CAAC;AACrH,CAAC;AAqFD,iFAAiF;AACjF,8EAA8E;AAC9E,iEAAiE;AACjE,6CAA6C;AAC7C,cAAc,aAAa,CAAC;AAC5B,uFAAuF;AACvF,cAAc,YAAY,CAAC;AAC3B,oFAAoF;AACpF,cAAc,mBAAmB,CAAC;AAClC,6EAA6E;AAC7E,gFAAgF;AAChF,cAAc,yBAAyB,CAAC;AACxC,kFAAkF;AAClF,cAAc,oBAAoB,CAAC;AACnC,sFAAsF;AACtF,qEAAqE;AACrE,sEAAsE;AACtE,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,4EAA4E;AAC5E,cAAc,4BAA4B,CAAC;AAC3C,6EAA6E;AAC7E,cAAc,oBAAoB,CAAC;AACnC,sFAAsF;AACtF,cAAc,mCAAmC,CAAC;AAClD,wEAAwE;AACxE,cAAc,oCAAoC,CAAC;AACnD,4FAA4F;AAC5F,cAAc,4BAA4B,CAAC;AAC3C,kGAAkG;AAClG,cAAc,yBAAyB,CAAC;AACxC,6EAA6E;AAC7E,cAAc,kCAAkC,CAAC;AACjD,yFAAyF;AACzF,cAAc,wBAAwB,CAAC;AACvC,2FAA2F;AAC3F,cAAc,mBAAmB,CAAC"}
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
* ── THE ONE COMPOSER (B's & C's DONE.md snippets were proven equivalent by a
|
|
14
14
|
* reviewer; this is that single agreed composer):
|
|
15
15
|
*
|
|
16
|
+
* 0. SEPARATION OF DUTIES (`evaluateSeparationOfDuties`), BEFORE the policy: a
|
|
17
|
+
* principal bound to the record for a declared action ⇒ `deny(explicit_deny_policy,
|
|
18
|
+
* 'separation_of_duties')`; unverifiable facts ⇒ `'separation_of_duties_unverified'`.
|
|
19
|
+
* Neither policy, baseline nor share is consulted.
|
|
16
20
|
* 1. Evaluate the POLICY (TEAM B `evaluateRecordPolicy`).
|
|
17
21
|
* 2. `policy.explicitDeny` ⇒ `deny(explicit_deny_policy)` — DENY-WINS, and it
|
|
18
22
|
* SHORT-CIRCUITS *before* the share is ever consulted. A share can NEVER beat
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permit-tier.d.ts","sourceRoot":"","sources":["../../../src/authorization/record/permit-tier.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"permit-tier.d.ts","sourceRoot":"","sources":["../../../src/authorization/record/permit-tier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,KAAK,EAA4B,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAWzF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AAEtF;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,2BAAgC,GAAG,cAAc,CA2ChG"}
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
* ── THE ONE COMPOSER (B's & C's DONE.md snippets were proven equivalent by a
|
|
14
14
|
* reviewer; this is that single agreed composer):
|
|
15
15
|
*
|
|
16
|
+
* 0. SEPARATION OF DUTIES (`evaluateSeparationOfDuties`), BEFORE the policy: a
|
|
17
|
+
* principal bound to the record for a declared action ⇒ `deny(explicit_deny_policy,
|
|
18
|
+
* 'separation_of_duties')`; unverifiable facts ⇒ `'separation_of_duties_unverified'`.
|
|
19
|
+
* Neither policy, baseline nor share is consulted.
|
|
16
20
|
* 1. Evaluate the POLICY (TEAM B `evaluateRecordPolicy`).
|
|
17
21
|
* 2. `policy.explicitDeny` ⇒ `deny(explicit_deny_policy)` — DENY-WINS, and it
|
|
18
22
|
* SHORT-CIRCUITS *before* the share is ever consulted. A share can NEVER beat
|
|
@@ -43,6 +47,7 @@
|
|
|
43
47
|
import { gateAllow, gateDeny } from '../decision-authority.js';
|
|
44
48
|
import { denyExplicitPolicy, denyNoRecordPermit } from '../reason-codes.js';
|
|
45
49
|
import { evaluateRecordPolicy } from './rule-evaluator.js';
|
|
50
|
+
import { SEPARATION_OF_DUTIES_DENY_DETAIL, SEPARATION_OF_DUTIES_UNVERIFIED_DETAIL, evaluateSeparationOfDuties, } from './separation-of-duties.js';
|
|
46
51
|
import { evaluateOwnerBaseline } from './owner-baseline.js';
|
|
47
52
|
import { evaluateRecordShare } from './shares.js';
|
|
48
53
|
/**
|
|
@@ -58,6 +63,14 @@ import { evaluateRecordShare } from './shares.js';
|
|
|
58
63
|
*/
|
|
59
64
|
export function createRecordPermitGate(options = {}) {
|
|
60
65
|
return async function recordPermit(ctx) {
|
|
66
|
+
// 0. SEPARATION OF DUTIES — before the policy; deny-only, fails closed when unverifiable.
|
|
67
|
+
const sod = evaluateSeparationOfDuties(ctx);
|
|
68
|
+
if (sod === 'bound_principal') {
|
|
69
|
+
return gateDeny(denyExplicitPolicy(SEPARATION_OF_DUTIES_DENY_DETAIL));
|
|
70
|
+
}
|
|
71
|
+
if (sod === 'unverified') {
|
|
72
|
+
return gateDeny(denyExplicitPolicy(SEPARATION_OF_DUTIES_UNVERIFIED_DETAIL));
|
|
73
|
+
}
|
|
61
74
|
// 1. POLICY (TEAM B). Deny-wins is resolved inside `evaluateRecordPolicy` under
|
|
62
75
|
// strict `=== true`; a transient throw PROPAGATES (not caught).
|
|
63
76
|
const policy = await evaluateRecordPolicy(ctx);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permit-tier.js","sourceRoot":"","sources":["../../../src/authorization/record/permit-tier.ts"],"names":[],"mappings":"AAAA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tF,mFAAmF;QACnF,mBAAmB;QACnB,MAAM,QAAQ,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC;QAC5C,IAAI,MAAM,CAAC,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC7B,OAAO,SAAS,EAAE,CAAC;QACrB,CAAC;QAED,qFAAqF;QACrF,oFAAoF;QACpF,iFAAiF;QACjF,8BAA8B;QAC9B,MAAM,KAAK,GAAG,MAAM,mBAAmB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACtD,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,SAAS,EAAE,CAAC;QACrB,CAAC;QAED,yEAAyE;QACzE,OAAO,QAAQ,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACxC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Separation of duties (SoD) evaluator for gate 6 — docs/features/separation-of-duties/SPEC.md
|
|
3
|
+
* (R4, R5, R7, D-4, D-7).
|
|
4
|
+
*
|
|
5
|
+
* A type declares `separationOfDuties: [{ actions: [...] }]`; the ENGINE supplies the facts
|
|
6
|
+
* (the record's `shield.separationOfDuties` attribute, `{ actorIds }`); gate 6 enforces,
|
|
7
|
+
* BEFORE the policy is consulted. A principal named in `actorIds` is denied a listed action;
|
|
8
|
+
* a declared action whose attribute is missing or malformed is unverifiable and fails closed.
|
|
9
|
+
*
|
|
10
|
+
* PURE + zero-dep (ADR-0003): reads only the resolved descriptor, the principal and
|
|
11
|
+
* `ctx.context.attributes`. Never throws on odd attribute shapes.
|
|
12
|
+
*/
|
|
13
|
+
import type { GateContext } from '../decision-authority.js';
|
|
14
|
+
/** Decision-attribute key under which the engine supplies the SoD facts. */
|
|
15
|
+
export declare const SEPARATION_OF_DUTIES_ATTRIBUTE: "shield.separationOfDuties";
|
|
16
|
+
/** Deny detail when the principal is named in the record's facts. */
|
|
17
|
+
export declare const SEPARATION_OF_DUTIES_DENY_DETAIL: "separation_of_duties";
|
|
18
|
+
/** Deny detail when a bound action arrives without valid facts (fail closed). */
|
|
19
|
+
export declare const SEPARATION_OF_DUTIES_UNVERIFIED_DETAIL: "separation_of_duties_unverified";
|
|
20
|
+
/**
|
|
21
|
+
* Whether a decision is a separation-of-duties deny. Gate 7 (delegation) must never override
|
|
22
|
+
* one: a delegated operation is bound by the rule like any other principal (ADR-0048).
|
|
23
|
+
*/
|
|
24
|
+
export declare function isSeparationOfDutiesDeny(decision: {
|
|
25
|
+
readonly effect: string;
|
|
26
|
+
readonly reason: string;
|
|
27
|
+
readonly detail?: string;
|
|
28
|
+
}): boolean;
|
|
29
|
+
/** Shape of the {@link SEPARATION_OF_DUTIES_ATTRIBUTE} value. */
|
|
30
|
+
export interface SeparationOfDutiesAttribute {
|
|
31
|
+
/** Ids of the principals who previously acted on the record (strict string equality). */
|
|
32
|
+
readonly actorIds: readonly string[];
|
|
33
|
+
}
|
|
34
|
+
/** Outcome of {@link evaluateSeparationOfDuties}. */
|
|
35
|
+
export type SeparationOfDutiesOutcome = 'unbound' | 'bound_principal' | 'unverified' | 'clear';
|
|
36
|
+
/**
|
|
37
|
+
* - `unbound`: the type does not declare SoD for this action (nothing to enforce).
|
|
38
|
+
* - `unverified`: declared, but the engine facts are absent or malformed (fail closed).
|
|
39
|
+
* - `bound_principal`: the principal appears in `actorIds` (deny).
|
|
40
|
+
* - `clear`: declared, verified, principal not named.
|
|
41
|
+
*
|
|
42
|
+
* A registry throw propagates, as in the other gate-6 evaluators.
|
|
43
|
+
*/
|
|
44
|
+
export declare function evaluateSeparationOfDuties(ctx: GateContext): SeparationOfDutiesOutcome;
|
|
45
|
+
//# sourceMappingURL=separation-of-duties.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"separation-of-duties.d.ts","sourceRoot":"","sources":["../../../src/authorization/record/separation-of-duties.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D,4EAA4E;AAC5E,eAAO,MAAM,8BAA8B,EAAG,2BAAoC,CAAC;AAEnF,qEAAqE;AACrE,eAAO,MAAM,gCAAgC,EAAG,sBAA+B,CAAC;AAEhF,iFAAiF;AACjF,eAAO,MAAM,sCAAsC,EAAG,iCAA0C,CAAC;AAEjG;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE;IACjD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B,GAAG,OAAO,CAOV;AAED,iEAAiE;AACjE,MAAM,WAAW,2BAA2B;IAC1C,yFAAyF;IACzF,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED,qDAAqD;AACrD,MAAM,MAAM,yBAAyB,GAAG,SAAS,GAAG,iBAAiB,GAAG,YAAY,GAAG,OAAO,CAAC;AAE/F;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,WAAW,GAAG,yBAAyB,CAgCtF"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Separation of duties (SoD) evaluator for gate 6 — docs/features/separation-of-duties/SPEC.md
|
|
3
|
+
* (R4, R5, R7, D-4, D-7).
|
|
4
|
+
*
|
|
5
|
+
* A type declares `separationOfDuties: [{ actions: [...] }]`; the ENGINE supplies the facts
|
|
6
|
+
* (the record's `shield.separationOfDuties` attribute, `{ actorIds }`); gate 6 enforces,
|
|
7
|
+
* BEFORE the policy is consulted. A principal named in `actorIds` is denied a listed action;
|
|
8
|
+
* a declared action whose attribute is missing or malformed is unverifiable and fails closed.
|
|
9
|
+
*
|
|
10
|
+
* PURE + zero-dep (ADR-0003): reads only the resolved descriptor, the principal and
|
|
11
|
+
* `ctx.context.attributes`. Never throws on odd attribute shapes.
|
|
12
|
+
*/
|
|
13
|
+
/** Decision-attribute key under which the engine supplies the SoD facts. */
|
|
14
|
+
export const SEPARATION_OF_DUTIES_ATTRIBUTE = 'shield.separationOfDuties';
|
|
15
|
+
/** Deny detail when the principal is named in the record's facts. */
|
|
16
|
+
export const SEPARATION_OF_DUTIES_DENY_DETAIL = 'separation_of_duties';
|
|
17
|
+
/** Deny detail when a bound action arrives without valid facts (fail closed). */
|
|
18
|
+
export const SEPARATION_OF_DUTIES_UNVERIFIED_DETAIL = 'separation_of_duties_unverified';
|
|
19
|
+
/**
|
|
20
|
+
* Whether a decision is a separation-of-duties deny. Gate 7 (delegation) must never override
|
|
21
|
+
* one: a delegated operation is bound by the rule like any other principal (ADR-0048).
|
|
22
|
+
*/
|
|
23
|
+
export function isSeparationOfDutiesDeny(decision) {
|
|
24
|
+
return (decision.effect === 'deny' &&
|
|
25
|
+
decision.reason === 'explicit_deny_policy' &&
|
|
26
|
+
(decision.detail === SEPARATION_OF_DUTIES_DENY_DETAIL ||
|
|
27
|
+
decision.detail === SEPARATION_OF_DUTIES_UNVERIFIED_DETAIL));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* - `unbound`: the type does not declare SoD for this action (nothing to enforce).
|
|
31
|
+
* - `unverified`: declared, but the engine facts are absent or malformed (fail closed).
|
|
32
|
+
* - `bound_principal`: the principal appears in `actorIds` (deny).
|
|
33
|
+
* - `clear`: declared, verified, principal not named.
|
|
34
|
+
*
|
|
35
|
+
* A registry throw propagates, as in the other gate-6 evaluators.
|
|
36
|
+
*/
|
|
37
|
+
export function evaluateSeparationOfDuties(ctx) {
|
|
38
|
+
const descriptor = ctx.deps.registry.resolveObjectType(ctx.resource.typeKey);
|
|
39
|
+
const declarations = descriptor?.separationOfDuties;
|
|
40
|
+
if (!Array.isArray(declarations))
|
|
41
|
+
return 'unbound';
|
|
42
|
+
const declared = declarations.some((d) => d !== null &&
|
|
43
|
+
typeof d === 'object' &&
|
|
44
|
+
Array.isArray(d.actions) &&
|
|
45
|
+
d.actions.includes(ctx.action.key));
|
|
46
|
+
if (!declared)
|
|
47
|
+
return 'unbound';
|
|
48
|
+
const attributes = ctx.context.attributes;
|
|
49
|
+
if (attributes === undefined || attributes === null)
|
|
50
|
+
return 'unverified';
|
|
51
|
+
if (!Object.prototype.hasOwnProperty.call(attributes, SEPARATION_OF_DUTIES_ATTRIBUTE)) {
|
|
52
|
+
return 'unverified';
|
|
53
|
+
}
|
|
54
|
+
const value = attributes[SEPARATION_OF_DUTIES_ATTRIBUTE];
|
|
55
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
56
|
+
return 'unverified';
|
|
57
|
+
if (!Object.prototype.hasOwnProperty.call(value, 'actorIds'))
|
|
58
|
+
return 'unverified';
|
|
59
|
+
const actorIds = value.actorIds;
|
|
60
|
+
if (!Array.isArray(actorIds))
|
|
61
|
+
return 'unverified';
|
|
62
|
+
for (const id of actorIds) {
|
|
63
|
+
if (typeof id !== 'string')
|
|
64
|
+
return 'unverified';
|
|
65
|
+
}
|
|
66
|
+
const principalId = ctx.principal.id;
|
|
67
|
+
if (typeof principalId === 'string' && principalId.length > 0 && actorIds.includes(principalId)) {
|
|
68
|
+
return 'bound_principal';
|
|
69
|
+
}
|
|
70
|
+
return 'clear';
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=separation-of-duties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"separation-of-duties.js","sourceRoot":"","sources":["../../../src/authorization/record/separation-of-duties.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,4EAA4E;AAC5E,MAAM,CAAC,MAAM,8BAA8B,GAAG,2BAAoC,CAAC;AAEnF,qEAAqE;AACrE,MAAM,CAAC,MAAM,gCAAgC,GAAG,sBAA+B,CAAC;AAEhF,iFAAiF;AACjF,MAAM,CAAC,MAAM,sCAAsC,GAAG,iCAA0C,CAAC;AAEjG;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CA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AK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,YAAY,CAAC;IAC7F,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC;QAAE,OAAO,YAAY,CAAC;IAClF,MAAM,QAAQ,GAAa,KAAgC,CAAC,QAAQ,CAAC;IACrE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;QAAE,OAAO,YAAY,CAAC;IAClD,KAAK,MAAM,EAAE,IAAI,QAAQ,EAAE,CAAC;QAC1B,IAAI,OAAO,EAAE,KAAK,QAAQ;YAAE,OAAO,YAAY,CAAC;IAClD,CAAC;IAED,MAAM,WAAW,GAAG,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;IACrC,IAAI,OAAO,WAAW,KAAK,QAAQ,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QAChG,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framework-tables.d.ts","sourceRoot":"","sources":["../../src/database/framework-tables.ts"],"names":[],"mappings":"AASA,yGAAyG;AACzG,eAAO,MAAM,gBAAgB;;;;;
|
|
1
|
+
{"version":3,"file":"framework-tables.d.ts","sourceRoot":"","sources":["../../src/database/framework-tables.ts"],"names":[],"mappings":"AASA,yGAAyG;AACzG,eAAO,MAAM,gBAAgB;;;;;EAwC3B,CAAC;AAEH,iCAAiC;AACjC,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAAmC,CAAC;AAIpF;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,WAAW,GAAE,MAAuC,GACnD,OAAO,CAGT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framework-tables.js","sourceRoot":"","sources":["../../src/database/framework-tables.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAExE,yGAAyG;AACzG,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5C,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC;QACjB,WAAW;QACX,OAAO;QACP,OAAO;QACP,aAAa;QACb,UAAU;QACV,oBAAoB;QACpB,oBAAoB;QACpB,qBAAqB;QACrB,kBAAkB;QAClB,iBAAiB;QACjB,iBAAiB;QACjB,aAAa;QACb,iBAAiB;KAClB,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC;QACtB,qBAAqB;QACrB,SAAS;QACT,eAAe;QACf,YAAY;QACZ,sBAAsB;QACtB,mBAAmB;QACnB,oBAAoB;QACpB,uBAAuB;
|
|
1
|
+
{"version":3,"file":"framework-tables.js","sourceRoot":"","sources":["../../src/database/framework-tables.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAExE,yGAAyG;AACzG,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5C,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC;QACjB,WAAW;QACX,OAAO;QACP,OAAO;QACP,aAAa;QACb,UAAU;QACV,oBAAoB;QACpB,oBAAoB;QACpB,qBAAqB;QACrB,kBAAkB;QAClB,iBAAiB;QACjB,iBAAiB;QACjB,aAAa;QACb,iBAAiB;KAClB,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC;QACtB,qBAAqB;QACrB,SAAS;QACT,eAAe;QACf,YAAY;QACZ,sBAAsB;QACtB,mBAAmB;QACnB,oBAAoB;QACpB,uBAAuB;QACvB,mBAAmB;KACpB,CAAC;IACF,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC;QACnB,YAAY;QACZ,iBAAiB;QACjB,0BAA0B;QAC1B,eAAe;QACf,0BAA0B;QAC1B,wBAAwB;QACxB,cAAc;QACd,eAAe;QACf,qBAAqB;QACrB,oBAAoB;KACrB,CAAC;IACF,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,aAAa,EAAE,wBAAwB,CAAC,CAAC;CAC7E,CAAC,CAAC;AAEH,iCAAiC;AACjC,MAAM,CAAC,MAAM,kBAAkB,GAAsB,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;AAEpF,MAAM,QAAQ,GAAwB,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AAEtF;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CACtC,IAAY,EACZ,cAAsB,8BAA8B;IAEpD,MAAM,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAC7B,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,WAAW,CAAC,WAAW,EAAE,CAAC;AAC5D,CAAC"}
|
package/dist/metadata/index.d.ts
CHANGED
|
@@ -66,6 +66,17 @@ export interface ObjectTypeDescriptor {
|
|
|
66
66
|
* type (fail-closed — a rule/share must permit; the baseline never owner/system-allows).
|
|
67
67
|
*/
|
|
68
68
|
readonly access?: RecordAccessPosture;
|
|
69
|
+
/**
|
|
70
|
+
* OPTIONAL separation-of-duties declarations (docs/features/separation-of-duties).
|
|
71
|
+
* Declared on the type in code; the engine supplies the facts (the record's
|
|
72
|
+
* `shield.separationOfDuties` attribute) and gate 6 enforces: a principal named there is
|
|
73
|
+
* denied the listed actions. Never `read`/`create` (validated by the engine). Absent ⇒ none.
|
|
74
|
+
*/
|
|
75
|
+
readonly separationOfDuties?: readonly SeparationOfDutiesDeclaration[];
|
|
76
|
+
}
|
|
77
|
+
/** One separation-of-duties declaration: actions barred to principals already bound to the record. */
|
|
78
|
+
export interface SeparationOfDutiesDeclaration {
|
|
79
|
+
readonly actions: readonly string[];
|
|
69
80
|
}
|
|
70
81
|
/**
|
|
71
82
|
* A supporting read-only dependency (§5.3): a subordinate lookup auto-permitted
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/metadata/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,aAAa,EACnB,MAAM,2BAA2B,CAAC;AAGnC,cAAc,mBAAmB,CAAC;AAKlC,cAAc,eAAe,CAAC;AAK9B,cAAc,mBAAmB,CAAC;AAElC,8EAA8E;AAC9E,MAAM,WAAW,eAAe;IAC9B,iEAAiE;IACjE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACrC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,mBAAmB;IAClC,uFAAuF;IACvF,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB;wEACoE;IACpE,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAChC;iEAC6D;IAC7D,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,yEAAyE;AACzE,MAAM,WAAW,oBAAoB;IACnC,gEAAgE;IAChE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;IAC5C;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src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K,OAAO,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YACrE,IAAI,KAAK,KAAK,SAAS;gBAAE,OAAO,SAAS,CAAC,CAAC,0BAA0B;YACrE,KAAK,GAAG,CAAC,CAAC;QACZ,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -66,6 +66,7 @@ exports.isActionInScope = isActionInScope;
|
|
|
66
66
|
exports.createDelegationOverlay = createDelegationOverlay;
|
|
67
67
|
const decision_authority_js_1 = require("../decision-authority.js");
|
|
68
68
|
const reason_codes_js_1 = require("../reason-codes.js");
|
|
69
|
+
const separation_of_duties_js_1 = require("../record/separation-of-duties.js");
|
|
69
70
|
/**
|
|
70
71
|
* The FROZEN `DecisionContext.attributes` bag key under which the enforcement
|
|
71
72
|
* adapter marks a decision as a DELEGATED internal step and names its operation +
|
|
@@ -141,11 +142,16 @@ function isActionInScope(authority, actionKey) {
|
|
|
141
142
|
* Note: `explicit_deny_policy` (a deny-wins record-rule deny) IS a permission-tier
|
|
142
143
|
* deny and MAY be overridden by a valid in-scope delegated authority — the operation
|
|
143
144
|
* acts under its OWN identity, for which the caller-scoped rule deny is irrelevant.
|
|
145
|
+
* EXCEPT a separation-of-duties deny (G-025, ADR-0048): it binds the principal, delegated
|
|
146
|
+
* or not, so it is never overridable.
|
|
144
147
|
*/
|
|
145
148
|
function isOverridablePermissionDeny(baseline) {
|
|
146
149
|
if (baseline.effect !== 'deny') {
|
|
147
150
|
return false;
|
|
148
151
|
}
|
|
152
|
+
if ((0, separation_of_duties_js_1.isSeparationOfDutiesDeny)(baseline)) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
149
155
|
switch (baseline.reason) {
|
|
150
156
|
case 'tenant_mismatch':
|
|
151
157
|
case 'resource_not_registered':
|
|
@@ -213,6 +219,18 @@ function createDelegationOverlay(_options = {}) {
|
|
|
213
219
|
!isActionInScope(authority, ctx.action.key)) {
|
|
214
220
|
return (0, decision_authority_js_1.gateDeny)((0, reason_codes_js_1.denyMissingObjectTypeGrant)());
|
|
215
221
|
}
|
|
222
|
+
// (4b) SEPARATION OF DUTIES (G-025, ADR-0048). A delegated step is bound like any other
|
|
223
|
+
// principal. When gate 5 denied (no grant), gate 6 never ran, so the rule is checked here
|
|
224
|
+
// before the override; the same evaluator, so the outcome equals gate 6's.
|
|
225
|
+
if (ctx.resource.level === 'record') {
|
|
226
|
+
const sod = (0, separation_of_duties_js_1.evaluateSeparationOfDuties)(ctx);
|
|
227
|
+
if (sod === 'bound_principal') {
|
|
228
|
+
return (0, decision_authority_js_1.gateDeny)((0, reason_codes_js_1.denyExplicitPolicy)(separation_of_duties_js_1.SEPARATION_OF_DUTIES_DENY_DETAIL));
|
|
229
|
+
}
|
|
230
|
+
if (sod === 'unverified') {
|
|
231
|
+
return (0, decision_authority_js_1.gateDeny)((0, reason_codes_js_1.denyExplicitPolicy)(separation_of_duties_js_1.SEPARATION_OF_DUTIES_UNVERIFIED_DETAIL));
|
|
232
|
+
}
|
|
233
|
+
}
|
|
216
234
|
// (5) In-scope AND tenant OK. The step runs under the OPERATION's own declared,
|
|
217
235
|
// scoped, least-privilege authority — overriding the caller's permission-deny
|
|
218
236
|
// baseline. (The "on behalf of" audit — §10.5 — is the enforcement adapter's job,
|
|
@@ -130,6 +130,8 @@ __exportStar(require("./delegation/operation-identity.js"), exports);
|
|
|
130
130
|
__exportStar(require("./record/owner-baseline.js"), exports);
|
|
131
131
|
// - INTEGRATION: the composed gate-6 record permit tier (baseline ∪ policy ∪ share, deny-wins):
|
|
132
132
|
__exportStar(require("./record/permit-tier.js"), exports);
|
|
133
|
+
// - SEPARATION OF DUTIES: attribute name + pure evaluator (gate 6 step 0):
|
|
134
|
+
__exportStar(require("./record/separation-of-duties.js"), exports);
|
|
133
135
|
// - LIST SCOPE: the decision-derived visible-set spec — sibling to decide() (Phase 1):
|
|
134
136
|
__exportStar(require("./record/list-scope.js"), exports);
|
|
135
137
|
// - INTEGRATION: the production gate-set wiring + fully-wired DecisionAuthority factory:
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
* ── THE ONE COMPOSER (B's & C's DONE.md snippets were proven equivalent by a
|
|
15
15
|
* reviewer; this is that single agreed composer):
|
|
16
16
|
*
|
|
17
|
+
* 0. SEPARATION OF DUTIES (`evaluateSeparationOfDuties`), BEFORE the policy: a
|
|
18
|
+
* principal bound to the record for a declared action ⇒ `deny(explicit_deny_policy,
|
|
19
|
+
* 'separation_of_duties')`; unverifiable facts ⇒ `'separation_of_duties_unverified'`.
|
|
20
|
+
* Neither policy, baseline nor share is consulted.
|
|
17
21
|
* 1. Evaluate the POLICY (TEAM B `evaluateRecordPolicy`).
|
|
18
22
|
* 2. `policy.explicitDeny` ⇒ `deny(explicit_deny_policy)` — DENY-WINS, and it
|
|
19
23
|
* SHORT-CIRCUITS *before* the share is ever consulted. A share can NEVER beat
|
|
@@ -46,6 +50,7 @@ exports.createRecordPermitGate = createRecordPermitGate;
|
|
|
46
50
|
const decision_authority_js_1 = require("../decision-authority.js");
|
|
47
51
|
const reason_codes_js_1 = require("../reason-codes.js");
|
|
48
52
|
const rule_evaluator_js_1 = require("./rule-evaluator.js");
|
|
53
|
+
const separation_of_duties_js_1 = require("./separation-of-duties.js");
|
|
49
54
|
const owner_baseline_js_1 = require("./owner-baseline.js");
|
|
50
55
|
const shares_js_1 = require("./shares.js");
|
|
51
56
|
/**
|
|
@@ -61,6 +66,14 @@ const shares_js_1 = require("./shares.js");
|
|
|
61
66
|
*/
|
|
62
67
|
function createRecordPermitGate(options = {}) {
|
|
63
68
|
return async function recordPermit(ctx) {
|
|
69
|
+
// 0. SEPARATION OF DUTIES — before the policy; deny-only, fails closed when unverifiable.
|
|
70
|
+
const sod = (0, separation_of_duties_js_1.evaluateSeparationOfDuties)(ctx);
|
|
71
|
+
if (sod === 'bound_principal') {
|
|
72
|
+
return (0, decision_authority_js_1.gateDeny)((0, reason_codes_js_1.denyExplicitPolicy)(separation_of_duties_js_1.SEPARATION_OF_DUTIES_DENY_DETAIL));
|
|
73
|
+
}
|
|
74
|
+
if (sod === 'unverified') {
|
|
75
|
+
return (0, decision_authority_js_1.gateDeny)((0, reason_codes_js_1.denyExplicitPolicy)(separation_of_duties_js_1.SEPARATION_OF_DUTIES_UNVERIFIED_DETAIL));
|
|
76
|
+
}
|
|
64
77
|
// 1. POLICY (TEAM B). Deny-wins is resolved inside `evaluateRecordPolicy` under
|
|
65
78
|
// strict `=== true`; a transient throw PROPAGATES (not caught).
|
|
66
79
|
const policy = await (0, rule_evaluator_js_1.evaluateRecordPolicy)(ctx);
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Separation of duties (SoD) evaluator for gate 6 — docs/features/separation-of-duties/SPEC.md
|
|
4
|
+
* (R4, R5, R7, D-4, D-7).
|
|
5
|
+
*
|
|
6
|
+
* A type declares `separationOfDuties: [{ actions: [...] }]`; the ENGINE supplies the facts
|
|
7
|
+
* (the record's `shield.separationOfDuties` attribute, `{ actorIds }`); gate 6 enforces,
|
|
8
|
+
* BEFORE the policy is consulted. A principal named in `actorIds` is denied a listed action;
|
|
9
|
+
* a declared action whose attribute is missing or malformed is unverifiable and fails closed.
|
|
10
|
+
*
|
|
11
|
+
* PURE + zero-dep (ADR-0003): reads only the resolved descriptor, the principal and
|
|
12
|
+
* `ctx.context.attributes`. Never throws on odd attribute shapes.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SEPARATION_OF_DUTIES_UNVERIFIED_DETAIL = exports.SEPARATION_OF_DUTIES_DENY_DETAIL = exports.SEPARATION_OF_DUTIES_ATTRIBUTE = void 0;
|
|
16
|
+
exports.isSeparationOfDutiesDeny = isSeparationOfDutiesDeny;
|
|
17
|
+
exports.evaluateSeparationOfDuties = evaluateSeparationOfDuties;
|
|
18
|
+
/** Decision-attribute key under which the engine supplies the SoD facts. */
|
|
19
|
+
exports.SEPARATION_OF_DUTIES_ATTRIBUTE = 'shield.separationOfDuties';
|
|
20
|
+
/** Deny detail when the principal is named in the record's facts. */
|
|
21
|
+
exports.SEPARATION_OF_DUTIES_DENY_DETAIL = 'separation_of_duties';
|
|
22
|
+
/** Deny detail when a bound action arrives without valid facts (fail closed). */
|
|
23
|
+
exports.SEPARATION_OF_DUTIES_UNVERIFIED_DETAIL = 'separation_of_duties_unverified';
|
|
24
|
+
/**
|
|
25
|
+
* Whether a decision is a separation-of-duties deny. Gate 7 (delegation) must never override
|
|
26
|
+
* one: a delegated operation is bound by the rule like any other principal (ADR-0048).
|
|
27
|
+
*/
|
|
28
|
+
function isSeparationOfDutiesDeny(decision) {
|
|
29
|
+
return (decision.effect === 'deny' &&
|
|
30
|
+
decision.reason === 'explicit_deny_policy' &&
|
|
31
|
+
(decision.detail === exports.SEPARATION_OF_DUTIES_DENY_DETAIL ||
|
|
32
|
+
decision.detail === exports.SEPARATION_OF_DUTIES_UNVERIFIED_DETAIL));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* - `unbound`: the type does not declare SoD for this action (nothing to enforce).
|
|
36
|
+
* - `unverified`: declared, but the engine facts are absent or malformed (fail closed).
|
|
37
|
+
* - `bound_principal`: the principal appears in `actorIds` (deny).
|
|
38
|
+
* - `clear`: declared, verified, principal not named.
|
|
39
|
+
*
|
|
40
|
+
* A registry throw propagates, as in the other gate-6 evaluators.
|
|
41
|
+
*/
|
|
42
|
+
function evaluateSeparationOfDuties(ctx) {
|
|
43
|
+
const descriptor = ctx.deps.registry.resolveObjectType(ctx.resource.typeKey);
|
|
44
|
+
const declarations = descriptor?.separationOfDuties;
|
|
45
|
+
if (!Array.isArray(declarations))
|
|
46
|
+
return 'unbound';
|
|
47
|
+
const declared = declarations.some((d) => d !== null &&
|
|
48
|
+
typeof d === 'object' &&
|
|
49
|
+
Array.isArray(d.actions) &&
|
|
50
|
+
d.actions.includes(ctx.action.key));
|
|
51
|
+
if (!declared)
|
|
52
|
+
return 'unbound';
|
|
53
|
+
const attributes = ctx.context.attributes;
|
|
54
|
+
if (attributes === undefined || attributes === null)
|
|
55
|
+
return 'unverified';
|
|
56
|
+
if (!Object.prototype.hasOwnProperty.call(attributes, exports.SEPARATION_OF_DUTIES_ATTRIBUTE)) {
|
|
57
|
+
return 'unverified';
|
|
58
|
+
}
|
|
59
|
+
const value = attributes[exports.SEPARATION_OF_DUTIES_ATTRIBUTE];
|
|
60
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
61
|
+
return 'unverified';
|
|
62
|
+
if (!Object.prototype.hasOwnProperty.call(value, 'actorIds'))
|
|
63
|
+
return 'unverified';
|
|
64
|
+
const actorIds = value.actorIds;
|
|
65
|
+
if (!Array.isArray(actorIds))
|
|
66
|
+
return 'unverified';
|
|
67
|
+
for (const id of actorIds) {
|
|
68
|
+
if (typeof id !== 'string')
|
|
69
|
+
return 'unverified';
|
|
70
|
+
}
|
|
71
|
+
const principalId = ctx.principal.id;
|
|
72
|
+
if (typeof principalId === 'string' && principalId.length > 0 && actorIds.includes(principalId)) {
|
|
73
|
+
return 'bound_principal';
|
|
74
|
+
}
|
|
75
|
+
return 'clear';
|
|
76
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astram/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Astram framework — sealed security core (Identity, Authentication, Session, Risk, Authorization, Audit). ZERO framework deps — the portable decision brain (ADR-0003). The frozen public contract consumers build against; installed, not edited (ADR-0023).",
|
|
6
6
|
"type": "module",
|