snipe-auth-rbac 0.6.0 → 0.6.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snipe-auth-rbac",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Two-layer RBAC (system + company) for React, Next.js, and any modern TS app — paired with the Python sibling.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -957,6 +957,15 @@ DO $$ BEGIN
957
957
  IF EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'authenticated') THEN
958
958
  EXECUTE 'GRANT EXECUTE ON FUNCTION rbac.is_super_admin() TO authenticated';
959
959
  EXECUTE 'GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA rbac TO authenticated';
960
+ -- 0.6.1+: ALTER DEFAULT PRIVILEGES so any future tables
961
+ -- added to the rbac schema (by adopters or by a later
962
+ -- version of this package) automatically get the same
963
+ -- authenticated CRUD grant. Prevents the
964
+ -- "rbac.role_permission_overrides missing UPDATE → upsert
965
+ -- silently rejected" class of bug that hit adopters who
966
+ -- ran 0001 on an existing DB before role_permission_overrides
967
+ -- existed.
968
+ EXECUTE 'ALTER DEFAULT PRIVILEGES IN SCHEMA rbac GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO authenticated';
960
969
  END IF;
961
970
  IF EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'service_role') THEN
962
971
  EXECUTE 'GRANT ALL ON ALL TABLES IN SCHEMA rbac TO service_role';
@@ -965,6 +974,19 @@ DO $$ BEGIN
965
974
  END IF;
966
975
  END $$;
967
976
 
977
+ -- 0.6.1+: explicit per-table re-grant for the two 0.4.0+ tables.
978
+ -- Belt-and-braces for adopters whose DB has the tables but whose
979
+ -- earlier 0001 run pre-dated the tables (so the schema-wide GRANT
980
+ -- above didn't cover them, and ALTER DEFAULT PRIVILEGES only
981
+ -- applies to tables created AFTER it). Idempotent — re-granting
982
+ -- existing privileges is a no-op.
983
+ DO $$ BEGIN
984
+ IF EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'authenticated') THEN
985
+ EXECUTE 'GRANT SELECT, INSERT, UPDATE, DELETE ON rbac.resource_dependencies TO authenticated';
986
+ EXECUTE 'GRANT SELECT, INSERT, UPDATE, DELETE ON rbac.role_permission_overrides TO authenticated';
987
+ END IF;
988
+ END $$;
989
+
968
990
  ALTER TABLE rbac.companies ENABLE ROW LEVEL SECURITY;
969
991
  ALTER TABLE rbac.resources ENABLE ROW LEVEL SECURITY;
970
992
  ALTER TABLE rbac.roles ENABLE ROW LEVEL SECURITY;