@astram/guard 0.36.0 → 0.39.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/auth/auth.controller.d.ts.map +1 -1
- package/dist/auth/auth.controller.js +5 -1
- package/dist/auth/dto.d.ts +2 -0
- package/dist/auth/dto.d.ts.map +1 -1
- package/dist/authz/list-scope-sql.d.ts +21 -0
- package/dist/authz/list-scope-sql.d.ts.map +1 -1
- package/dist/authz/list-scope-sql.js +45 -2
- package/dist/authz/mariadb-list-scope-adapter.d.ts.map +1 -1
- package/dist/authz/mariadb-list-scope-adapter.js +10 -25
- package/dist/authz/mariadb-policy-store.d.ts +45 -7
- package/dist/authz/mariadb-policy-store.d.ts.map +1 -1
- package/dist/authz/mariadb-policy-store.js +112 -13
- package/dist/authz/mariadb-record-rule-adapter.d.ts +19 -1
- package/dist/authz/mariadb-record-rule-adapter.d.ts.map +1 -1
- package/dist/authz/mariadb-record-rule-adapter.js +65 -14
- package/dist/authz/rule-subject.d.ts +32 -0
- package/dist/authz/rule-subject.d.ts.map +1 -0
- package/dist/authz/rule-subject.js +71 -0
- package/dist/authz/viewer-departments.d.ts +14 -0
- package/dist/authz/viewer-departments.d.ts.map +1 -0
- package/dist/authz/viewer-departments.js +61 -0
- package/dist/authz/wire-record-authorization.d.ts.map +1 -1
- package/dist/authz/wire-record-authorization.js +25 -2
- package/dist/completeness/catalog-reconciler.d.ts +10 -1
- package/dist/completeness/catalog-reconciler.d.ts.map +1 -1
- package/dist/completeness/catalog-reconciler.js +23 -4
- package/dist/completeness/ports/catalog-store.d.ts +19 -2
- package/dist/completeness/ports/catalog-store.d.ts.map +1 -1
- package/dist/identity/auth-facts.controller.d.ts.map +1 -1
- package/dist/identity/auth-facts.controller.js +5 -1
- package/dist/identity/identity-actions.d.ts +8 -0
- package/dist/identity/identity-actions.d.ts.map +1 -1
- package/dist/identity/identity-actions.js +8 -1
- package/dist/identity/module-registry.bridge.d.ts +16 -0
- package/dist/identity/module-registry.bridge.d.ts.map +1 -1
- package/dist/identity/module-registry.bridge.js +45 -0
- package/dist/identity/permission-facts.adapter.d.ts +41 -1
- package/dist/identity/permission-facts.adapter.d.ts.map +1 -1
- package/dist/identity/permission-facts.adapter.js +98 -1
- package/dist/index.d.ts +8 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -6
- package/dist/module/shield-tokens.d.ts +27 -0
- package/dist/module/shield-tokens.d.ts.map +1 -1
- package/dist/module/shield-tokens.js +8 -1
- package/migrations/1710000000141-AddRecordRuleSubjectRoles.cjs +95 -0
- package/migrations/1710000000143-AddPermissionGroup.cjs +41 -0
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.controller.d.ts","sourceRoot":"","sources":["../../src/auth/auth.controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAeH,OAAO,KAAK,EACV,aAAa,EAIb,cAAc,EAGd,gBAAgB,EAEjB,MAAM,cAAc,CAAC;AAkCtB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAEjF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAQjE,OAAO,EAA2C,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE3F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,iCAAiC,CAAC;AAOtF,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,CAAC;IAyGhB;;;;;;;;;;;;;;;;OAgBG;IAIG,GAAG,CAAS,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC;IA0B5D;;;;;;;;;;;;;;OAcG;YACW,eAAe;IAsD7B;;;;;;;;;;;;;;;OAeG;YACW,uBAAuB;IA6GrC;;;;;;;;OAQG;IACH,OAAO,CAAC,kBAAkB;IA0C1B,kFAAkF;IAClF,OAAO,CAAC,WAAW;IAOnB,iGAAiG;IACjG,OAAO,CAAC,YAAY;IAIpB;;;OAGG;YACW,qBAAqB;IAiBnC;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,OAAO,CAAC,mBAAmB;IAuC3B;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,gBAAgB;IAIxB;;;;;;;;;;OAUG;IAIG,OAAO,CAAS,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;IA0EpE,iGAAiG;IACjG,OAAO,CAAC,YAAY;IAUpB;;;;OAIG;YACW,cAAc;IAe5B;;;;;;;;;;;;;;;;;;;;OAoBG;YACW,cAAc;IA0E5B;;;;;;;;;;OAUG;IAIG,MAAM,CACF,IAAI,EAAE,aAAa,EACD,aAAa,CAAC,EAAE,MAAM,GAC/C,OAAO,CAAC,IAAI,CAAC;IA0ChB;;;;;OAKG;YACW,iBAAiB;CAOhC"}
|
|
@@ -523,7 +523,11 @@ let AuthController = class AuthController {
|
|
|
523
523
|
if (adapter === undefined || adapter === null)
|
|
524
524
|
return undefined;
|
|
525
525
|
try {
|
|
526
|
-
|
|
526
|
+
// Department scope fact: the principal kind, as `GET /identity/auth-facts` passes it, so the
|
|
527
|
+
// inline answer equals that route's.
|
|
528
|
+
return await adapter.projectFor(principal.id, principal.tenantId, principal.isRoot === true, {
|
|
529
|
+
kind: principal.kind,
|
|
530
|
+
});
|
|
527
531
|
}
|
|
528
532
|
catch {
|
|
529
533
|
// Fail-closed → omit `authFacts`; the frontend fetches it separately. Never a
|
package/dist/auth/dto.d.ts
CHANGED
|
@@ -72,6 +72,8 @@ export interface AuthFactsView {
|
|
|
72
72
|
}>;
|
|
73
73
|
readonly projectedAt: number;
|
|
74
74
|
readonly permissionsVersion?: number;
|
|
75
|
+
/** Department scope fact (UX only): readable types whose reads a department policy narrows. */
|
|
76
|
+
readonly scopeLimits?: Readonly<Record<string, readonly 'department'[]>>;
|
|
75
77
|
}
|
|
76
78
|
/** A successful session establishment payload (login / mfa / refresh success). */
|
|
77
79
|
export interface SessionSuccess {
|
package/dist/auth/dto.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dto.d.ts","sourceRoot":"","sources":["../../src/auth/dto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AASH;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IAC9D,oBAAoB;IACpB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,oBAAoB;IACpB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;QAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;QAC1B,Q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M,aAAa,GAAG,cAAc,GAAG,oBAAoB,CAAC;AAMlE;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IACzB,kFAAkF;IAClF,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,CAAC;IAC1C,iEAAiE;IACjE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,cAAc,CAAC;AAMzC;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,eAAe,GAAG,cAAc,CAAC;AAM7C;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;CACxB"}
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
*/
|
|
78
78
|
import type { ListScopeSpec, ScopeCondition } from '@astram/core';
|
|
79
79
|
import { type ObjectType } from '@astram/engine';
|
|
80
|
+
import { AuthorizationUnavailableError } from '@astram/core';
|
|
80
81
|
/** The translated fragment: a boolean WHERE expression + its ordered bind params. */
|
|
81
82
|
export interface TranslatedListScope {
|
|
82
83
|
/** A SQL boolean expression carrying ONLY `?` placeholders + backtick columns. */
|
|
@@ -93,7 +94,27 @@ export interface TranslatedListScope {
|
|
|
93
94
|
export interface ListScopePrincipal {
|
|
94
95
|
readonly principalId: string;
|
|
95
96
|
readonly principalTenantId: string;
|
|
97
|
+
/**
|
|
98
|
+
* The viewer's department codes for `in_my_departments` / `not_in_my_departments`
|
|
99
|
+
* (department-scoped policies, spec §5 D): the codes of the viewer's in-effect postings in
|
|
100
|
+
* `principalTenantId`. `null` / absent = NOT LOADED: the wiring loads the set whenever a
|
|
101
|
+
* group uses a department operator, so a department operator meeting an unloaded set is a
|
|
102
|
+
* programming error and the translator THROWS {@link UnloadedDepartmentSetError} (fail
|
|
103
|
+
* closed, never `TRUE`). The owning-tenant (cross-tenant) deny branch is always translated
|
|
104
|
+
* with an EMPTY set (D3), whatever this holds.
|
|
105
|
+
*/
|
|
106
|
+
readonly departmentCodes?: readonly string[] | null | undefined;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Thrown when a department operator is translated without a loaded viewer department set (a
|
|
110
|
+
* wiring error). It IS an {@link AuthorizationUnavailableError} (branded), so the read fails
|
|
111
|
+
* 503 like any other unanswerable access decision (spec §13), never an unbounded list.
|
|
112
|
+
*/
|
|
113
|
+
export declare class UnloadedDepartmentSetError extends AuthorizationUnavailableError {
|
|
114
|
+
constructor(typeKey: string);
|
|
96
115
|
}
|
|
116
|
+
/** Whether any condition of any group uses a department operator (the wiring's load trigger). */
|
|
117
|
+
export declare function groupsUseDepartmentOperator(groups: readonly (readonly ScopeCondition[])[]): boolean;
|
|
97
118
|
/** Error thrown when a scope condition references a field the type does not register. */
|
|
98
119
|
export declare class UnknownScopeFieldError extends Error {
|
|
99
120
|
constructor(typeKey: string, field: string);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-scope-sql.d.ts","sourceRoot":"","sources":["../../src/authz/list-scope-sql.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4EG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EAIf,MAAM,cAAc,CAAC;AACtB,OAAO,EAML,KAAK,UAAU,EAChB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"list-scope-sql.d.ts","sourceRoot":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CAAC,EAAE,MAAM,MAAM,CAAC;IACrB;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE,SAAS,CAAC,SAAS,cAAc,EAAE,CAAC,EAAE,CAAC;CAC3D,GACA,mBAAmB,CAgKrB"}
|
|
@@ -77,10 +77,34 @@
|
|
|
77
77
|
* PURE — no DB, no I/O. `translateListScope(spec, reg, principal) → { sql, params }`.
|
|
78
78
|
*/
|
|
79
79
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
80
|
-
exports.UnknownScopeFieldError = void 0;
|
|
80
|
+
exports.UnknownScopeFieldError = exports.UnloadedDepartmentSetError = void 0;
|
|
81
|
+
exports.groupsUseDepartmentOperator = groupsUseDepartmentOperator;
|
|
81
82
|
exports.translateListScope = translateListScope;
|
|
82
83
|
const engine_1 = require("@astram/engine");
|
|
83
84
|
const core_1 = require("@astram/core");
|
|
85
|
+
/**
|
|
86
|
+
* Thrown when a department operator is translated without a loaded viewer department set (a
|
|
87
|
+
* wiring error). It IS an {@link AuthorizationUnavailableError} (branded), so the read fails
|
|
88
|
+
* 503 like any other unanswerable access decision (spec §13), never an unbounded list.
|
|
89
|
+
*/
|
|
90
|
+
class UnloadedDepartmentSetError extends core_1.AuthorizationUnavailableError {
|
|
91
|
+
constructor(typeKey) {
|
|
92
|
+
super(`list-scope: a department operator on type '${typeKey}' met an unloaded viewer ` +
|
|
93
|
+
`department set (wiring error); the read fails closed.`);
|
|
94
|
+
this.name = 'UnloadedDepartmentSetError';
|
|
95
|
+
Object.setPrototypeOf(this, UnloadedDepartmentSetError.prototype);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.UnloadedDepartmentSetError = UnloadedDepartmentSetError;
|
|
99
|
+
/** The department operators (department-scoped policies). */
|
|
100
|
+
const DEPARTMENT_OPERATORS = new Set([
|
|
101
|
+
'in_my_departments',
|
|
102
|
+
'not_in_my_departments',
|
|
103
|
+
]);
|
|
104
|
+
/** Whether any condition of any group uses a department operator (the wiring's load trigger). */
|
|
105
|
+
function groupsUseDepartmentOperator(groups) {
|
|
106
|
+
return groups.some((g) => g.some((c) => DEPARTMENT_OPERATORS.has(c.operator)));
|
|
107
|
+
}
|
|
84
108
|
/** Error thrown when a scope condition references a field the type does not register. */
|
|
85
109
|
class UnknownScopeFieldError extends Error {
|
|
86
110
|
constructor(typeKey, field) {
|
|
@@ -183,6 +207,23 @@ function translateCondition(cond, reg, principal, p) {
|
|
|
183
207
|
case 'is_not_owner':
|
|
184
208
|
// Same guards, mirrored for the negative ownership operator.
|
|
185
209
|
return `(${col} IS NOT NULL AND ${col} <> '' AND ${col} <> ${p.bind(principal.principalId)})`;
|
|
210
|
+
case 'in_my_departments':
|
|
211
|
+
case 'not_in_my_departments': {
|
|
212
|
+
// Department-scoped policies (spec §5 D, D5). Mirrors `conditionHolds`: in = a non-empty
|
|
213
|
+
// value that equals (byte for byte — `CAST(… AS BINARY)`, so no case- or pad-insensitive
|
|
214
|
+
// collation can widen the list past decide()'s `===`) one of the viewer's codes; not_in =
|
|
215
|
+
// its null-safe negation. Every code is a bound `?`; none reaches the SQL text.
|
|
216
|
+
const codes = principal.departmentCodes;
|
|
217
|
+
if (codes === null || codes === undefined)
|
|
218
|
+
throw new UnloadedDepartmentSetError(reg.typeKey);
|
|
219
|
+
const negate = op === 'not_in_my_departments';
|
|
220
|
+
if (codes.length === 0)
|
|
221
|
+
return negate ? 'TRUE' : 'FALSE';
|
|
222
|
+
const placeholders = codes.map((c) => `CAST(${p.bind(c)} AS BINARY)`).join(', ');
|
|
223
|
+
return negate
|
|
224
|
+
? `(${col} IS NULL OR ${col} = '' OR CAST(${col} AS BINARY) NOT IN (${placeholders}))`
|
|
225
|
+
: `(${col} IS NOT NULL AND ${col} <> '' AND CAST(${col} AS BINARY) IN (${placeholders}))`;
|
|
226
|
+
}
|
|
186
227
|
default:
|
|
187
228
|
// Unknown operator → a condition that never matches (fail-closed; never widen).
|
|
188
229
|
return 'FALSE';
|
|
@@ -352,7 +393,9 @@ function translateListScope(spec, reg, principal, opts) {
|
|
|
352
393
|
if (!rootUnbounded) {
|
|
353
394
|
const crossTenant = translateCrossTenant(spec, reg, schema, nowMs, p);
|
|
354
395
|
if (crossTenant !== null) {
|
|
355
|
-
|
|
396
|
+
// D3: a record reached only by a cross-tenant grant is judged with an EMPTY viewer
|
|
397
|
+
// department set (decide() does the same for a resource outside the subtree).
|
|
398
|
+
const owningDeny = translateGroups(opts.owningTenantDeny ?? [], reg, { ...principal, departmentCodes: [] }, p);
|
|
356
399
|
const crossBranch = owningDeny !== null ? `( ${crossTenant} ) AND NOT ( ${owningDeny} )` : crossTenant;
|
|
357
400
|
result = `( ${sameTenantBranch} OR ${crossBranch} )`;
|
|
358
401
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mariadb-list-scope-adapter.d.ts","sourceRoot":"","sources":["../../src/authz/mariadb-list-scope-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAGjB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"mariadb-list-scope-adapter.d.ts","sourceRoot":"","sources":["../../src/authz/mariadb-list-scope-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAGjB,MAAM,cAAc,CAAC;AAKtB,iFAAiF;AACjF,eAAO,MAAM,sBAAsB,eAAmC,CAAC;AAEvE,oFAAoF;AACpF,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACnE;AAsBD;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,aAAa;IAC3D,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAqB;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAEpB,EAAE,EAAE,kBAAkB,EAAE,IAAI,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO;IAO5D,oBAAoB,CACxB,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,SAAS,MAAM,EAAE,EAChC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,oBAAoB,CAAC;CA8EjC"}
|
|
@@ -44,31 +44,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
44
44
|
exports.MariaDbListScopeAdapter = exports.SHIELD_LIST_SCOPE_PORT = void 0;
|
|
45
45
|
const core_1 = require("@astram/core");
|
|
46
46
|
const framework_schema_names_js_1 = require("../config/framework-schema-names.js");
|
|
47
|
+
const rule_subject_js_1 = require("./rule-subject.js");
|
|
47
48
|
/** The DI token the adapter is bound under (parity with the rule-port token). */
|
|
48
49
|
exports.SHIELD_LIST_SCOPE_PORT = Symbol('SHIELD_LIST_SCOPE_PORT');
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
* A group's subject is consistent across its rows (the store writes one subject per policy),
|
|
57
|
-
* so it is read from the group's HEAD row (like the effect). A group that FAILS the subject
|
|
58
|
-
* match contributes to NEITHER allow NOR deny — it is simply not this principal's rule (a
|
|
59
|
-
* role-subjected DENY not aimed at the principal must NOT over-restrict them, the symmetric
|
|
60
|
-
* divergence — so BOTH sides are filtered identically).
|
|
61
|
-
*/
|
|
62
|
-
function subjectMatches(head, subject) {
|
|
63
|
-
const kind = head.rpr_subject_kind;
|
|
64
|
-
if (kind === 'everyone')
|
|
65
|
-
return true;
|
|
66
|
-
if (kind === 'role') {
|
|
67
|
-
return head.rpr_subject_value !== null && subject.roleIds.includes(head.rpr_subject_value);
|
|
68
|
-
}
|
|
69
|
-
// Unknown subject kind → does NOT match (fail-closed).
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
50
|
+
// Subject matching is the ONE shared helper (`rule-subject.ts`) the per-record rule adapter
|
|
51
|
+
// also uses (department-scoped policies D4), so list and decide() agree on who a rule
|
|
52
|
+
// applies to. A group that FAILS the subject match contributes to NEITHER allow NOR deny —
|
|
53
|
+
// it is simply not this principal's rule (a role-subjected DENY not aimed at the principal
|
|
54
|
+
// must NOT over-restrict them — so BOTH sides are filtered identically). Like `evaluate`,
|
|
55
|
+
// every row of the group must subject-match (the store writes one subject per policy, so
|
|
56
|
+
// this equals the head-row check on well-formed data and stays identical on malformed data).
|
|
72
57
|
/**
|
|
73
58
|
* The concrete list-scope adapter. Reads the ADMIN rules for `(tenant, type_key, action|*)`
|
|
74
59
|
* and projects them into allow/deny {@link ScopeCondition} AND-groups for the translator.
|
|
@@ -93,7 +78,7 @@ class MariaDbListScopeAdapter {
|
|
|
93
78
|
: `rpr_tenant_uuid IS NULL`;
|
|
94
79
|
let rows;
|
|
95
80
|
try {
|
|
96
|
-
rows = (await this.db.query(`SELECT rpr_policy_uuid, rpr_effect, rpr_subject_kind, rpr_subject_value, rpr_field, rpr_operator, rpr_value
|
|
81
|
+
rows = (await this.db.query(`SELECT rpr_policy_uuid, rpr_effect, rpr_subject_kind, rpr_subject_value, rpr_subject_role_uuids, rpr_field, rpr_operator, rpr_value
|
|
97
82
|
FROM \`${this.schema}\`.\`record_permission_rule\`
|
|
98
83
|
WHERE rpr_type_key = ?
|
|
99
84
|
AND ${tenantClause}
|
|
@@ -132,7 +117,7 @@ class MariaDbListScopeAdapter {
|
|
|
132
117
|
// A group whose subject does NOT match this principal contributes to NEITHER allow NOR
|
|
133
118
|
// deny (it is not this principal's rule). Applied identically to allow AND deny so a
|
|
134
119
|
// role-subjected deny not aimed at the principal cannot over-restrict them.
|
|
135
|
-
if (!subjectMatches(
|
|
120
|
+
if (!groupRows.every((row) => (0, rule_subject_js_1.subjectMatches)(row, subject.roleIds)))
|
|
136
121
|
continue;
|
|
137
122
|
// A NULL-field row contributes NO condition (unconditional). A group of only such
|
|
138
123
|
// rows → an EMPTY condition list, which the translator renders as `(TRUE)` — a
|
|
@@ -28,10 +28,13 @@
|
|
|
28
28
|
* • `rpr_type_key` — the policy's `typeKey` (same on every row).
|
|
29
29
|
* • `rpr_action` — the policy's `action` (same on every row).
|
|
30
30
|
* • `rpr_effect` — the policy's `effect` ('allow' | 'deny'; same every row).
|
|
31
|
-
* • `rpr_subject_kind` —
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* • `rpr_subject_value`— always NULL (
|
|
31
|
+
* • `rpr_subject_kind` — the policy's subject kind (department-scoped policies, D4):
|
|
32
|
+
* `'everyone'` (absent subject — the pre-existing mapping),
|
|
33
|
+
* `'roles'` or `'except_roles'`. Same on every row.
|
|
34
|
+
* • `rpr_subject_value`— always NULL (the legacy single-`role` kind is read, never written).
|
|
35
|
+
* • `rpr_subject_role_uuids` — NULL for `everyone`; else the JSON array of the subject's
|
|
36
|
+
* role ids, sorted and distinct (guard migration 141). Same on
|
|
37
|
+
* every row.
|
|
35
38
|
* • `rpr_field` — the condition's `field` (NULL for a 0-condition policy).
|
|
36
39
|
* • `rpr_operator` — the condition's operator, persisted with core's CANONICAL
|
|
37
40
|
* name (`eq`, `ne`, `is_owner`, …). The read adapter
|
|
@@ -68,9 +71,36 @@
|
|
|
68
71
|
import type { GuidedPolicy, Policy, PolicyStore } from '@astram/core';
|
|
69
72
|
/** The DI token the policy store is bound under (parity with the rule-port token). */
|
|
70
73
|
export declare const SHIELD_POLICY_STORE: unique symbol;
|
|
71
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* The minimal query surface this store needs — a `mariadb` Pool satisfies it. A db that can also
|
|
76
|
+
* open a connection (`getConnection`, as a Pool does) lets a write with
|
|
77
|
+
* {@link PolicyWriteOptions} run in one transaction (department-scope-fact SPEC §5).
|
|
78
|
+
*/
|
|
72
79
|
export interface RuleQueryable {
|
|
73
80
|
query(sql: string, params?: readonly unknown[]): Promise<unknown>;
|
|
81
|
+
getConnection?(): Promise<PolicyStoreConnection>;
|
|
82
|
+
}
|
|
83
|
+
/** One transaction connection — a `mariadb` `PoolConnection` satisfies it structurally. */
|
|
84
|
+
export interface PolicyStoreConnection {
|
|
85
|
+
query(sql: string, params?: readonly unknown[]): Promise<unknown>;
|
|
86
|
+
beginTransaction(): Promise<void>;
|
|
87
|
+
commit(): Promise<void>;
|
|
88
|
+
rollback(): Promise<void>;
|
|
89
|
+
release(): void | Promise<void>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Hooks of one policy write (department-scope-fact SPEC §5). With them and a db that can open a
|
|
93
|
+
* connection, the rows and `afterWrite` run in ONE transaction on one connection: BEGIN, the
|
|
94
|
+
* rows, `afterWrite`, COMMIT, then `afterCommit`; ROLLBACK (then `afterRollback`) on any error,
|
|
95
|
+
* which is rethrown. A delete that removes no row runs no hook and commits nothing.
|
|
96
|
+
*/
|
|
97
|
+
export interface PolicyWriteOptions {
|
|
98
|
+
/** Runs inside the transaction after the rows (e.g. the tenant permission-version bump). */
|
|
99
|
+
readonly afterWrite?: (q: RuleQueryable) => Promise<void>;
|
|
100
|
+
/** Runs after COMMIT, before the connection is released (e.g. publish the bumped version). */
|
|
101
|
+
readonly afterCommit?: (q: RuleQueryable) => Promise<void>;
|
|
102
|
+
/** Runs after ROLLBACK, before the connection is released (e.g. drop pending publishes). */
|
|
103
|
+
readonly afterRollback?: (q: RuleQueryable) => void | Promise<void>;
|
|
74
104
|
}
|
|
75
105
|
/**
|
|
76
106
|
* The concrete guided-policy store. Persists a {@link GuidedPolicy} as N
|
|
@@ -89,7 +119,14 @@ export declare class MariaDbPolicyStore implements PolicyStore {
|
|
|
89
119
|
* Returns the {@link Policy} with `policyId = rpr_policy_uuid`. The engine has
|
|
90
120
|
* already VALIDATED the structure (AC 5) before this is called.
|
|
91
121
|
*/
|
|
92
|
-
savePolicy(tenantId: string, policy: GuidedPolicy): Promise<Policy>;
|
|
122
|
+
savePolicy(tenantId: string, policy: GuidedPolicy, opts?: PolicyWriteOptions): Promise<Policy>;
|
|
123
|
+
/**
|
|
124
|
+
* Run one write and its hooks (see {@link PolicyWriteOptions}). With a db that opens a
|
|
125
|
+
* connection: one transaction, rolled back on any error (rethrown). Without one: the write and
|
|
126
|
+
* `afterWrite` on the db in turn (no transaction to join), then `afterCommit`.
|
|
127
|
+
*/
|
|
128
|
+
private inWriteTransaction;
|
|
129
|
+
private insertPolicy;
|
|
93
130
|
/**
|
|
94
131
|
* List the policies governing `typeKey` in `tenantId`, GROUPED by
|
|
95
132
|
* `rpr_policy_uuid` — each group's rows reconstruct one {@link GuidedPolicy}
|
|
@@ -113,6 +150,7 @@ export declare class MariaDbPolicyStore implements PolicyStore {
|
|
|
113
150
|
* ── SAFETY: both `rpr_policy_uuid` + `rpr_tenant_uuid` are `?`-bound. The tenant is the
|
|
114
151
|
* SERVER-resolved actor tenant (never client input) — see the PolicyService.
|
|
115
152
|
*/
|
|
116
|
-
deletePolicyForTenant(policyId: string, tenantId: string): Promise<number>;
|
|
153
|
+
deletePolicyForTenant(policyId: string, tenantId: string, opts?: PolicyWriteOptions): Promise<number>;
|
|
154
|
+
private deleteRows;
|
|
117
155
|
}
|
|
118
156
|
//# sourceMappingURL=mariadb-policy-store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mariadb-policy-store.d.ts","sourceRoot":"","sources":["../../src/authz/mariadb-policy-store.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"mariadb-policy-store.d.ts","sourceRoot":"","sources":["../../src/authz/mariadb-policy-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AAGH,OAAO,KAAK,EACV,YAAY,EACZ,MAAM,EACN,WAAW,EAGZ,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AI,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO;IAO7D;;;;;OAKG;IACG,UAAU,CACd,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,YAAY,EACpB,IAAI,CAAC,EAAE,kBAAkB,GACxB,OAAO,CAAC,MAAM,CAAC;IAOlB;;;;OAIG;YACW,kBAAkB;YAqClB,YAAY;IAqD1B;;;;OAIG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC;IAmDjF;;;;OAIG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQnD;;;;;;;;;;OAUG;IACG,qBAAqB,CACzB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,kBAAkB,GACxB,OAAO,CAAC,MAAM,CAAC;YAQJ,UAAU;CASzB"}
|
|
@@ -29,10 +29,13 @@
|
|
|
29
29
|
* • `rpr_type_key` — the policy's `typeKey` (same on every row).
|
|
30
30
|
* • `rpr_action` — the policy's `action` (same on every row).
|
|
31
31
|
* • `rpr_effect` — the policy's `effect` ('allow' | 'deny'; same every row).
|
|
32
|
-
* • `rpr_subject_kind` —
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* • `rpr_subject_value`— always NULL (
|
|
32
|
+
* • `rpr_subject_kind` — the policy's subject kind (department-scoped policies, D4):
|
|
33
|
+
* `'everyone'` (absent subject — the pre-existing mapping),
|
|
34
|
+
* `'roles'` or `'except_roles'`. Same on every row.
|
|
35
|
+
* • `rpr_subject_value`— always NULL (the legacy single-`role` kind is read, never written).
|
|
36
|
+
* • `rpr_subject_role_uuids` — NULL for `everyone`; else the JSON array of the subject's
|
|
37
|
+
* role ids, sorted and distinct (guard migration 141). Same on
|
|
38
|
+
* every row.
|
|
36
39
|
* • `rpr_field` — the condition's `field` (NULL for a 0-condition policy).
|
|
37
40
|
* • `rpr_operator` — the condition's operator, persisted with core's CANONICAL
|
|
38
41
|
* name (`eq`, `ne`, `is_owner`, …). The read adapter
|
|
@@ -70,6 +73,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
70
73
|
exports.MariaDbPolicyStore = exports.SHIELD_POLICY_STORE = void 0;
|
|
71
74
|
const node_crypto_1 = require("node:crypto");
|
|
72
75
|
const framework_schema_names_js_1 = require("../config/framework-schema-names.js");
|
|
76
|
+
const rule_subject_js_1 = require("./rule-subject.js");
|
|
73
77
|
/** The DI token the policy store is bound under (parity with the rule-port token). */
|
|
74
78
|
exports.SHIELD_POLICY_STORE = Symbol('SHIELD_POLICY_STORE');
|
|
75
79
|
/**
|
|
@@ -82,7 +86,39 @@ const OPERAND_LESS_OPERATORS = new Set([
|
|
|
82
86
|
'is_not_null',
|
|
83
87
|
'is_owner',
|
|
84
88
|
'is_not_owner',
|
|
89
|
+
'in_my_departments',
|
|
90
|
+
'not_in_my_departments',
|
|
85
91
|
]);
|
|
92
|
+
/** The `(rpr_subject_kind, rpr_subject_role_uuids)` pair written on every row of a policy. */
|
|
93
|
+
function subjectColumns(subject) {
|
|
94
|
+
if (subject === undefined || subject.kind === 'everyone')
|
|
95
|
+
return ['everyone', null];
|
|
96
|
+
const ids = [...new Set(subject.roleIds)].sort();
|
|
97
|
+
return [subject.kind, JSON.stringify(ids)];
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Rebuild a policy's subject from its group's first row. A legacy `role` row reads as
|
|
101
|
+
* `{ kind: 'roles', roleIds: [value] }`. A row whose subject the enforcement helper would never
|
|
102
|
+
* match (unknown kind, malformed / empty JSON) reads as `{ kind: 'roles', roleIds: [] }` — "applies
|
|
103
|
+
* to nobody", which is what enforcement does with it — so the admin still sees (and can delete)
|
|
104
|
+
* the rule. A row with no subject columns at all (pre-subject reader) reads as `everyone`.
|
|
105
|
+
*/
|
|
106
|
+
function subjectOf(row) {
|
|
107
|
+
const kind = row.rpr_subject_kind;
|
|
108
|
+
if (kind === undefined || kind === 'everyone')
|
|
109
|
+
return { kind: 'everyone' };
|
|
110
|
+
if (kind === 'role') {
|
|
111
|
+
return typeof row.rpr_subject_value === 'string' && row.rpr_subject_value !== ''
|
|
112
|
+
? { kind: 'roles', roleIds: [row.rpr_subject_value] }
|
|
113
|
+
: { kind: 'roles', roleIds: [] };
|
|
114
|
+
}
|
|
115
|
+
if (kind === 'roles' || kind === 'except_roles') {
|
|
116
|
+
const ids = (0, rule_subject_js_1.parseSubjectRoleIds)(row.rpr_subject_role_uuids);
|
|
117
|
+
if (ids !== null)
|
|
118
|
+
return { kind, roleIds: [...ids] };
|
|
119
|
+
}
|
|
120
|
+
return { kind: 'roles', roleIds: [] };
|
|
121
|
+
}
|
|
86
122
|
/** Serialize a condition operand to the VARCHAR form the enforcement adapter reads. */
|
|
87
123
|
function serializeValue(condition) {
|
|
88
124
|
if (OPERAND_LESS_OPERATORS.has(condition.operator))
|
|
@@ -112,7 +148,56 @@ class MariaDbPolicyStore {
|
|
|
112
148
|
* Returns the {@link Policy} with `policyId = rpr_policy_uuid`. The engine has
|
|
113
149
|
* already VALIDATED the structure (AC 5) before this is called.
|
|
114
150
|
*/
|
|
115
|
-
async savePolicy(tenantId, policy) {
|
|
151
|
+
async savePolicy(tenantId, policy, opts) {
|
|
152
|
+
if (opts === undefined)
|
|
153
|
+
return this.insertPolicy(this.db, tenantId, policy);
|
|
154
|
+
return this.inWriteTransaction(opts, (q) => this.insertPolicy(q, tenantId, policy), {
|
|
155
|
+
wrote: () => true,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Run one write and its hooks (see {@link PolicyWriteOptions}). With a db that opens a
|
|
160
|
+
* connection: one transaction, rolled back on any error (rethrown). Without one: the write and
|
|
161
|
+
* `afterWrite` on the db in turn (no transaction to join), then `afterCommit`.
|
|
162
|
+
*/
|
|
163
|
+
async inWriteTransaction(opts, write, hooks) {
|
|
164
|
+
const open = this.db.getConnection;
|
|
165
|
+
if (typeof open !== 'function') {
|
|
166
|
+
const result = await write(this.db);
|
|
167
|
+
if (hooks.wrote(result)) {
|
|
168
|
+
await opts.afterWrite?.(this.db);
|
|
169
|
+
await opts.afterCommit?.(this.db);
|
|
170
|
+
}
|
|
171
|
+
return result;
|
|
172
|
+
}
|
|
173
|
+
const conn = await open.call(this.db);
|
|
174
|
+
try {
|
|
175
|
+
await conn.beginTransaction();
|
|
176
|
+
let result;
|
|
177
|
+
try {
|
|
178
|
+
result = await write(conn);
|
|
179
|
+
if (hooks.wrote(result))
|
|
180
|
+
await opts.afterWrite?.(conn);
|
|
181
|
+
await conn.commit();
|
|
182
|
+
}
|
|
183
|
+
catch (cause) {
|
|
184
|
+
try {
|
|
185
|
+
await conn.rollback();
|
|
186
|
+
}
|
|
187
|
+
finally {
|
|
188
|
+
await opts.afterRollback?.(conn);
|
|
189
|
+
}
|
|
190
|
+
throw cause;
|
|
191
|
+
}
|
|
192
|
+
if (hooks.wrote(result))
|
|
193
|
+
await opts.afterCommit?.(conn);
|
|
194
|
+
return result;
|
|
195
|
+
}
|
|
196
|
+
finally {
|
|
197
|
+
await conn.release();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
async insertPolicy(q, tenantId, policy) {
|
|
116
201
|
// ONE generated group id shared by every row of this policy (the AND-group key).
|
|
117
202
|
const policyUuid = (0, node_crypto_1.randomUUID)();
|
|
118
203
|
// A 0-condition policy → ONE unconditional row (field/operator/value NULL).
|
|
@@ -124,22 +209,26 @@ class MariaDbPolicyStore {
|
|
|
124
209
|
operator: c.operator, // canonical core name (eq/ne/is_owner/…)
|
|
125
210
|
value: serializeValue(c),
|
|
126
211
|
}));
|
|
212
|
+
// ONE subject for the whole policy, written onto every row (D4).
|
|
213
|
+
const [subjectKind, subjectRoleUuids] = subjectColumns(policy.subject);
|
|
127
214
|
for (const row of rows) {
|
|
128
|
-
await
|
|
215
|
+
await q.query(`INSERT INTO \`${this.schema}\`.\`record_permission_rule\`
|
|
129
216
|
(rpr_uuid, rpr_policy_uuid, rpr_tenant_uuid, rpr_type_key, rpr_action,
|
|
130
|
-
rpr_effect, rpr_subject_kind, rpr_subject_value, rpr_field, rpr_operator, rpr_value
|
|
131
|
-
|
|
217
|
+
rpr_effect, rpr_subject_kind, rpr_subject_value, rpr_field, rpr_operator, rpr_value,
|
|
218
|
+
rpr_subject_role_uuids)
|
|
219
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
132
220
|
(0, node_crypto_1.randomUUID)(), // rpr_uuid — a fresh per-row id
|
|
133
221
|
policyUuid, // rpr_policy_uuid — the SHARED group id
|
|
134
222
|
tenantId, // rpr_tenant_uuid
|
|
135
223
|
policy.typeKey, // rpr_type_key
|
|
136
224
|
policy.action, // rpr_action
|
|
137
225
|
policy.effect, // rpr_effect
|
|
138
|
-
|
|
139
|
-
null, // rpr_subject_value
|
|
226
|
+
subjectKind, // rpr_subject_kind — everyone | roles | except_roles
|
|
227
|
+
null, // rpr_subject_value (legacy single-role kind is never written)
|
|
140
228
|
row.field, // rpr_field
|
|
141
229
|
row.operator, // rpr_operator
|
|
142
230
|
row.value, // rpr_value
|
|
231
|
+
subjectRoleUuids, // rpr_subject_role_uuids — JSON array, or NULL for everyone
|
|
143
232
|
]);
|
|
144
233
|
}
|
|
145
234
|
return { policyId: policyUuid, tenantId, policy };
|
|
@@ -150,7 +239,8 @@ class MariaDbPolicyStore {
|
|
|
150
239
|
* (its conditions = its rows, in row order). Returns `[]` when none exist (NORMAL).
|
|
151
240
|
*/
|
|
152
241
|
async listPolicies(typeKey, tenantId) {
|
|
153
|
-
const rows = (await this.db.query(`SELECT rpr_policy_uuid, rpr_action, rpr_effect,
|
|
242
|
+
const rows = (await this.db.query(`SELECT rpr_policy_uuid, rpr_action, rpr_effect, rpr_subject_kind, rpr_subject_value,
|
|
243
|
+
rpr_subject_role_uuids, rpr_field, rpr_operator, rpr_value
|
|
154
244
|
FROM \`${this.schema}\`.\`record_permission_rule\`
|
|
155
245
|
WHERE rpr_type_key = ?
|
|
156
246
|
AND rpr_tenant_uuid = ?
|
|
@@ -191,6 +281,7 @@ class MariaDbPolicyStore {
|
|
|
191
281
|
action: first.rpr_action ?? '',
|
|
192
282
|
effect: first.rpr_effect === 'deny' ? 'deny' : 'allow',
|
|
193
283
|
conditions,
|
|
284
|
+
subject: subjectOf(first),
|
|
194
285
|
},
|
|
195
286
|
});
|
|
196
287
|
}
|
|
@@ -216,8 +307,16 @@ class MariaDbPolicyStore {
|
|
|
216
307
|
* ── SAFETY: both `rpr_policy_uuid` + `rpr_tenant_uuid` are `?`-bound. The tenant is the
|
|
217
308
|
* SERVER-resolved actor tenant (never client input) — see the PolicyService.
|
|
218
309
|
*/
|
|
219
|
-
async deletePolicyForTenant(policyId, tenantId) {
|
|
220
|
-
|
|
310
|
+
async deletePolicyForTenant(policyId, tenantId, opts) {
|
|
311
|
+
if (opts === undefined)
|
|
312
|
+
return this.deleteRows(this.db, policyId, tenantId);
|
|
313
|
+
// No row removed (absent or another tenant's) ⇒ no hook runs: nothing to bump (§5).
|
|
314
|
+
return this.inWriteTransaction(opts, (q) => this.deleteRows(q, policyId, tenantId), {
|
|
315
|
+
wrote: (removed) => removed > 0,
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
async deleteRows(q, policyId, tenantId) {
|
|
319
|
+
const result = (await q.query(`DELETE FROM \`${this.schema}\`.\`record_permission_rule\`
|
|
221
320
|
WHERE rpr_policy_uuid = ? AND rpr_tenant_uuid = ?`, [policyId, tenantId]));
|
|
222
321
|
const affected = result?.affectedRows;
|
|
223
322
|
return typeof affected === 'number' ? affected : 0;
|
|
@@ -38,7 +38,9 @@
|
|
|
38
38
|
* 14-operator {@link import('@astram/core').PolicyOperator} model (unified with
|
|
39
39
|
* the guided policy builder, Task 0.2): `eq/ne` (dual-accept legacy
|
|
40
40
|
* `equals`/`not_equals`), `in/not_in`, `gt/lt/gte/lte`, `contains/not_contains`,
|
|
41
|
-
* `is_null/is_not_null`, `is_owner/is_not_owner
|
|
41
|
+
* `is_null/is_not_null`, `is_owner/is_not_owner`, plus the principal-relative
|
|
42
|
+
* `in_my_departments/not_in_my_departments` (department-scoped policies: the viewer's
|
|
43
|
+
* department codes, read lazily once per evaluate). An unknown operator makes the
|
|
42
44
|
* rule NOT match (fail-closed, never a spurious allow) — see `conditionHolds`
|
|
43
45
|
* below for the exact per-operator semantics and the documented edge-case choices.
|
|
44
46
|
*/
|
|
@@ -56,9 +58,25 @@ export interface RuleQueryable {
|
|
|
56
58
|
export declare class MariaDbRecordPermissionRuleAdapter implements RecordPermissionRulePort {
|
|
57
59
|
private readonly db;
|
|
58
60
|
private readonly schema;
|
|
61
|
+
private readonly appSchema;
|
|
62
|
+
private readonly now;
|
|
59
63
|
constructor(db: RuleQueryable, opts?: {
|
|
60
64
|
schema?: string;
|
|
65
|
+
/**
|
|
66
|
+
* The org (`<app>`) database the viewer-department reader joins (memberships, postings,
|
|
67
|
+
* departments). Checked; absent ⇒ resolved from `SHIELD_DB_NAMESPACE` here, once.
|
|
68
|
+
*/
|
|
69
|
+
appSchema?: string;
|
|
70
|
+
/** Clock for the posting in-effect window (epoch ms). */
|
|
71
|
+
now?: () => number;
|
|
61
72
|
});
|
|
73
|
+
/**
|
|
74
|
+
* The viewer department set `D` for this evaluation (spec §5 C, D3):
|
|
75
|
+
* - root and a record reached outside the principal's subtree (cross-tenant grant) ⇒ empty;
|
|
76
|
+
* - otherwise the codes of the principal's in-effect postings in `principal.tenantId`.
|
|
77
|
+
* A reader failure throws {@link AuthorizationUnavailableError} (fail closed).
|
|
78
|
+
*/
|
|
79
|
+
private departmentsFor;
|
|
62
80
|
evaluate(input: RulePermitInput): Promise<RulePermit>;
|
|
63
81
|
}
|
|
64
82
|
//# sourceMappingURL=mariadb-record-rule-adapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mariadb-record-rule-adapter.d.ts","sourceRoot":"","sources":["../../src/authz/mariadb-record-rule-adapter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"mariadb-record-rule-adapter.d.ts","sourceRoot":"","sources":["../../src/authz/mariadb-record-rule-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAU1F,qFAAqF;AACrF,eAAO,MAAM,uBAAuB,eAAoC,CAAC;AAEzE,oFAAoF;AACpF,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACnE;AAmMD;;;GAGG;AACH,qBAAa,kCAAmC,YAAW,wBAAwB;IACjF,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAgB;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;gBAGjC,EAAE,EAAE,aAAa,EACjB,IAAI,GAAE;QACJ,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB;;;WAGG;QACH,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,yDAAyD;QACzD,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;KACf;IAaR;;;;;OAKG;YACW,cAAc;IAoBtB,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC;CAmF5D"}
|