@astram/guard 0.13.0 → 0.15.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.module.d.ts.map +1 -1
- package/dist/auth/auth.module.js +57 -30
- package/dist/auth/connections.d.ts +2 -2
- package/dist/auth/connections.d.ts.map +1 -1
- package/dist/auth/connections.js +4 -13
- package/dist/authentication/mariadb-api-key-store.d.ts +10 -1
- package/dist/authentication/mariadb-api-key-store.d.ts.map +1 -1
- package/dist/authentication/mariadb-api-key-store.js +20 -10
- package/dist/authentication/mariadb-credential-resolver.d.ts +8 -1
- package/dist/authentication/mariadb-credential-resolver.d.ts.map +1 -1
- package/dist/authentication/mariadb-credential-resolver.js +15 -5
- package/dist/authentication/mariadb-credential-writer.d.ts +6 -1
- package/dist/authentication/mariadb-credential-writer.d.ts.map +1 -1
- package/dist/authentication/mariadb-credential-writer.js +9 -3
- package/dist/authentication/mariadb-email-address-changer.d.ts +10 -1
- package/dist/authentication/mariadb-email-address-changer.d.ts.map +1 -1
- package/dist/authentication/mariadb-email-address-changer.js +22 -9
- package/dist/authentication/mariadb-email-change-token-store.d.ts +8 -1
- package/dist/authentication/mariadb-email-change-token-store.d.ts.map +1 -1
- package/dist/authentication/mariadb-email-change-token-store.js +18 -9
- package/dist/authentication/mariadb-mfa-device-store.d.ts +6 -1
- package/dist/authentication/mariadb-mfa-device-store.d.ts.map +1 -1
- package/dist/authentication/mariadb-mfa-device-store.js +22 -13
- package/dist/authentication/mariadb-profile-resolver.d.ts +6 -1
- package/dist/authentication/mariadb-profile-resolver.d.ts.map +1 -1
- package/dist/authentication/mariadb-profile-resolver.js +12 -6
- package/dist/authentication/mariadb-profile-writer.d.ts +6 -1
- package/dist/authentication/mariadb-profile-writer.d.ts.map +1 -1
- package/dist/authentication/mariadb-profile-writer.js +11 -4
- package/dist/authentication/mariadb-recovery-code-store.d.ts +6 -1
- package/dist/authentication/mariadb-recovery-code-store.d.ts.map +1 -1
- package/dist/authentication/mariadb-recovery-code-store.js +11 -5
- package/dist/authentication/mariadb-reset-token-store.d.ts +6 -1
- package/dist/authentication/mariadb-reset-token-store.d.ts.map +1 -1
- package/dist/authentication/mariadb-reset-token-store.js +11 -5
- package/dist/authentication/mariadb-session-sweeper.d.ts +6 -1
- package/dist/authentication/mariadb-session-sweeper.d.ts.map +1 -1
- package/dist/authentication/mariadb-session-sweeper.js +11 -5
- package/dist/authz/cross-tenant-grant-writer.d.ts.map +1 -1
- package/dist/authz/cross-tenant-grant-writer.js +4 -3
- package/dist/authz/list-scope-sql.d.ts +10 -2
- package/dist/authz/list-scope-sql.d.ts.map +1 -1
- package/dist/authz/list-scope-sql.js +4 -4
- package/dist/authz/mariadb-cross-tenant-grant-adapter.d.ts.map +1 -1
- package/dist/authz/mariadb-cross-tenant-grant-adapter.js +4 -3
- package/dist/authz/mariadb-list-scope-adapter.d.ts.map +1 -1
- package/dist/authz/mariadb-list-scope-adapter.js +4 -3
- package/dist/authz/mariadb-policy-store.d.ts.map +1 -1
- package/dist/authz/mariadb-policy-store.js +4 -3
- package/dist/authz/mariadb-record-rule-adapter.d.ts.map +1 -1
- package/dist/authz/mariadb-record-rule-adapter.js +4 -3
- package/dist/authz/mariadb-record-share-adapter.d.ts.map +1 -1
- package/dist/authz/mariadb-record-share-adapter.js +4 -3
- package/dist/authz/record-share-cascade.d.ts.map +1 -1
- package/dist/authz/record-share-cascade.js +4 -3
- package/dist/authz/record-share-writer.d.ts.map +1 -1
- package/dist/authz/record-share-writer.js +4 -3
- package/dist/authz/wire-record-authorization.d.ts +8 -0
- package/dist/authz/wire-record-authorization.d.ts.map +1 -1
- package/dist/authz/wire-record-authorization.js +14 -6
- package/dist/boot/boot-sequence.d.ts +4 -0
- package/dist/boot/boot-sequence.d.ts.map +1 -1
- package/dist/boot/boot-sequence.js +13 -1
- package/dist/boot/migration-ledger-check.d.ts +94 -0
- package/dist/boot/migration-ledger-check.d.ts.map +1 -0
- package/dist/boot/migration-ledger-check.js +280 -0
- package/dist/config/app-config.d.ts +72 -3
- package/dist/config/app-config.d.ts.map +1 -1
- package/dist/config/app-config.js +129 -7
- package/dist/config/config.module.d.ts +7 -0
- package/dist/config/config.module.d.ts.map +1 -1
- package/dist/config/config.module.js +13 -2
- package/dist/config/framework-schema-names.d.ts +29 -0
- package/dist/config/framework-schema-names.d.ts.map +1 -0
- package/dist/config/framework-schema-names.js +41 -0
- package/dist/config/loopback-host.d.ts +9 -0
- package/dist/config/loopback-host.d.ts.map +1 -0
- package/dist/config/loopback-host.js +19 -0
- package/dist/encryption/local-kek-crypto.d.ts +6 -0
- package/dist/encryption/local-kek-crypto.d.ts.map +1 -1
- package/dist/encryption/local-kek-crypto.js +8 -0
- package/dist/identity/identity-actions.d.ts +18 -7
- package/dist/identity/identity-actions.d.ts.map +1 -1
- package/dist/identity/identity-actions.js +16 -17
- package/dist/identity/module-registry.bridge.d.ts.map +1 -1
- package/dist/identity/module-registry.bridge.js +5 -3
- package/dist/identity/permission-facts.adapter.d.ts +7 -1
- package/dist/identity/permission-facts.adapter.d.ts.map +1 -1
- package/dist/identity/permission-facts.adapter.js +15 -6
- package/dist/index.d.ts +14 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +68 -22
- package/dist/module/shield-tokens.d.ts +11 -0
- package/dist/module/shield-tokens.d.ts.map +1 -1
- package/dist/module/shield-tokens.js +12 -1
- package/dist/module/shield.module.d.ts +10 -0
- package/dist/module/shield.module.d.ts.map +1 -1
- package/dist/module/shield.module.js +78 -12
- package/dist/secrets/boot-secrets.d.ts +33 -0
- package/dist/secrets/boot-secrets.d.ts.map +1 -0
- package/dist/secrets/boot-secrets.js +180 -0
- package/dist/session/mariadb-session-record-store.d.ts +8 -1
- package/dist/session/mariadb-session-record-store.d.ts.map +1 -1
- package/dist/session/mariadb-session-record-store.js +23 -13
- package/dist/session/session-restriction-store.d.ts +8 -1
- package/dist/session/session-restriction-store.d.ts.map +1 -1
- package/dist/session/session-restriction-store.js +15 -5
- package/dist/storage/file-intake.interceptor.d.ts +54 -0
- package/dist/storage/file-intake.interceptor.d.ts.map +1 -0
- package/dist/storage/file-intake.interceptor.js +223 -0
- package/dist/storage/node-sha256-digest.d.ts +6 -0
- package/dist/storage/node-sha256-digest.d.ts.map +1 -0
- package/dist/storage/node-sha256-digest.js +15 -0
- package/dist/storage/object-store-boot-check.d.ts +16 -0
- package/dist/storage/object-store-boot-check.d.ts.map +1 -0
- package/dist/storage/object-store-boot-check.js +52 -0
- package/dist/storage/optional-peer.d.ts +10 -0
- package/dist/storage/optional-peer.d.ts.map +1 -0
- package/dist/storage/optional-peer.js +26 -0
- package/dist/storage/s3-object-store.d.ts +35 -0
- package/dist/storage/s3-object-store.d.ts.map +1 -0
- package/dist/storage/s3-object-store.js +238 -0
- package/dist/storage/storage.providers.d.ts +10 -0
- package/dist/storage/storage.providers.d.ts.map +1 -0
- package/dist/storage/storage.providers.js +104 -0
- package/migrations/1710000000006-CreateAuthzSchema.cjs +15 -4
- package/migrations/1710000000007-ExtendPermissionAndRolePermission.cjs +11 -3
- package/migrations/1710000000008-CreateAccessBundleTables.cjs +14 -4
- package/migrations/1710000000009-CreateRecordPermissionRule.cjs +15 -4
- package/migrations/1710000000014-CreateRecordShare.cjs +15 -4
- package/migrations/1710000000015-CreateScopeClosure.cjs +14 -4
- package/migrations/1710000000016-AlterCompanyParentFkRestrict.cjs +20 -9
- package/migrations/1710000000017-CreateServiceAccountKey.cjs +14 -4
- package/package.json +11 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mariadb-session-sweeper.d.ts","sourceRoot":"","sources":["../../src/authentication/mariadb-session-sweeper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"mariadb-session-sweeper.d.ts","sourceRoot":"","sources":["../../src/authentication/mariadb-session-sweeper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAClF,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,qCAAqC,CAAC;AAM7C,0GAA0G;AAC1G,KAAK,WAAW,GAAG,IAAI,CAAC,kBAAkB,EAAE,eAAe,CAAC,GAC1D,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,CAAC,CAAC;AAE3D,qBAAa,qBAAsB,YAAW,cAAc;IAKxD,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,gEAAgE;IAChE,OAAO,CAAC,QAAQ,CAAC,GAAG;IAPtB,oFAAoF;IACpF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;gBAGnB,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,WAAW;IACpC,gEAAgE;IAC/C,GAAG,GAAE,MAAM,MAAiB;IAC7C,yFAAyF;IACzF,OAAO,CAAC,EAAE,oBAAoB;IAKhC;;;;OAIG;YACW,SAAS;IAUjB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBzD,wBAAwB,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAkB1F"}
|
|
@@ -23,16 +23,22 @@
|
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.MariaDbSessionSweeper = void 0;
|
|
26
|
+
const framework_schema_names_js_1 = require("../config/framework-schema-names.js");
|
|
26
27
|
class MariaDbSessionSweeper {
|
|
27
28
|
pool;
|
|
28
29
|
binder;
|
|
29
30
|
now;
|
|
31
|
+
/** `<identity>`.`session`, resolved at construction (configurable-framework-db). */
|
|
32
|
+
sessionTable;
|
|
30
33
|
constructor(pool, binder,
|
|
31
34
|
/** Clock for the "not yet expired" unbind window (epoch-ms). */
|
|
32
|
-
now = Date.now
|
|
35
|
+
now = Date.now,
|
|
36
|
+
/** Framework database names; absent ⇒ resolved from `SHIELD_DB_NAMESPACE` here, once. */
|
|
37
|
+
schemas) {
|
|
33
38
|
this.pool = pool;
|
|
34
39
|
this.binder = binder;
|
|
35
40
|
this.now = now;
|
|
41
|
+
this.sessionTable = (0, framework_schema_names_js_1.qualifiedTableName)((0, framework_schema_names_js_1.schemaNamesAtConstruction)(schemas).identity, 'session');
|
|
36
42
|
}
|
|
37
43
|
/**
|
|
38
44
|
* Unbind the given sessions in Redis. Every session is attempted; if any unbind failed, the
|
|
@@ -53,9 +59,9 @@ class MariaDbSessionSweeper {
|
|
|
53
59
|
// absolute expiry, WHATEVER its status — so a retry after a failed unbind (the durable row is
|
|
54
60
|
// already `revoked`) still drops the Redis keys. Read BEFORE the durable revoke.
|
|
55
61
|
const rows = (await this.pool.query(`SELECT s_session_id
|
|
56
|
-
FROM
|
|
62
|
+
FROM ${this.sessionTable}
|
|
57
63
|
WHERE s_principal_id = ? AND s_absolute_expires_at_ms > ?`, [principalId, this.now()]));
|
|
58
|
-
await this.pool.query(`UPDATE
|
|
64
|
+
await this.pool.query(`UPDATE ${this.sessionTable}
|
|
59
65
|
SET s_status = 'revoked'
|
|
60
66
|
WHERE s_principal_id = ? AND s_status = 'active'`, [principalId]);
|
|
61
67
|
// Drop each session's Redis liveness key so outstanding access tokens die immediately, not
|
|
@@ -65,9 +71,9 @@ class MariaDbSessionSweeper {
|
|
|
65
71
|
async revokeOthersForPrincipal(principalId, keepSessionId) {
|
|
66
72
|
// Same unbind set as revokeAll (not-yet-expired, any status) minus the kept session.
|
|
67
73
|
const rows = (await this.pool.query(`SELECT s_session_id
|
|
68
|
-
FROM
|
|
74
|
+
FROM ${this.sessionTable}
|
|
69
75
|
WHERE s_principal_id = ? AND s_absolute_expires_at_ms > ? AND s_session_id <> ?`, [principalId, this.now(), keepSessionId]));
|
|
70
|
-
await this.pool.query(`UPDATE
|
|
76
|
+
await this.pool.query(`UPDATE ${this.sessionTable}
|
|
71
77
|
SET s_status = 'revoked'
|
|
72
78
|
WHERE s_principal_id = ? AND s_status = 'active' AND s_session_id <> ?`, [principalId, keepSessionId]);
|
|
73
79
|
// Only the OTHER sessions are unbound — the kept (current) session's liveness key
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cross-tenant-grant-writer.d.ts","sourceRoot":"","sources":["../../src/authz/cross-tenant-grant-writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"cross-tenant-grant-writer.d.ts","sourceRoot":"","sources":["../../src/authz/cross-tenant-grant-writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAG9E,8CAA8C;AAC9C,eAAO,MAAM,gCAAgC,eAA6C,CAAC;AAE3F,0FAA0F;AAC1F,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,CAAC;AAE/C,gFAAgF;AAChF,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG,QAAQ,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,gBAAgB,GAAG,C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O,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;gBAEvB,IAAI,EAAE;QAChB,EAAE,EAAE,cAAc,CAAC;QACnB;;;;WAIG;QACH,SAAS,EAAE,gBAAgB,CAAC;QAC5B,oFAAoF;QACpF,KAAK,CAAC,EAAE,cAAc,CAAC;QACvB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,+DAA+D;QAC/D,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC;KACtB;IAUD;;;;;;;;;OASG;IACG,KAAK,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAuEpD;;;;;;;;;OASG;IACG,MAAM,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAiDpD;;;;;;;;;OASG;IACG,MAAM,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAqDpD;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAkDxB;;;;OAIG;YACW,gBAAgB;IAU9B,uGAAuG;YACzF,UAAU;IAqBxB,mEAAmE;YACrD,IAAI;IAalB,wFAAwF;YAC1E,WAAW;CA0B1B"}
|
|
@@ -63,8 +63,7 @@
|
|
|
63
63
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64
64
|
exports.CrossTenantGrantWriter = exports.GrantStoreUnavailableError = exports.InvalidGrantError = exports.GrantNotPermittedError = exports.SHIELD_CROSS_TENANT_GRANT_WRITER = void 0;
|
|
65
65
|
const node_crypto_1 = require("node:crypto");
|
|
66
|
-
|
|
67
|
-
const DEFAULT_SCHEMA = 'shield_authz';
|
|
66
|
+
const framework_schema_names_js_1 = require("../config/framework-schema-names.js");
|
|
68
67
|
/** The DI token the writer is bound under. */
|
|
69
68
|
exports.SHIELD_CROSS_TENANT_GRANT_WRITER = Symbol('SHIELD_CROSS_TENANT_GRANT_WRITER');
|
|
70
69
|
/** Thrown when the who-may-grant bound rejects an offer/accept/revoke (fail-closed). */
|
|
@@ -122,7 +121,9 @@ class CrossTenantGrantWriter {
|
|
|
122
121
|
this.db = deps.db;
|
|
123
122
|
this.authorize = deps.authorize;
|
|
124
123
|
this.audit = deps.audit;
|
|
125
|
-
|
|
124
|
+
// The `cross_tenant_grant` database: `deps.schema` (checked), else the resolved authz name
|
|
125
|
+
// (configurable-framework-db), fixed at construction.
|
|
126
|
+
this.schema = (0, framework_schema_names_js_1.authzSchemaAtConstruction)(deps.schema);
|
|
126
127
|
this.now = deps.nowMs ?? (() => Date.now());
|
|
127
128
|
}
|
|
128
129
|
/**
|
|
@@ -107,9 +107,17 @@ export declare class UnknownScopeFieldError extends Error {
|
|
|
107
107
|
* @returns `{ sql, params }` — `sql` carries ONLY `?` + backtick columns; `params` the
|
|
108
108
|
* bound values in `?`-order.
|
|
109
109
|
* @throws {@link UnknownScopeFieldError} if any condition names an unregistered field.
|
|
110
|
+
* @throws FrameworkSchemaConfigError (core) if `opts.schema` is missing or not a safe name.
|
|
110
111
|
*/
|
|
111
|
-
export declare function translateListScope(spec: ListScopeSpec, reg: ObjectType, principal: ListScopePrincipal, opts
|
|
112
|
-
|
|
112
|
+
export declare function translateListScope(spec: ListScopeSpec, reg: ObjectType, principal: ListScopePrincipal, opts: {
|
|
113
|
+
/**
|
|
114
|
+
* REQUIRED: the authz database holding `record_share` / `cross_tenant_grant` (configurable-
|
|
115
|
+
* framework-db). No default: this pure translator runs per request and never reads env, and
|
|
116
|
+
* a silent `shield_authz` default would read another environment's grants under a namespace.
|
|
117
|
+
* The wiring (`buildListScopeFn`) passes the resolved `schemas.authz`. Checked with core
|
|
118
|
+
* `assertSchemaName` on every call (fail closed).
|
|
119
|
+
*/
|
|
120
|
+
schema: string;
|
|
113
121
|
nowMs?: () => number;
|
|
114
122
|
/**
|
|
115
123
|
* The OWNING tenant's deny AND-groups (Task 4.2 — the fail-open leak fix). Applied ONLY to
|
|
@@ -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,EAKL,KAAK,UAAU,EAChB,MAAM,gBAAgB,CAAC;
|
|
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,EAKL,KAAK,UAAU,EAChB,MAAM,gBAAgB,CAAC;AAGxB,qFAAqF;AACrF,MAAM,WAAW,mBAAmB;IAClC,kFAAkF;IAClF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;CAC5B;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;CACpC;AAED,yFAAyF;AACzF,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;CAO3C;AAmID;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,aAAa,EACnB,GAAG,EAAE,UAAU,EACf,SAAS,EAAE,kBAAkB,EAC7B,IAAI,EAAE;IACJ;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC;IACrB;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE,SAAS,CAAC,SAAS,cAAc,EAAE,CAAC,EAAE,CAAC;CAC3D,GACA,mBAAmB,CAoJrB"}
|
|
@@ -80,8 +80,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
80
80
|
exports.UnknownScopeFieldError = void 0;
|
|
81
81
|
exports.translateListScope = translateListScope;
|
|
82
82
|
const engine_1 = require("@astram/engine");
|
|
83
|
-
|
|
84
|
-
const DEFAULT_SCHEMA = 'shield_authz';
|
|
83
|
+
const core_1 = require("@astram/core");
|
|
85
84
|
/** Error thrown when a scope condition references a field the type does not register. */
|
|
86
85
|
class UnknownScopeFieldError extends Error {
|
|
87
86
|
constructor(typeKey, field) {
|
|
@@ -211,9 +210,10 @@ function translateGroups(groups, reg, principal, p) {
|
|
|
211
210
|
* @returns `{ sql, params }` — `sql` carries ONLY `?` + backtick columns; `params` the
|
|
212
211
|
* bound values in `?`-order.
|
|
213
212
|
* @throws {@link UnknownScopeFieldError} if any condition names an unregistered field.
|
|
213
|
+
* @throws FrameworkSchemaConfigError (core) if `opts.schema` is missing or not a safe name.
|
|
214
214
|
*/
|
|
215
|
-
function translateListScope(spec, reg, principal, opts
|
|
216
|
-
const schema = opts
|
|
215
|
+
function translateListScope(spec, reg, principal, opts) {
|
|
216
|
+
const schema = (0, core_1.assertSchemaName)(opts?.schema, 'translateListScope opts.schema');
|
|
217
217
|
// The cross-tenant expiry filter binds THIS clock's epoch-ms against the BIGINT
|
|
218
218
|
// `ctg_expires_at_ms` column — timezone-immune (mirrors MariaDbCrossTenantGrantAdapter's
|
|
219
219
|
// injectable clock). Injectable for deterministic tests.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mariadb-cross-tenant-grant-adapter.d.ts","sourceRoot":"","sources":["../../src/authz/mariadb-cross-tenant-grant-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;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B,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAkCtB"}
|
|
@@ -69,10 +69,9 @@
|
|
|
69
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
70
|
exports.MariaDbCrossTenantGrantAdapter = exports.SHIELD_CROSS_TENANT_GRANT_PORT = void 0;
|
|
71
71
|
const core_1 = require("@astram/core");
|
|
72
|
+
const framework_schema_names_js_1 = require("../config/framework-schema-names.js");
|
|
72
73
|
/** The DI token the adapter is bound under (parity with the share/rule-port tokens). */
|
|
73
74
|
exports.SHIELD_CROSS_TENANT_GRANT_PORT = Symbol('SHIELD_CROSS_TENANT_GRANT_PORT');
|
|
74
|
-
/** Schema the `cross_tenant_grant` table lives in (astram3 ships the migration). */
|
|
75
|
-
const DEFAULT_SCHEMA = 'shield_authz';
|
|
76
75
|
/**
|
|
77
76
|
* Parse `ctg_allowed_actions` to a `string[]`. ⚠️ The `ctg_allowed_actions` column is a JSON
|
|
78
77
|
* column, and the mariadb driver AUTO-PARSES it into a JS ARRAY on read — so `raw` is ALREADY an
|
|
@@ -123,7 +122,9 @@ class MariaDbCrossTenantGrantAdapter {
|
|
|
123
122
|
now;
|
|
124
123
|
constructor(db, opts = {}) {
|
|
125
124
|
this.db = db;
|
|
126
|
-
|
|
125
|
+
// The `cross_tenant_grant` database: `opts.schema` (checked), else the resolved authz name
|
|
126
|
+
// (configurable-framework-db), fixed at construction.
|
|
127
|
+
this.schema = (0, framework_schema_names_js_1.authzSchemaAtConstruction)(opts.schema);
|
|
127
128
|
// The expiry filter binds THIS clock's epoch-ms against the BIGINT `ctg_expires_at_ms`
|
|
128
129
|
// column — timezone-immune (no Date/`NOW()` skew). Injectable for deterministic tests.
|
|
129
130
|
this.now = opts.nowMs ?? (() => Date.now());
|
|
@@ -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;AAItB,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;AAoCD;;;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"}
|
|
@@ -43,10 +43,9 @@
|
|
|
43
43
|
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
|
+
const framework_schema_names_js_1 = require("../config/framework-schema-names.js");
|
|
46
47
|
/** The DI token the adapter is bound under (parity with the rule-port token). */
|
|
47
48
|
exports.SHIELD_LIST_SCOPE_PORT = Symbol('SHIELD_LIST_SCOPE_PORT');
|
|
48
|
-
/** Schema the `record_permission_rule` table lives in (framework migration ...009). */
|
|
49
|
-
const DEFAULT_SCHEMA = 'shield_authz';
|
|
50
49
|
/**
|
|
51
50
|
* Whether a rule group's SUBJECT matches the requesting principal — the EXACT mirror of the
|
|
52
51
|
* per-record rule adapter's `subjectMatches` ({@link MariaDbRecordPermissionRuleAdapter}):
|
|
@@ -79,7 +78,9 @@ class MariaDbListScopeAdapter {
|
|
|
79
78
|
schema;
|
|
80
79
|
constructor(db, opts = {}) {
|
|
81
80
|
this.db = db;
|
|
82
|
-
|
|
81
|
+
// The `record_permission_rule` database (framework migration ...009): `opts.schema`
|
|
82
|
+
// (checked), else the resolved authz name (configurable-framework-db), fixed here.
|
|
83
|
+
this.schema = (0, framework_schema_names_js_1.authzSchemaAtConstruction)(opts.schema);
|
|
83
84
|
}
|
|
84
85
|
async listPolicyConditions(typeKey, tenantNodeIds, action, subject) {
|
|
85
86
|
// The caller's reachable subtree (active node + descendants, ADR-0027). A rule scoped to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mariadb-policy-store.d.ts","sourceRoot":"","sources":["../../src/authz/mariadb-policy-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,EAAmB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"mariadb-policy-store.d.ts","sourceRoot":"","sources":["../../src/authz/mariadb-policy-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,EAAmB,MAAM,cAAc,CAAC;AAGvF,sFAAsF;AACtF,eAAO,MAAM,mBAAmB,eAAgC,CAAC;AAEjE,kFAAkF;AAClF,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACnE;AAgCD;;;;GAIG;AACH,qBAAa,kBAAmB,YAAW,WAAW;IACpD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAgB;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAEpB,EAAE,EAAE,aAAa,EAAE,IAAI,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO;IAO7D;;;;;OAKG;IACG,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;IA4CzE;;;;OAIG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC;IAiDjF;;;;OAIG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQnD;;;;;;;;;;OAUG;IACG,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CASjF"}
|
|
@@ -69,10 +69,9 @@
|
|
|
69
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
70
|
exports.MariaDbPolicyStore = exports.SHIELD_POLICY_STORE = void 0;
|
|
71
71
|
const node_crypto_1 = require("node:crypto");
|
|
72
|
+
const framework_schema_names_js_1 = require("../config/framework-schema-names.js");
|
|
72
73
|
/** The DI token the policy store is bound under (parity with the rule-port token). */
|
|
73
74
|
exports.SHIELD_POLICY_STORE = Symbol('SHIELD_POLICY_STORE');
|
|
74
|
-
/** Schema the `record_permission_rule` table lives in (framework migration ...009). */
|
|
75
|
-
const DEFAULT_SCHEMA = 'shield_authz';
|
|
76
75
|
/**
|
|
77
76
|
* The operators that take NO operand (the read adapter ignores `rpr_value` for
|
|
78
77
|
* these). Their conditions persist `rpr_value = NULL` so a round-trip yields the
|
|
@@ -103,7 +102,9 @@ class MariaDbPolicyStore {
|
|
|
103
102
|
schema;
|
|
104
103
|
constructor(db, opts = {}) {
|
|
105
104
|
this.db = db;
|
|
106
|
-
|
|
105
|
+
// The `record_permission_rule` database (framework migration ...009): `opts.schema`
|
|
106
|
+
// (checked), else the resolved authz name (configurable-framework-db), fixed here.
|
|
107
|
+
this.schema = (0, framework_schema_names_js_1.authzSchemaAtConstruction)(opts.schema);
|
|
107
108
|
}
|
|
108
109
|
/**
|
|
109
110
|
* Persist a guided policy as N `record_permission_rule` rows (ONE row for a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mariadb-record-rule-adapter.d.ts","sourceRoot":"","sources":["../../src/authz/mariadb-record-rule-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"mariadb-record-rule-adapter.d.ts","sourceRoot":"","sources":["../../src/authz/mariadb-record-rule-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAI1F,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;AAmLD;;;GAGG;AACH,qBAAa,kCAAmC,YAAW,wBAAwB;IACjF,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAgB;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAEpB,EAAE,EAAE,aAAa,EAAE,IAAI,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO;IAOvD,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC;CAuE5D"}
|
|
@@ -46,10 +46,9 @@
|
|
|
46
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
47
|
exports.MariaDbRecordPermissionRuleAdapter = exports.SHIELD_RECORD_RULE_PORT = void 0;
|
|
48
48
|
const core_1 = require("@astram/core");
|
|
49
|
+
const framework_schema_names_js_1 = require("../config/framework-schema-names.js");
|
|
49
50
|
/** The DI token the adapter is bound under (parity with the session store token). */
|
|
50
51
|
exports.SHIELD_RECORD_RULE_PORT = Symbol('SHIELD_RECORD_RULE_PORT');
|
|
51
|
-
/** Schema the `record_permission_rule` table lives in (astram3 ships the migration). */
|
|
52
|
-
const DEFAULT_SCHEMA = 'shield_authz';
|
|
53
52
|
/** Whether the rule's subject matches this principal (role membership / everyone). */
|
|
54
53
|
function subjectMatches(row, input) {
|
|
55
54
|
const kind = row.rpr_subject_kind;
|
|
@@ -222,7 +221,9 @@ class MariaDbRecordPermissionRuleAdapter {
|
|
|
222
221
|
schema;
|
|
223
222
|
constructor(db, opts = {}) {
|
|
224
223
|
this.db = db;
|
|
225
|
-
|
|
224
|
+
// The `record_permission_rule` database: `opts.schema` (checked), else the resolved authz
|
|
225
|
+
// name (configurable-framework-db), fixed at construction.
|
|
226
|
+
this.schema = (0, framework_schema_names_js_1.authzSchemaAtConstruction)(opts.schema);
|
|
226
227
|
}
|
|
227
228
|
async evaluate(input) {
|
|
228
229
|
// tenant scoping: match rows for the resource's tenant OR the global/system baseline
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mariadb-record-share-adapter.d.ts","sourceRoot":"","sources":["../../src/authz/mariadb-record-share-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"mariadb-record-share-adapter.d.ts","sourceRoot":"","sources":["../../src/authz/mariadb-record-share-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD,iFAAiF;AACjF,eAAO,MAAM,wBAAwB,eAAqC,CAAC;AAE3E,oFAAoF;AACpF,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACnE;AAOD;;;GAGG;AACH,qBAAa,yBAA0B,YAAW,eAAe;IAC/D,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAiB;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAEpB,EAAE,EAAE,cAAc,EAAE,IAAI,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO;IAOxD,QAAQ,CACZ,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,CAAC;CAqCpB"}
|
|
@@ -57,10 +57,9 @@
|
|
|
57
57
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
58
|
exports.MariaDbRecordShareAdapter = exports.SHIELD_RECORD_SHARE_PORT = void 0;
|
|
59
59
|
const core_1 = require("@astram/core");
|
|
60
|
+
const framework_schema_names_js_1 = require("../config/framework-schema-names.js");
|
|
60
61
|
/** The DI token the adapter is bound under (parity with the rule-port token). */
|
|
61
62
|
exports.SHIELD_RECORD_SHARE_PORT = Symbol('SHIELD_RECORD_SHARE_PORT');
|
|
62
|
-
/** Schema the `record_share` table lives in (astram3 ships the migration). */
|
|
63
|
-
const DEFAULT_SCHEMA = 'shield_authz';
|
|
64
63
|
/**
|
|
65
64
|
* The concrete per-record share adapter. Answers `hasShare` from `record_share`, matching
|
|
66
65
|
* user- and role-granted shares with exact-or-wildcard action.
|
|
@@ -70,7 +69,9 @@ class MariaDbRecordShareAdapter {
|
|
|
70
69
|
schema;
|
|
71
70
|
constructor(db, opts = {}) {
|
|
72
71
|
this.db = db;
|
|
73
|
-
|
|
72
|
+
// The `record_share` database: `opts.schema` (checked), else the resolved authz name
|
|
73
|
+
// (configurable-framework-db), fixed at construction.
|
|
74
|
+
this.schema = (0, framework_schema_names_js_1.authzSchemaAtConstruction)(opts.schema);
|
|
74
75
|
}
|
|
75
76
|
async hasShare(principalId, roleIds, typeKey, recordId, action) {
|
|
76
77
|
// Grantee predicate: the user share OR (only when roles exist) a role share. The role
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record-share-cascade.d.ts","sourceRoot":"","sources":["../../src/authz/record-share-cascade.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;
|
|
1
|
+
{"version":3,"file":"record-share-cascade.d.ts","sourceRoot":"","sources":["../../src/authz/record-share-cascade.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAIH;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAE1F;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAC9B,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,KACb,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,iBAAiB,CAgBxF"}
|
|
@@ -32,8 +32,7 @@
|
|
|
32
32
|
*/
|
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
34
|
exports.makeShareDeleteCascade = makeShareDeleteCascade;
|
|
35
|
-
|
|
36
|
-
const DEFAULT_SCHEMA = 'shield_authz';
|
|
35
|
+
const framework_schema_names_js_1 = require("../config/framework-schema-names.js");
|
|
37
36
|
/**
|
|
38
37
|
* Build the delete-cascade function (a {@link RecordDeletedHook}) the consumer wires into
|
|
39
38
|
* the engine as `onRecordDeleted`. Removes a deleted record's `record_share` rows,
|
|
@@ -41,7 +40,9 @@ const DEFAULT_SCHEMA = 'shield_authz';
|
|
|
41
40
|
* no pool — the query fn is supplied by the engine on every call.
|
|
42
41
|
*/
|
|
43
42
|
function makeShareDeleteCascade(opts = {}) {
|
|
44
|
-
|
|
43
|
+
// The `record_share` database: explicit, else the resolved authz name, fixed here at build
|
|
44
|
+
// time (configurable-framework-db) — the hook itself never reads env.
|
|
45
|
+
const schema = (0, framework_schema_names_js_1.authzSchemaAtConstruction)(opts.schema);
|
|
45
46
|
return async (query, typeKey, recordId, tenantId) => {
|
|
46
47
|
await query(`DELETE FROM \`${schema}\`.\`record_share\`` +
|
|
47
48
|
` WHERE rs_tenant_uuid = ? AND rs_type_key = ? AND rs_record_uuid = ?`, [tenantId, typeKey, recordId]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record-share-writer.d.ts","sourceRoot":"","sources":["../../src/authz/record-share-writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"record-share-writer.d.ts","sourceRoot":"","sources":["../../src/authz/record-share-writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAGxE,8CAA8C;AAC9C,eAAO,MAAM,0BAA0B,eAAuC,CAAC;AAE/E,4DAA4D;AAC5D,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,2BAA2B;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,4CAA4C;IAC5C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,6FAA6F;IAC7F,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,0FAA0F;IAC1F,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAAC;CACrD;AAED,6FAA6F;AAC7F,MAAM,WAAW,eAAe;IAC9B,+BAA+B;IAC/B,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,8BAA8B;IAC9B,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,CAAC;IACnD,mCAAmC;IACnC,QA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AAC,EAAE,CAAiB;IACpC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoB;IAC1C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA6B;IACnD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;gBAEvB,IAAI,EAAE;QAChB,EAAE,EAAE,cAAc,CAAC;QACnB,KAAK,EAAE,iBAAiB,CAAC;QACzB,kFAAkF;QAClF,KAAK,CAAC,EAAE,cAAc,CAAC;QACvB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,+DAA+D;QAC/D,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC;KACtB;IAUD;;;;;;;;OAQG;IACG,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IA8B7C;;;;OAIG;IACG,OAAO,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IA4B/C;;;;;;;;;;OAUG;IACG,mBAAmB,CAAC,KAAK,EAAE;QAC/B,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CACT,aAAa,CAAC;QACZ,WAAW,EAAE,gBAAgB,CAAC;QAC9B,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC,CACH;IA0CD;;;;OAIG;YACW,cAAc;IAoC5B;;;;OAIG;YACW,sBAAsB;IA6BpC,OAAO,CAAC,cAAc;IAItB,sFAAsF;YACxE,IAAI;CAsBnB"}
|
|
@@ -42,8 +42,7 @@
|
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
43
|
exports.RecordShareWriter = exports.ShareStoreUnavailableError = exports.ShareNotPermittedError = exports.SHIELD_RECORD_SHARE_WRITER = void 0;
|
|
44
44
|
const node_crypto_1 = require("node:crypto");
|
|
45
|
-
|
|
46
|
-
const DEFAULT_SCHEMA = 'shield_authz';
|
|
45
|
+
const framework_schema_names_js_1 = require("../config/framework-schema-names.js");
|
|
47
46
|
/** The DI token the writer is bound under. */
|
|
48
47
|
exports.SHIELD_RECORD_SHARE_WRITER = Symbol('SHIELD_RECORD_SHARE_WRITER');
|
|
49
48
|
/** Thrown when the who-may-share bound rejects a share/unshare (fail-closed). */
|
|
@@ -72,7 +71,9 @@ class RecordShareWriter {
|
|
|
72
71
|
this.db = deps.db;
|
|
73
72
|
this.types = deps.types;
|
|
74
73
|
this.audit = deps.audit;
|
|
75
|
-
|
|
74
|
+
// The `record_share` database: `deps.schema` (checked), else the resolved authz name
|
|
75
|
+
// (configurable-framework-db), fixed at construction.
|
|
76
|
+
this.schema = (0, framework_schema_names_js_1.authzSchemaAtConstruction)(deps.schema);
|
|
76
77
|
this.now = deps.nowMs ?? (() => Date.now());
|
|
77
78
|
}
|
|
78
79
|
/**
|
|
@@ -27,6 +27,7 @@ import type { DecisionAuthority, ModuleRegistry, PermissionFactsPort, Principal,
|
|
|
27
27
|
import type { PermissionVersionReader } from './permission-version-cache.js';
|
|
28
28
|
import type { ObjectType } from '@astram/engine';
|
|
29
29
|
import { type RuleQueryable } from './mariadb-record-rule-adapter.js';
|
|
30
|
+
import { type FrameworkSchemaNames } from '../config/framework-schema-names.js';
|
|
30
31
|
import { type OperationManifestEntry } from './manifest-operation-authority-adapter.js';
|
|
31
32
|
/**
|
|
32
33
|
* The pieces a consumer supplies for the framework to build the real record-tier
|
|
@@ -57,6 +58,13 @@ export interface RecordAuthorizationInputs {
|
|
|
57
58
|
* ENTRIES; the framework owns the ADAPTER.
|
|
58
59
|
*/
|
|
59
60
|
readonly operationManifest?: readonly OperationManifestEntry[];
|
|
61
|
+
/**
|
|
62
|
+
* The resolved framework database names (configurable-framework-db, ADR-0037): every
|
|
63
|
+
* framework-built adapter reads `schemas.authz`. Inject `FRAMEWORK_SCHEMAS`. Absent ⇒ resolved
|
|
64
|
+
* from `SHIELD_DB_NAMESPACE` once, when the authority / list fn is built (never per request);
|
|
65
|
+
* `ShieldModule` fills it from `AppConfig.schemas` when the inputs omit it.
|
|
66
|
+
*/
|
|
67
|
+
readonly schemas?: FrameworkSchemaNames;
|
|
60
68
|
}
|
|
61
69
|
/**
|
|
62
70
|
* Construct the four framework-owned record-tier adapters over the supplied pool +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire-record-authorization.d.ts","sourceRoot":"","sources":["../../src/authz/wire-record-authorization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EAEd,mBAAmB,EACnB,SAAS,EAET,kBAAkB,EACnB,MAAM,cAAc,CAAC;AAMtB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,kCAAkC,CAAC;AAM1C,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,2CAA2C,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,uFAAuF;IACvF,QAAQ,CAAC,eAAe,EAAE,mBAAmB,CAAC;IAC9C,6FAA6F;IAC7F,QAAQ,CAAC,YAAY,EAAE,kBAAkB,CAAC;IAC1C,6GAA6G;IAC7G,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC;;;;;OAKG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,sBAAsB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"wire-record-authorization.d.ts","sourceRoot":"","sources":["../../src/authz/wire-record-authorization.ts"],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GAC5C,iBAAiB,CA4BnB;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,WAAW,GAAG,CACxB,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,MAAM,KACX,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,EAAE,CAAA;CAAE,CAAC,CAAC;AAEjD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,yBAAyB,GAAG,WAAW,CAyE/E"}
|
|
@@ -10,7 +10,12 @@ const mariadb_cross_tenant_grant_adapter_js_1 = require("./mariadb-cross-tenant-
|
|
|
10
10
|
const mariadb_list_scope_adapter_js_1 = require("./mariadb-list-scope-adapter.js");
|
|
11
11
|
const list_scope_sql_js_1 = require("./list-scope-sql.js");
|
|
12
12
|
const session_facts_als_js_1 = require("../request-auth/session-facts-als.js");
|
|
13
|
+
const framework_schema_names_js_1 = require("../config/framework-schema-names.js");
|
|
13
14
|
const manifest_operation_authority_adapter_js_1 = require("./manifest-operation-authority-adapter.js");
|
|
15
|
+
/** The authz database the framework-built adapters read: `inputs.schemas`, else resolved now. */
|
|
16
|
+
function authzSchemaOf(inputs) {
|
|
17
|
+
return (0, framework_schema_names_js_1.schemaNamesAtConstruction)(inputs.schemas).authz;
|
|
18
|
+
}
|
|
14
19
|
/**
|
|
15
20
|
* Construct the four framework-owned record-tier adapters over the supplied pool +
|
|
16
21
|
* manifest, and return the fully-wired core {@link DecisionAuthority}. Behavior-identical
|
|
@@ -65,6 +70,7 @@ function buildRecordAuthorization(inputs, options = {}) {
|
|
|
65
70
|
const facts = options.versionCache !== undefined
|
|
66
71
|
? withRedisPermissionVersion(inputs.permissionFacts, options.versionCache)
|
|
67
72
|
: inputs.permissionFacts;
|
|
73
|
+
const schema = authzSchemaOf(inputs);
|
|
68
74
|
return (0, core_1.createWiredDecisionAuthority)({
|
|
69
75
|
registry: inputs.registry,
|
|
70
76
|
// The app-owned port, wrapped so a gate-5 reload inside an enforcement request notifies the
|
|
@@ -76,13 +82,13 @@ function buildRecordAuthorization(inputs, options = {}) {
|
|
|
76
82
|
// ── The FOUR framework-owned record-tier adapters — constructed HERE, and ONLY here.
|
|
77
83
|
// Record-permit ADMIN rules over `shield_authz.record_permission_rule` (widen the
|
|
78
84
|
// core-owned owner baseline, deny-wins). Empty table ⇒ owner-only (NOT a lockout).
|
|
79
|
-
recordRule: new mariadb_record_rule_adapter_js_1.MariaDbRecordPermissionRuleAdapter(inputs.pool),
|
|
85
|
+
recordRule: new mariadb_record_rule_adapter_js_1.MariaDbRecordPermissionRuleAdapter(inputs.pool, { schema }),
|
|
80
86
|
// Per-record SHARE source over `shield_authz.record_share` (widening permit, union
|
|
81
87
|
// with baseline under deny-wins). No share ⇒ false (baseline still governs).
|
|
82
|
-
recordShare: new mariadb_record_share_adapter_js_1.MariaDbRecordShareAdapter(inputs.pool),
|
|
88
|
+
recordShare: new mariadb_record_share_adapter_js_1.MariaDbRecordShareAdapter(inputs.pool, { schema }),
|
|
83
89
|
// Cross-tenant consented grants over `shield_authz.cross_tenant_grant`. No active
|
|
84
90
|
// grant ⇒ null (deny-by-default for the cross-tenant reach).
|
|
85
|
-
crossTenantGrant: new mariadb_cross_tenant_grant_adapter_js_1.MariaDbCrossTenantGrantAdapter(inputs.pool),
|
|
91
|
+
crossTenantGrant: new mariadb_cross_tenant_grant_adapter_js_1.MariaDbCrossTenantGrantAdapter(inputs.pool, { schema }),
|
|
86
92
|
// Delegation / trusted-operation authority over the DECLARED manifest (no DB).
|
|
87
93
|
// Empty ⇒ pass-through. The app supplies the entries; the framework owns the adapter.
|
|
88
94
|
operationAuthority: new manifest_operation_authority_adapter_js_1.ManifestOperationAuthorityAdapter(inputs.operationManifest ?? []),
|
|
@@ -107,13 +113,15 @@ function buildRecordAuthorization(inputs, options = {}) {
|
|
|
107
113
|
* unknown-field rejection) PROPAGATES so the read fails, NEVER falls open to unbounded.
|
|
108
114
|
*/
|
|
109
115
|
function buildListScopeFn(inputs) {
|
|
116
|
+
// The authz database, resolved ONCE here (build time) and captured by the per-request fn.
|
|
117
|
+
const schema = authzSchemaOf(inputs);
|
|
110
118
|
// Framework-constructed over `inputs.pool` — UN-overridable (not a field of the inputs).
|
|
111
|
-
const listScopePort = new mariadb_list_scope_adapter_js_1.MariaDbListScopeAdapter(inputs.pool);
|
|
119
|
+
const listScopePort = new mariadb_list_scope_adapter_js_1.MariaDbListScopeAdapter(inputs.pool, { schema });
|
|
112
120
|
// The cross-tenant grant adapter — reused HERE to resolve the OWNING tenants a grantee
|
|
113
121
|
// reaches, so the list can apply the OWNING tenant's deny rules to the cross-tenant branch
|
|
114
122
|
// (deny-wins per the resource's tenant — the fail-open leak the Phase-4 review found). Same
|
|
115
123
|
// un-overridable `inputs.pool`.
|
|
116
|
-
const crossTenantAdapter = new mariadb_cross_tenant_grant_adapter_js_1.MariaDbCrossTenantGrantAdapter(inputs.pool);
|
|
124
|
+
const crossTenantAdapter = new mariadb_cross_tenant_grant_adapter_js_1.MariaDbCrossTenantGrantAdapter(inputs.pool, { schema });
|
|
117
125
|
return async (reg, actor, action) => {
|
|
118
126
|
// Bridge the engine `ObjectType` → the core `ComputeListScopeDeps.registry` shape.
|
|
119
127
|
// `computeListScope` reads ONLY `descriptor.access` for the owner-baseline posture
|
|
@@ -156,7 +164,7 @@ function buildListScopeFn(inputs) {
|
|
|
156
164
|
}
|
|
157
165
|
// Translate the abstract spec → SAFE parameterized WHERE fragment. An unknown-field
|
|
158
166
|
// rejection here also PROPAGATES (fail-closed).
|
|
159
|
-
const translated = (0, list_scope_sql_js_1.translateListScope)(spec, reg, { principalId: actor.id, principalTenantId: actor.tenantId }, { owningTenantDeny });
|
|
167
|
+
const translated = (0, list_scope_sql_js_1.translateListScope)(spec, reg, { principalId: actor.id, principalTenantId: actor.tenantId }, { owningTenantDeny, schema });
|
|
160
168
|
return { sql: translated.sql, params: translated.params };
|
|
161
169
|
};
|
|
162
170
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type OnApplicationBootstrap } from '@nestjs/common';
|
|
2
|
+
import type { FrameworkSchemas } from '@astram/core';
|
|
2
3
|
import { type AppConfig, type PoolBudgetConfig } from '../config/app-config.js';
|
|
3
4
|
/**
|
|
4
5
|
* Boot sequence extension point (Infrastructure layer — ADR-0018).
|
|
@@ -17,6 +18,7 @@ import { type AppConfig, type PoolBudgetConfig } from '../config/app-config.js';
|
|
|
17
18
|
*/
|
|
18
19
|
export declare class BootSequence implements OnApplicationBootstrap {
|
|
19
20
|
private readonly config;
|
|
21
|
+
private readonly logger;
|
|
20
22
|
constructor(config: AppConfig);
|
|
21
23
|
onApplicationBootstrap(): Promise<void>;
|
|
22
24
|
/**
|
|
@@ -31,6 +33,8 @@ export declare class BootSequence implements OnApplicationBootstrap {
|
|
|
31
33
|
*/
|
|
32
34
|
private assertConnectionPoolReady;
|
|
33
35
|
}
|
|
36
|
+
/** The boot log line naming the resolved framework databases (names only, spec 5.E). */
|
|
37
|
+
export declare function frameworkDatabasesLogLine(s: FrameworkSchemas): string;
|
|
34
38
|
/**
|
|
35
39
|
* Validate a {@link PoolBudgetConfig} against the ADR-0018 budget. Exported so
|
|
36
40
|
* unit tests can assert the throw/no-throw contract directly without booting
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boot-sequence.d.ts","sourceRoot":"","sources":["../../src/boot/boot-sequence.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"boot-sequence.d.ts","sourceRoot":"","sources":["../../src/boot/boot-sequence.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACzF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;;GAcG;AACH,qBACa,YAAa,YAAW,sBAAsB;IAGzB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFvD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwB;gBAEE,MAAM,EAAE,SAAS;IAE5D,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAU7C;;;;;;;;;OASG;YACW,yBAAyB;CAIxC;AAED,wFAAwF;AACxF,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAKrE;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,gBAAgB,GAAG,IAAI,CAuB5D"}
|
|
@@ -13,6 +13,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.BootSequence = void 0;
|
|
16
|
+
exports.frameworkDatabasesLogLine = frameworkDatabasesLogLine;
|
|
16
17
|
exports.assertPoolBudget = assertPoolBudget;
|
|
17
18
|
const common_1 = require("@nestjs/common");
|
|
18
19
|
const config_module_js_1 = require("../config/config.module.js");
|
|
@@ -34,12 +35,18 @@ const app_config_js_1 = require("../config/app-config.js");
|
|
|
34
35
|
*/
|
|
35
36
|
let BootSequence = class BootSequence {
|
|
36
37
|
config;
|
|
38
|
+
logger = new common_1.Logger('Shield');
|
|
37
39
|
constructor(config) {
|
|
38
40
|
this.config = config;
|
|
39
41
|
}
|
|
40
42
|
async onApplicationBootstrap() {
|
|
43
|
+
// configurable-framework-db spec 5.E: the resolved database names, once per boot. Names
|
|
44
|
+
// only — never a user, password, host or connection string.
|
|
45
|
+
this.logger.log(frameworkDatabasesLogLine((0, app_config_js_1.frameworkSchemasOf)(this.config)));
|
|
41
46
|
await this.assertConnectionPoolReady();
|
|
42
|
-
// Future boot-time assertions attach here (each fail-closed).
|
|
47
|
+
// Future boot-time assertions attach here (each fail-closed). The migration ledger check
|
|
48
|
+
// (spec 5.D) needs the runtime pool, so it runs from AuthModule (`auth: true`) and from
|
|
49
|
+
// IdentityFeatureModule: see ./migration-ledger-check.ts.
|
|
43
50
|
}
|
|
44
51
|
/**
|
|
45
52
|
* ADR-0018: assert the configured connection-pool budget fits under the DB
|
|
@@ -62,6 +69,11 @@ exports.BootSequence = BootSequence = __decorate([
|
|
|
62
69
|
__param(0, (0, common_1.Inject)(config_module_js_1.APP_CONFIG)),
|
|
63
70
|
__metadata("design:paramtypes", [Object])
|
|
64
71
|
], BootSequence);
|
|
72
|
+
/** The boot log line naming the resolved framework databases (names only, spec 5.E). */
|
|
73
|
+
function frameworkDatabasesLogLine(s) {
|
|
74
|
+
return (`Shield databases: namespace=${s.namespace} app=${s.app} identity=${s.identity} ` +
|
|
75
|
+
`authz=${s.authz} audit=${s.audit}`);
|
|
76
|
+
}
|
|
65
77
|
/**
|
|
66
78
|
* Validate a {@link PoolBudgetConfig} against the ADR-0018 budget. Exported so
|
|
67
79
|
* unit tests can assert the throw/no-throw contract directly without booting
|