@nodii/dsar 0.16.0 → 0.18.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/bind-pattern-a.d.ts +6 -19
- package/dist/bind-pattern-a.d.ts.map +1 -1
- package/dist/bind-pattern-a.js +97 -30
- package/dist/bind-pattern-a.js.map +1 -1
- package/dist/bind-pattern-b.d.ts.map +1 -1
- package/dist/bind-pattern-b.js +6 -3
- package/dist/bind-pattern-b.js.map +1 -1
- package/dist/hold-failure-mode.d.ts +116 -18
- package/dist/hold-failure-mode.d.ts.map +1 -1
- package/dist/hold-failure-mode.js +230 -27
- package/dist/hold-failure-mode.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -6
- package/dist/index.js.map +1 -1
- package/dist/migrations/index.d.ts +42 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +311 -0
- package/dist/migrations/index.js.map +1 -1
- package/dist/orchestrator.d.ts +11 -16
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +127 -47
- package/dist/orchestrator.js.map +1 -1
- package/dist/state-store/postgres-lifecycle.d.ts +29 -0
- package/dist/state-store/postgres-lifecycle.d.ts.map +1 -1
- package/dist/state-store/postgres-lifecycle.js +54 -0
- package/dist/state-store/postgres-lifecycle.js.map +1 -1
- package/dist/types.d.ts +21 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +4 -4
package/dist/migrations/index.js
CHANGED
|
@@ -381,6 +381,306 @@ $do$;`;
|
|
|
381
381
|
export function getDsarMigrationSQL() {
|
|
382
382
|
return DSAR_MIGRATION_SQL;
|
|
383
383
|
}
|
|
384
|
+
/**
|
|
385
|
+
* THE DELIVERY UNIT — byte-equal inlined copy of `SESSION_FENCE_BOOTSTRAP_SQL`
|
|
386
|
+
* from `@nodii/db-rls`: the `auth.session_tenant_ids()` resolver that the
|
|
387
|
+
* policies below reference, plus the `auth.assert_tenant_fence()` gate.
|
|
388
|
+
*
|
|
389
|
+
* WHY THIS PACKAGE INSTALLS IT RATHER THAN DEMANDING SOMEBODY ELSE DID.
|
|
390
|
+
*
|
|
391
|
+
* The previous revision only CHECKED (`SESSION_RESOLVER_PRECONDITION_SQL`) and
|
|
392
|
+
* refused to migrate when the resolver was absent. That was correct as far as
|
|
393
|
+
* it went — it turned a silent, destructive half-migration into a clean refusal
|
|
394
|
+
* — but it left the service unable to boot, with no path to fix itself.
|
|
395
|
+
*
|
|
396
|
+
* There is no such path for most of the fleet. Measured, not assumed: of the
|
|
397
|
+
* ten services that call neither `applyAuthSchemaMigrations` nor
|
|
398
|
+
* `authSchemaHelpers`, SIX (billing, kyc, notification, task-tracking, tenant,
|
|
399
|
+
* geo) have NO database step in `deploy-dev.yml` at all — their `db:setup`
|
|
400
|
+
* runs only in `ci.yml`, against a throwaway Postgres. And a fleet-wide grep
|
|
401
|
+
* for `session_tenant_ids` across every service's vendored infra SQL returns
|
|
402
|
+
* ZERO files. So a refusal here is a service that cannot start and cannot be
|
|
403
|
+
* repaired by any pipeline that exists.
|
|
404
|
+
*
|
|
405
|
+
* Meanwhile THIS function already runs at boot in billing (`src/lib/bootstrap
|
|
406
|
+
* .ts`) and task-tracking (`src/bootstrap.ts`), against the real database, with
|
|
407
|
+
* owner privileges, immediately before the policies that need the resolver.
|
|
408
|
+
* That makes it the only reliable delivery channel these services have — so it
|
|
409
|
+
* delivers, rather than complaining that nobody else did.
|
|
410
|
+
*
|
|
411
|
+
* INLINED as a string constant, deliberately, so the published package carries
|
|
412
|
+
* NO dependency on `@nodii/db-rls` — the same posture as every other DDL
|
|
413
|
+
* constant in this module. The copy is asserted byte-equal to the db-rls
|
|
414
|
+
* original by `tests/fence-bootstrap-parity.test.ts`; it is not kept in step by
|
|
415
|
+
* anyone remembering to.
|
|
416
|
+
*
|
|
417
|
+
* SELF-CLASSIFYING. It installs the STRICT body where a real membership helper
|
|
418
|
+
* exists and the DEGRADED (fence-only, D415) body where `auth.user_tenant_ids`
|
|
419
|
+
* is absent or still the bootstrap stub. That distinction is derived from the
|
|
420
|
+
* catalog on every run, never from a per-service list — a list of exactly this
|
|
421
|
+
* kind was already wrong by six services on its first pass. It can upgrade
|
|
422
|
+
* degraded to strict once a mirror lands; it can never downgrade strict to
|
|
423
|
+
* degraded.
|
|
424
|
+
*/
|
|
425
|
+
export const SESSION_FENCE_BOOTSTRAP_SQL = `CREATE SCHEMA IF NOT EXISTS auth;
|
|
426
|
+
DO $fence_install$
|
|
427
|
+
DECLARE
|
|
428
|
+
v_src text;
|
|
429
|
+
v_is_stub boolean;
|
|
430
|
+
BEGIN
|
|
431
|
+
SELECT p.prosrc INTO v_src
|
|
432
|
+
FROM pg_proc p
|
|
433
|
+
JOIN pg_namespace n ON n.oid = p.pronamespace
|
|
434
|
+
WHERE n.nspname = 'auth' AND p.proname = 'user_tenant_ids'
|
|
435
|
+
LIMIT 1;
|
|
436
|
+
|
|
437
|
+
-- Structural, not an exact-string compare: the bootstrap stub is
|
|
438
|
+
-- \`SELECT NULL::uuid WHERE false\` — an unsatisfiable WHERE and no FROM. A
|
|
439
|
+
-- reformatted or re-indented copy of the same dead body still classifies as a
|
|
440
|
+
-- stub. Mirrors isStubMembershipHelper() in tenant-fence.ts exactly; the two
|
|
441
|
+
-- are asserted equivalent in the test-suite so a fix to one cannot leave the
|
|
442
|
+
-- other behind.
|
|
443
|
+
v_is_stub := v_src IS NULL
|
|
444
|
+
OR (v_src ~* 'where\\s+false' AND v_src !~* 'from\\s+\\w');
|
|
445
|
+
|
|
446
|
+
IF v_is_stub THEN
|
|
447
|
+
EXECUTE $fence_degraded$CREATE OR REPLACE FUNCTION auth.session_tenant_ids() RETURNS SETOF uuid
|
|
448
|
+
LANGUAGE plpgsql STABLE SECURITY DEFINER
|
|
449
|
+
SET search_path = pg_catalog, public, pg_temp
|
|
450
|
+
AS $session$
|
|
451
|
+
DECLARE
|
|
452
|
+
v_tenant uuid;
|
|
453
|
+
BEGIN
|
|
454
|
+
-- DB_RLS_DEGRADED_NO_MEMBERSHIP_MIRROR: no membership mirror in this service,
|
|
455
|
+
-- so the session tenant is accepted WITHOUT proving the principal holds it.
|
|
456
|
+
-- Replace with the strict resolver as soon as a mirror exists.
|
|
457
|
+
IF nullif(current_setting('app.user_id', true), '') IS NULL THEN
|
|
458
|
+
RAISE EXCEPTION 'db_rls_session_user_missing: app.user_id is not bound on this connection'
|
|
459
|
+
USING ERRCODE = '42501',
|
|
460
|
+
HINT = 'Open the session with withUserContext({ userId, tenantId }, fn) from @nodii/db-rls.';
|
|
461
|
+
END IF;
|
|
462
|
+
v_tenant := nullif(current_setting('app.tenant_id', true), '')::uuid;
|
|
463
|
+
IF v_tenant IS NULL THEN
|
|
464
|
+
RAISE EXCEPTION 'db_rls_session_tenant_missing: app.tenant_id is not bound on this connection'
|
|
465
|
+
USING ERRCODE = '42501',
|
|
466
|
+
HINT = 'Every authenticated-pool session must be EXPLICITLY tenant-scoped. Open it with withUserContext({ userId, tenantId }, fn) from @nodii/db-rls.';
|
|
467
|
+
END IF;
|
|
468
|
+
RETURN QUERY SELECT v_tenant;
|
|
469
|
+
END
|
|
470
|
+
$session$;$fence_degraded$;
|
|
471
|
+
ELSE
|
|
472
|
+
EXECUTE $fence_strict$CREATE OR REPLACE FUNCTION auth.session_tenant_ids() RETURNS SETOF uuid
|
|
473
|
+
LANGUAGE plpgsql STABLE SECURITY DEFINER
|
|
474
|
+
SET search_path = pg_catalog, public, pg_temp
|
|
475
|
+
AS $session$
|
|
476
|
+
DECLARE
|
|
477
|
+
v_user uuid;
|
|
478
|
+
v_tenant uuid;
|
|
479
|
+
BEGIN
|
|
480
|
+
v_user := nullif(current_setting('app.user_id', true), '')::uuid;
|
|
481
|
+
v_tenant := nullif(current_setting('app.tenant_id', true), '')::uuid;
|
|
482
|
+
IF v_user IS NULL THEN
|
|
483
|
+
RAISE EXCEPTION 'db_rls_session_user_missing: app.user_id is not bound on this connection'
|
|
484
|
+
USING ERRCODE = '42501',
|
|
485
|
+
HINT = 'The authenticated pool is the user-session pool; a session with no principal cannot be membership-checked. Open it with withUserContext({ userId, tenantId }, fn) from @nodii/db-rls.';
|
|
486
|
+
END IF;
|
|
487
|
+
IF v_tenant IS NULL THEN
|
|
488
|
+
RAISE EXCEPTION 'db_rls_session_tenant_missing: app.tenant_id is not bound on this connection'
|
|
489
|
+
USING ERRCODE = '42501',
|
|
490
|
+
HINT = 'Every authenticated-pool session must be EXPLICITLY tenant-scoped. Open it with withUserContext({ userId, tenantId }, fn) from @nodii/db-rls.';
|
|
491
|
+
END IF;
|
|
492
|
+
RETURN QUERY SELECT v_tenant WHERE v_tenant IN (SELECT auth.user_tenant_ids(v_user));
|
|
493
|
+
END
|
|
494
|
+
$session$;$fence_strict$;
|
|
495
|
+
END IF;
|
|
496
|
+
END
|
|
497
|
+
$fence_install$;
|
|
498
|
+
CREATE SCHEMA IF NOT EXISTS auth;
|
|
499
|
+
CREATE OR REPLACE FUNCTION auth._fence_reason(p_expr text) RETURNS text
|
|
500
|
+
LANGUAGE sql IMMUTABLE
|
|
501
|
+
SET search_path = pg_catalog, public, pg_temp
|
|
502
|
+
AS $reason$
|
|
503
|
+
SELECT CASE
|
|
504
|
+
WHEN p_expr ~* '(auth\\s*\\.\\s*)?user_tenant_ids\\s*\\('
|
|
505
|
+
THEN 'consults auth.user_tenant_ids directly instead of auth.session_tenant_ids() — resolves across EVERY tenant the principal belongs to'
|
|
506
|
+
WHEN p_expr IS NULL OR btrim(p_expr) = '' OR p_expr ~* '^\\(?\\s*true\\s*\\)?$'
|
|
507
|
+
THEN 'is permissive with no tenant reference at all — every tenant, every row'
|
|
508
|
+
ELSE 'does not resolve through auth.session_tenant_ids() — it may be fenced some other way, but nothing here proves it, and an unrecognized shape is not a safe shape'
|
|
509
|
+
END
|
|
510
|
+
$reason$;
|
|
511
|
+
CREATE OR REPLACE FUNCTION auth.assert_tenant_fence(
|
|
512
|
+
p_schemas text[] DEFAULT ARRAY['public'],
|
|
513
|
+
p_exempt_policies text[] DEFAULT ARRAY[]::text[],
|
|
514
|
+
p_exempt_tables text[] DEFAULT ARRAY[]::text[],
|
|
515
|
+
p_tenant_columns text[] DEFAULT ARRAY['tenant_id','org_id','organization_id'],
|
|
516
|
+
p_allow_degraded boolean DEFAULT true
|
|
517
|
+
) RETURNS void
|
|
518
|
+
LANGUAGE plpgsql STABLE SECURITY DEFINER
|
|
519
|
+
SET search_path = pg_catalog, public, pg_temp
|
|
520
|
+
AS $fence_check$
|
|
521
|
+
DECLARE
|
|
522
|
+
v_offenders text[] := ARRAY[]::text[];
|
|
523
|
+
v_row record;
|
|
524
|
+
v_resolver record;
|
|
525
|
+
v_membership record;
|
|
526
|
+
v_degraded boolean := false;
|
|
527
|
+
BEGIN
|
|
528
|
+
-- ---------------------------------------------------------------------
|
|
529
|
+
-- 1. The resolver itself. If it is missing, every policy referencing it is
|
|
530
|
+
-- already broken, and nothing below can be interpreted.
|
|
531
|
+
-- ---------------------------------------------------------------------
|
|
532
|
+
SELECT p.prosrc, p.prosecdef INTO v_resolver
|
|
533
|
+
FROM pg_proc p JOIN pg_namespace n ON n.oid = p.pronamespace
|
|
534
|
+
WHERE n.nspname = 'auth' AND p.proname = 'session_tenant_ids' LIMIT 1;
|
|
535
|
+
|
|
536
|
+
IF v_resolver IS NULL THEN
|
|
537
|
+
RAISE EXCEPTION 'tenant_fence: auth.session_tenant_ids() is not installed'
|
|
538
|
+
USING ERRCODE = 'P0001',
|
|
539
|
+
HINT = 'Apply INSTALL_SESSION_RESOLVER_SQL (applyAuthSchemaMigrations ships it, and @nodii/saga + @nodii/dsar + @nodii/audit-chain install it before their policies).';
|
|
540
|
+
END IF;
|
|
541
|
+
|
|
542
|
+
v_degraded := v_resolver.prosrc LIKE '%DB_RLS_DEGRADED_NO_MEMBERSHIP_MIRROR%';
|
|
543
|
+
|
|
544
|
+
IF v_resolver.prosrc !~* 'RAISE\\s+EXCEPTION' THEN
|
|
545
|
+
v_offenders := v_offenders || 'auth.session_tenant_ids() [session_tenant_ids] does not RAISE on an unbound session — it was replaced with a NULL-returning getter, which restores silent failure';
|
|
546
|
+
END IF;
|
|
547
|
+
|
|
548
|
+
IF NOT v_resolver.prosecdef THEN
|
|
549
|
+
v_offenders := v_offenders || 'auth.session_tenant_ids() [session_tenant_ids] is not SECURITY DEFINER — it cannot read the membership mirror (permission denied), or will recurse into the mirror''s own policy (54001)';
|
|
550
|
+
END IF;
|
|
551
|
+
|
|
552
|
+
IF v_degraded AND NOT p_allow_degraded THEN
|
|
553
|
+
v_offenders := v_offenders || 'auth.session_tenant_ids() [session_tenant_ids] is the DEGRADED fence-only resolver — the session tenant is trusted WITHOUT proving membership';
|
|
554
|
+
END IF;
|
|
555
|
+
|
|
556
|
+
-- The stub check applies ONLY to the strict resolver. Under the degraded body
|
|
557
|
+
-- auth.user_tenant_ids is never consulted, so a stub there is the expected,
|
|
558
|
+
-- D415-sanctioned terminal state — not a defect. Flagging it would make every
|
|
559
|
+
-- legitimately-degraded service permanently red, which is how a gate gets
|
|
560
|
+
-- switched off.
|
|
561
|
+
IF NOT v_degraded THEN
|
|
562
|
+
SELECT p.prosrc INTO v_membership
|
|
563
|
+
FROM pg_proc p JOIN pg_namespace n ON n.oid = p.pronamespace
|
|
564
|
+
WHERE n.nspname = 'auth' AND p.proname = 'user_tenant_ids' LIMIT 1;
|
|
565
|
+
IF v_membership IS NOT NULL
|
|
566
|
+
AND v_membership.prosrc ~* 'where\\s+false'
|
|
567
|
+
AND v_membership.prosrc !~* 'from\\s+\\w' THEN
|
|
568
|
+
v_offenders := v_offenders || 'auth.user_tenant_ids(uuid) [user_tenant_ids] is still the bootstrap stub returning the empty set — the strict resolver intersects to nothing, so the authenticated pool is silently deny-all';
|
|
569
|
+
END IF;
|
|
570
|
+
END IF;
|
|
571
|
+
|
|
572
|
+
-- ---------------------------------------------------------------------
|
|
573
|
+
-- 2. The positive rule over every authenticated-applicable policy.
|
|
574
|
+
-- ---------------------------------------------------------------------
|
|
575
|
+
FOR v_row IN
|
|
576
|
+
SELECT n.nspname AS schemaname,
|
|
577
|
+
c.relname AS tablename,
|
|
578
|
+
pol.polname AS policyname,
|
|
579
|
+
CASE pol.polcmd WHEN 'r' THEN 'SELECT' WHEN 'a' THEN 'INSERT'
|
|
580
|
+
WHEN 'w' THEN 'UPDATE' WHEN 'd' THEN 'DELETE'
|
|
581
|
+
ELSE 'ALL' END AS cmd,
|
|
582
|
+
pg_get_expr(pol.polqual, pol.polrelid) AS qual,
|
|
583
|
+
pg_get_expr(pol.polwithcheck, pol.polrelid) AS with_check
|
|
584
|
+
FROM pg_policy pol
|
|
585
|
+
JOIN pg_class c ON c.oid = pol.polrelid
|
|
586
|
+
JOIN pg_namespace n ON n.oid = c.relnamespace
|
|
587
|
+
WHERE n.nspname = ANY(p_schemas)
|
|
588
|
+
-- RESTRICTIVE policies are ANDed; they can only narrow access, so they
|
|
589
|
+
-- cannot be the source of a cross-tenant grant.
|
|
590
|
+
AND pol.polpermissive
|
|
591
|
+
AND (
|
|
592
|
+
EXISTS (SELECT 1 FROM unnest(pol.polroles) r WHERE r = 0)
|
|
593
|
+
OR (
|
|
594
|
+
EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'authenticated')
|
|
595
|
+
AND EXISTS (
|
|
596
|
+
SELECT 1 FROM unnest(pol.polroles) r
|
|
597
|
+
WHERE pg_has_role('authenticated', r, 'USAGE')
|
|
598
|
+
)
|
|
599
|
+
)
|
|
600
|
+
)
|
|
601
|
+
AND NOT (pol.polname = ANY(p_exempt_policies))
|
|
602
|
+
AND NOT ((c.relname || '.' || pol.polname) = ANY(p_exempt_policies))
|
|
603
|
+
AND NOT (c.relname = ANY(p_exempt_tables))
|
|
604
|
+
AND NOT ((n.nspname || '.' || c.relname) = ANY(p_exempt_tables))
|
|
605
|
+
ORDER BY c.relname, pol.polname
|
|
606
|
+
LOOP
|
|
607
|
+
-- A policy with NEITHER clause is permissive-everything.
|
|
608
|
+
IF v_row.qual IS NULL AND v_row.with_check IS NULL THEN
|
|
609
|
+
v_offenders := v_offenders || format(
|
|
610
|
+
'%s.%s [%s %s] is permissive with no tenant reference at all — every tenant, every row',
|
|
611
|
+
v_row.schemaname, v_row.tablename, v_row.policyname, v_row.cmd);
|
|
612
|
+
CONTINUE;
|
|
613
|
+
END IF;
|
|
614
|
+
|
|
615
|
+
-- EVERY clause present must resolve. A fenced read with an unfenced
|
|
616
|
+
-- WITH CHECK is a cross-tenant WRITE, which is what the refund incident
|
|
617
|
+
-- actually exercised.
|
|
618
|
+
IF v_row.qual IS NOT NULL
|
|
619
|
+
AND v_row.qual !~* '(auth\\s*\\.\\s*)?session_tenant_ids\\s*\\(' THEN
|
|
620
|
+
v_offenders := v_offenders || format('%s.%s [%s %s USING] %s :: %s',
|
|
621
|
+
v_row.schemaname, v_row.tablename, v_row.policyname, v_row.cmd,
|
|
622
|
+
auth._fence_reason(v_row.qual), v_row.qual);
|
|
623
|
+
END IF;
|
|
624
|
+
|
|
625
|
+
IF v_row.with_check IS NOT NULL
|
|
626
|
+
AND v_row.with_check !~* '(auth\\s*\\.\\s*)?session_tenant_ids\\s*\\(' THEN
|
|
627
|
+
v_offenders := v_offenders || format('%s.%s [%s %s WITH CHECK] %s :: %s',
|
|
628
|
+
v_row.schemaname, v_row.tablename, v_row.policyname, v_row.cmd,
|
|
629
|
+
auth._fence_reason(v_row.with_check), v_row.with_check);
|
|
630
|
+
END IF;
|
|
631
|
+
END LOOP;
|
|
632
|
+
|
|
633
|
+
-- ---------------------------------------------------------------------
|
|
634
|
+
-- 3. Table coverage. THE HOLE A POLICY-LEVEL CHECK CANNOT SEE: a table with
|
|
635
|
+
-- a tenant column and RLS switched off has no rows in pg_policy to
|
|
636
|
+
-- inspect, and under the canonical blanket grants it is readable AND
|
|
637
|
+
-- writable across every tenant — strictly more open than the union
|
|
638
|
+
-- predicate this release removes.
|
|
639
|
+
--
|
|
640
|
+
-- Discovered FROM THE CATALOG, never from a caller-supplied list. The
|
|
641
|
+
-- author who forgets ENABLE ROW LEVEL SECURITY is the same author who
|
|
642
|
+
-- forgets the list entry, in the same migration.
|
|
643
|
+
-- ---------------------------------------------------------------------
|
|
644
|
+
FOR v_row IN
|
|
645
|
+
SELECT n.nspname AS schemaname, c.relname AS tablename,
|
|
646
|
+
c.relkind::text AS relkind, c.relrowsecurity,
|
|
647
|
+
COALESCE((SELECT true FROM unnest(COALESCE(c.reloptions,'{}')) o
|
|
648
|
+
WHERE lower(replace(o,' ','')) = 'security_invoker=true'), false) AS security_invoker
|
|
649
|
+
FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace
|
|
650
|
+
WHERE c.relkind = ANY('{r,p,v,m,f}')
|
|
651
|
+
AND n.nspname = ANY(p_schemas)
|
|
652
|
+
AND NOT (c.relname = ANY(p_exempt_tables))
|
|
653
|
+
AND NOT ((n.nspname || '.' || c.relname) = ANY(p_exempt_tables))
|
|
654
|
+
AND EXISTS (SELECT 1 FROM pg_attribute a
|
|
655
|
+
WHERE a.attrelid = c.oid AND a.attnum > 0
|
|
656
|
+
AND NOT a.attisdropped AND a.attname = ANY(p_tenant_columns))
|
|
657
|
+
ORDER BY n.nspname, c.relname
|
|
658
|
+
LOOP
|
|
659
|
+
IF v_row.relkind IN ('v','m','f') THEN
|
|
660
|
+
-- A view with security_invoker=true executes as the CALLER, so the
|
|
661
|
+
-- underlying table's RLS applies and the view is genuinely safe.
|
|
662
|
+
IF v_row.relkind = 'v' AND v_row.security_invoker THEN CONTINUE; END IF;
|
|
663
|
+
v_offenders := v_offenders || format(
|
|
664
|
+
'%s.%s exposes a tenant column but cannot enforce RLS (relkind=%s) — a materialized/foreign relation has no row policies at all, and a view without security_invoker=true runs as its OWNER and bypasses the underlying table''s policies',
|
|
665
|
+
v_row.schemaname, v_row.tablename, v_row.relkind);
|
|
666
|
+
ELSIF NOT v_row.relrowsecurity THEN
|
|
667
|
+
v_offenders := v_offenders || format(
|
|
668
|
+
'%s.%s has a tenant column but ROW LEVEL SECURITY is NOT ENABLED — with the canonical blanket grants this table is readable and writable across EVERY tenant, and no policy is ever consulted',
|
|
669
|
+
v_row.schemaname, v_row.tablename);
|
|
670
|
+
END IF;
|
|
671
|
+
END LOOP;
|
|
672
|
+
|
|
673
|
+
IF array_length(v_offenders, 1) > 0 THEN
|
|
674
|
+
RAISE EXCEPTION 'tenant_fence: % authenticated-pool policy/helper defect(s). A user session must reach exactly ONE tenant — the one the edge resolved from the request — and nothing else, ever.%',
|
|
675
|
+
array_length(v_offenders, 1),
|
|
676
|
+
E'\\n - ' || array_to_string(v_offenders, E'\\n - ')
|
|
677
|
+
USING ERRCODE = 'P0001',
|
|
678
|
+
HINT = 'Regenerate policies with @nodii/db-rls withRls() / generateRlsPolicy(), which emit "<col> IN (SELECT auth.session_tenant_ids())". Nodii-staff cross-tenant access is a different path entirely: the platform_ops pool + withPlatformOpsContext.';
|
|
679
|
+
END IF;
|
|
680
|
+
END
|
|
681
|
+
$fence_check$;
|
|
682
|
+
GRANT EXECUTE ON FUNCTION auth._fence_reason(text) TO PUBLIC;
|
|
683
|
+
`;
|
|
384
684
|
/**
|
|
385
685
|
* PRECONDITION. Fails the migration BEFORE it drops anything if the resolver
|
|
386
686
|
* `auth.session_tenant_ids()` is absent.
|
|
@@ -414,6 +714,17 @@ $precondition$;`;
|
|
|
414
714
|
* protocol; we split on `;` boundaries we control.
|
|
415
715
|
*/
|
|
416
716
|
export async function applyDsarMigrations(sql) {
|
|
717
|
+
// DELIVER the resolver + gate, then verify. Installing is the whole point:
|
|
718
|
+
// this runs at boot with owner privileges against the real database, and for
|
|
719
|
+
// several services it is the ONLY code that ever does — see
|
|
720
|
+
// SESSION_FENCE_BOOTSTRAP_SQL. The precondition below is retained as a
|
|
721
|
+
// POST-condition: if the install somehow did not take (an older db-rls
|
|
722
|
+
// vendored copy, a partially-applied blob, a permissions failure that did not
|
|
723
|
+
// raise), we still refuse BEFORE the DROP POLICY statements rather than
|
|
724
|
+
// half-migrating the table into a deny-all state with no policies at all.
|
|
725
|
+
for (const stmt of splitStatements(SESSION_FENCE_BOOTSTRAP_SQL)) {
|
|
726
|
+
await sql.unsafe(stmt);
|
|
727
|
+
}
|
|
417
728
|
await sql.unsafe(SESSION_RESOLVER_PRECONDITION_SQL);
|
|
418
729
|
const ddl = getDsarMigrationSQL();
|
|
419
730
|
const statements = splitStatements(ddl);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,gEAAgE;AAChE,EAAE;AACF,wEAAwE;AACxE,mEAAmE;AACnE,2EAA2E;AAC3E,yEAAyE;AAOzE;;;;;GAKG;AACH,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAC;AAGvE,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsLzB,gBAAgB,CAAC,sBAAsB,CAAC;EACxC,gBAAgB,CAAC,sBAAsB,CAAC;EACxC,mBAAmB,CAAC,oBAAoB,CAAC;EACzC,mBAAmB,CAAC,6BAA6B,CAAC;EAClD,mBAAmB,CAAC,sBAAsB,CAAC;CAC5C,CAAC,IAAI,EAAE,CAAC;AAET;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAa;IACpC,MAAM,KAAK,GAAa;QACtB,uDAAuD,KAAK,oBAAoB;QAChF,eAAe,KAAK,6BAA6B;QACjD,2EAA2E;QAC3E,uEAAuE;QACvE,uEAAuE;QACvE,wEAAwE;QACxE,0BA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EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAC5B,sEAAsE;QACtE,IAAI,SAAS,KAAK,IAAI,IAAI,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAAE,SAAS;QACrE,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;QAE3C,mEAAmE;QACnE,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC;QACvD,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;YACxB,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;gBACvB,SAAS,GAAG,CAAC,CAAC;YAChB,CAAC;iBAAM,IAAI,SAAS,KAAK,CAAC,EAAE,CAAC;gBAC3B,SAAS,GAAG,IAAI,CAAC;YACnB,CAAC;QACH,CAAC;QAED,IAAI,SAAS,KAAK,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7C,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;YAC3B,IAAI,OAAO;gBAAE,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC/B,GAAG,GAAG,EAAE,CAAC;QACX,CAAC;IACH,CAAC;IACD,IAAI,GAAG,CAAC,IAAI,EAAE;QAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IACrC,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/orchestrator.d.ts
CHANGED
|
@@ -23,19 +23,12 @@ export interface BindOrchestratorOpts {
|
|
|
23
23
|
/** Defaults to `data_residency_holds`. */
|
|
24
24
|
holdsTableName?: string;
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* COMPLIANCE-GATE BYPASS. Default `false`.
|
|
33
|
-
*/
|
|
34
|
-
allowFailOpenHolds?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* @deprecated Since 0.16.0 fail-closed is the DEFAULT. `true` is a no-op;
|
|
37
|
-
* `false` THROWS {@link AmbiguousHoldFailureMode} at bind time — pass
|
|
38
|
-
* `allowFailOpenHolds: true` if you really want fail-open.
|
|
26
|
+
* @deprecated The orchestrator-side hold gate is UNCONDITIONALLY
|
|
27
|
+
* fail-CLOSED (operator ruling 2026-07-30 — "If holds is inaccessible - we
|
|
28
|
+
* deny the write. ... Fail CLOSED.", all three twins). The former
|
|
29
|
+
* `allowFailOpenHolds` opt-out is REMOVED. `true` is a no-op; `false`
|
|
30
|
+
* THROWS {@link AmbiguousHoldFailureMode} at bind time — there is no
|
|
31
|
+
* fail-open to opt into.
|
|
39
32
|
*/
|
|
40
33
|
failClosedHolds?: boolean;
|
|
41
34
|
/**
|
|
@@ -44,9 +37,11 @@ export interface BindOrchestratorOpts {
|
|
|
44
37
|
*/
|
|
45
38
|
eraseBlockingHoldKinds?: readonly HoldKind[];
|
|
46
39
|
/**
|
|
47
|
-
* Per
|
|
48
|
-
*
|
|
49
|
-
*
|
|
40
|
+
* Per-`subject_kind` → siblings static map (D486 subject_kind-only routing;
|
|
41
|
+
* SUPERSEDES the pre-D486 `"<data_class>:<subject_kind>"` key). Used when a
|
|
42
|
+
* sqlClient isn't supplied (unit tests / dev). Keyed by the bare subject_kind
|
|
43
|
+
* (e.g. `"customer"`, `"user"`) — `data_class` is NEVER part of the key.
|
|
44
|
+
* Sibling names must match `siblingClients` keys.
|
|
50
45
|
*/
|
|
51
46
|
retentionPolicies?: Record<string, string[]>;
|
|
52
47
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../src/orchestrator.ts"],"names":[],"mappings":"
|
|
1
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