From dc8ad2ee1c57f5e47080a18304cfb3571f23956a Mon Sep 17 00:00:00 2001 From: Dan Lynch Date: Sun, 22 Nov 2026 01:53:31 +0000 Subject: [PATCH 1/7] feat(supabase): add Supabase PostgREST integration module for auth:byo --- .github/workflows/ci.yml | 2 + .github/workflows/integration-test.yml | 1 + MODULES.md | 1 + packages/supabase/.npmignore | 2 + packages/supabase/LICENSE | 22 ++ packages/supabase/Makefile | 6 + packages/supabase/README.md | 46 +++ packages/supabase/__tests__/supabase.test.ts | 81 +++++ packages/supabase/deploy/roles/anon.sql | 15 + .../procedures/pre_request.sql | 27 ++ .../schemas/supabase_integration/schema.sql | 9 + packages/supabase/jest.config.js | 16 + packages/supabase/package.json | 38 +++ packages/supabase/pgpm-supabase.control | 7 + packages/supabase/pgpm.plan | 7 + packages/supabase/revert/roles/anon.sql | 7 + .../procedures/pre_request.sql | 7 + .../schemas/supabase_integration/schema.sql | 7 + .../sql/pgpm-supabase--0.1.0.bundle.tar.gz | Bin 0 -> 2179 bytes .../supabase/sql/pgpm-supabase--0.1.0.sql | 34 ++ packages/supabase/verify/roles/anon.sql | 12 + .../procedures/pre_request.sql | 15 + .../schemas/supabase_integration/schema.sql | 14 + pnpm-lock.yaml | 323 ++++++++++++++++++ 24 files changed, 699 insertions(+) create mode 100644 packages/supabase/.npmignore create mode 100644 packages/supabase/LICENSE create mode 100644 packages/supabase/Makefile create mode 100644 packages/supabase/README.md create mode 100644 packages/supabase/__tests__/supabase.test.ts create mode 100644 packages/supabase/deploy/roles/anon.sql create mode 100644 packages/supabase/deploy/schemas/supabase_integration/procedures/pre_request.sql create mode 100644 packages/supabase/deploy/schemas/supabase_integration/schema.sql create mode 100644 packages/supabase/jest.config.js create mode 100644 packages/supabase/package.json create mode 100644 packages/supabase/pgpm-supabase.control create mode 100644 packages/supabase/pgpm.plan create mode 100644 packages/supabase/revert/roles/anon.sql create mode 100644 packages/supabase/revert/schemas/supabase_integration/procedures/pre_request.sql create mode 100644 packages/supabase/revert/schemas/supabase_integration/schema.sql create mode 100644 packages/supabase/sql/pgpm-supabase--0.1.0.bundle.tar.gz create mode 100644 packages/supabase/sql/pgpm-supabase--0.1.0.sql create mode 100644 packages/supabase/verify/roles/anon.sql create mode 100644 packages/supabase/verify/schemas/supabase_integration/procedures/pre_request.sql create mode 100644 packages/supabase/verify/schemas/supabase_integration/schema.sql diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 328d79b55..d0e86edfe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,7 @@ jobs: - base32 - totp - jwt-claims + - supabase - defaults - measurements - metaschema-schema @@ -116,6 +117,7 @@ jobs: - name: Seed pg and app_user run: | pgpm admin-users bootstrap --client --yes + psql -v ON_ERROR_STOP=1 -c 'CREATE ROLE anon NOINHERIT NOLOGIN;' # optional, but added to avoid concurrent attempts to add user pgpm admin-users add --test --yes # the platform components' one login (NOBYPASSRLS); the reader tests diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 2fd7fc0c5..d572df4a3 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -86,6 +86,7 @@ jobs: - name: Seed pg users run: | pgpm admin-users bootstrap --client --yes + psql -v ON_ERROR_STOP=1 -c 'CREATE ROLE anon NOINHERIT NOLOGIN;' - name: Run Integration Tests run: pgpm test-packages --full-cycle diff --git a/MODULES.md b/MODULES.md index aae4464aa..f388161c2 100644 --- a/MODULES.md +++ b/MODULES.md @@ -46,6 +46,7 @@ ## Security & Authentication ### Core Security +- [ ] `packages/supabase` - Supabase PostgREST role and identity claim bridge - [ ] `packages/security/defaults` - Security defaults - [ ] `packages/security/jwt-claims` - JWT claim handling - [ ] `packages/security/totp` - Time-based One-Time Password (TOTP) diff --git a/packages/supabase/.npmignore b/packages/supabase/.npmignore new file mode 100644 index 000000000..cf8a45548 --- /dev/null +++ b/packages/supabase/.npmignore @@ -0,0 +1,2 @@ +__tests__ +jest.config.js diff --git a/packages/supabase/LICENSE b/packages/supabase/LICENSE new file mode 100644 index 000000000..7b18c9183 --- /dev/null +++ b/packages/supabase/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2025 Dan Lynch +Copyright (c) 2025 Constructive + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/supabase/Makefile b/packages/supabase/Makefile new file mode 100644 index 000000000..b659bfbad --- /dev/null +++ b/packages/supabase/Makefile @@ -0,0 +1,6 @@ +EXTENSION = pgpm-supabase +DATA = sql/pgpm-supabase--0.1.0.sql + +PG_CONFIG = pg_config +PGXS := $(shell $(PG_CONFIG) --pgxs) +include $(PGXS) diff --git a/packages/supabase/README.md b/packages/supabase/README.md new file mode 100644 index 000000000..9a27f115c --- /dev/null +++ b/packages/supabase/README.md @@ -0,0 +1,46 @@ +# @pgpm/supabase + +Bridge Supabase PostgREST requests to Constructive's transaction-local RLS claims. + +## Supabase setup + +1. Run `pgpm admin-users bootstrap --yes` against the Supabase database to create + Constructive's `anonymous` role (and the other base roles). +2. Ensure Supabase's `anon` and `authenticated` roles already exist. Outside + Supabase, create `anon` with `CREATE ROLE anon NOINHERIT NOLOGIN;` before deployment. +3. Install `@pgpm/supabase` and deploy `pgpm-supabase` with `pgpm deploy`. +4. As the database administrator, configure PostgREST: + + ```sql + ALTER ROLE authenticator SET pgrst.db_pre_request = 'supabase_integration.pre_request'; + NOTIFY pgrst, 'reload config'; + ``` + +The security-invoker hook switches `anon` to `anonymous`. It does not grant +automatic inheritance: `anon` cannot use `anonymous` grants without switching. +On PostgreSQL 16+ the membership explicitly disables inheritance and allows SET; +on PostgreSQL 15 it relies on Supabase's `anon` being NOINHERIT. + +For `authenticated`, the hook copies the verified `request.jwt.claims` JSON `sub` +to both `jwt.claims.user_id` and `jwt.claims.principal_id`, transaction-locally. +The subject must correspond to Constructive's `users.id`. Missing/empty claims +or subjects leave the claims unset; malformed JSON raises an error. Other roles +are unchanged. Only use this hook behind PostgREST's verified JWT boundary; +it does not verify JWTs or provision users. Each request must use a fresh transaction. + +RLS policies must treat empty claim strings as absent, for example +`nullif(current_setting('jwt.claims.user_id', true), '')::uuid`. PostgreSQL can +return an empty string for a custom GUC after its transaction-local value is +rolled back; a direct UUID cast would then raise on a later unauthenticated request. + +## Development + +```sh +eval "$(pgpm env)" +pnpm test +pgpm package +``` + +The tests create a missing `anon` role before deploying the module. Reverting +revokes the membership and drops the hook and schema, but does not drop roles +or change PostgREST configuration. Remove the pre-request setting before reverting. diff --git a/packages/supabase/__tests__/supabase.test.ts b/packages/supabase/__tests__/supabase.test.ts new file mode 100644 index 000000000..f16225d4e --- /dev/null +++ b/packages/supabase/__tests__/supabase.test.ts @@ -0,0 +1,81 @@ +import { getConnections, PgTestClient } from 'pgsql-test'; +import { seed } from 'pgsql-test/seed'; + +let pg: PgTestClient; +let teardown: () => Promise; +const userId = '00000000-0000-0000-0000-000000000001'; +const otherId = '00000000-0000-0000-0000-000000000002'; + +beforeAll(async () => { + ({ pg, teardown } = await getConnections({}, [ + seed.fn(async ({ pg }) => { + await pg.query(` + DO $$ BEGIN + IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = 'anon') THEN + CREATE ROLE anon NOINHERIT NOLOGIN; + END IF; + END $$; + `); + }), + seed.pgpm() + ])); + await pg.query(` + CREATE TABLE public.anonymous_read (value text); + INSERT INTO public.anonymous_read VALUES ('public content'); + GRANT SELECT ON public.anonymous_read TO anonymous; + CREATE TABLE public.owned_rows (user_id uuid PRIMARY KEY); + INSERT INTO public.owned_rows VALUES ('${userId}'), ('${otherId}'); + ALTER TABLE public.owned_rows ENABLE ROW LEVEL SECURITY; + GRANT SELECT ON public.owned_rows TO authenticated; + CREATE POLICY own_rows ON public.owned_rows TO authenticated + USING (user_id = nullif(current_setting('jwt.claims.user_id', true), '')::uuid); + `); +}); + +afterAll(async () => { await teardown?.(); }); +beforeEach(async () => { + pg.setContext({ role: null, 'request.jwt.claims': null }); + await pg.beforeEach(); +}); +afterEach(async () => { await pg.afterEach(); }); + +async function preRequestThen(sql: string) { + const results: any = await pg.query(`SELECT supabase_integration.pre_request(); ${sql}`); + return results[1].rows; +} + +it('does not inherit anonymous grants before pre_request', async () => { + pg.setContext({ role: 'anon' }); + await pg.expectError(() => pg.query('SELECT * FROM public.anonymous_read'), /permission denied/); +}); + +it('switches anon to anonymous and reads anonymous grants', async () => { + pg.setContext({ role: 'anon' }); + expect(await preRequestThen('SELECT current_user, value FROM public.anonymous_read')) + .toEqual([{ current_user: 'anonymous', value: 'public content' }]); +}); + +it('bridges both identity claims and restricts rows to the subject', async () => { + pg.setContext({ role: 'authenticated', 'request.jwt.claims': JSON.stringify({ sub: userId }) }); + expect(await preRequestThen(`SELECT user_id, + current_setting('jwt.claims.user_id', true) AS claim, + current_setting('jwt.claims.principal_id', true) AS principal + FROM public.owned_rows`)).toEqual([{ user_id: userId, claim: userId, principal: userId }]); +}); + +it.each([null, '', '{}', '{"sub":""}'])('handles absent subject in claims %p', async claims => { + pg.setContext({ role: 'authenticated', 'request.jwt.claims': claims }); + expect(await preRequestThen('SELECT * FROM public.owned_rows')).toEqual([]); +}); + +it('does nothing for other roles', async () => { + pg.setContext({ role: null, 'request.jwt.claims': JSON.stringify({ sub: userId }) }); + expect(await preRequestThen(`SELECT current_user = session_user AS unchanged, + nullif(current_setting('jwt.claims.user_id', true), '') AS claim`)) + .toEqual([{ unchanged: true, claim: null }]); +}); + +it('rejects malformed JWT JSON', async () => { + pg.setContext({ role: 'authenticated', 'request.jwt.claims': 'invalid' }); + await pg.expectError(() => pg.query('SELECT supabase_integration.pre_request()'), /invalid input syntax for type json/); +}); diff --git a/packages/supabase/deploy/roles/anon.sql b/packages/supabase/deploy/roles/anon.sql new file mode 100644 index 000000000..e924f7b9b --- /dev/null +++ b/packages/supabase/deploy/roles/anon.sql @@ -0,0 +1,15 @@ +-- Deploy roles/anon to pg + +BEGIN; + +DO $$ +BEGIN + IF current_setting('server_version_num')::integer >= 160000 THEN + GRANT anonymous TO anon WITH INHERIT FALSE, SET TRUE; + ELSE + GRANT anonymous TO anon; + END IF; +END; +$$; + +COMMIT; diff --git a/packages/supabase/deploy/schemas/supabase_integration/procedures/pre_request.sql b/packages/supabase/deploy/schemas/supabase_integration/procedures/pre_request.sql new file mode 100644 index 000000000..daf231b4a --- /dev/null +++ b/packages/supabase/deploy/schemas/supabase_integration/procedures/pre_request.sql @@ -0,0 +1,27 @@ +-- Deploy schemas/supabase_integration/procedures/pre_request to pg + +BEGIN; + +CREATE FUNCTION supabase_integration.pre_request() +RETURNS void +LANGUAGE plpgsql +AS $$ +DECLARE + subject text; +BEGIN + IF current_user = 'anon' THEN + PERFORM set_config('role', 'anonymous', true); + ELSIF current_user = 'authenticated' THEN + subject := nullif(current_setting('request.jwt.claims', true), '')::jsonb ->> 'sub'; + IF subject IS NOT NULL AND subject <> '' THEN + PERFORM set_config('jwt.claims.user_id', subject, true); + PERFORM set_config('jwt.claims.principal_id', subject, true); + END IF; + END IF; +END; +$$; + +REVOKE ALL ON FUNCTION supabase_integration.pre_request() FROM PUBLIC; +GRANT EXECUTE ON FUNCTION supabase_integration.pre_request() TO anon, authenticated; + +COMMIT; diff --git a/packages/supabase/deploy/schemas/supabase_integration/schema.sql b/packages/supabase/deploy/schemas/supabase_integration/schema.sql new file mode 100644 index 000000000..59ae34e7d --- /dev/null +++ b/packages/supabase/deploy/schemas/supabase_integration/schema.sql @@ -0,0 +1,9 @@ +-- Deploy schemas/supabase_integration/schema to pg + +BEGIN; + +CREATE SCHEMA supabase_integration; + +GRANT USAGE ON SCHEMA supabase_integration TO anon, authenticated; + +COMMIT; diff --git a/packages/supabase/jest.config.js b/packages/supabase/jest.config.js new file mode 100644 index 000000000..4108cf46f --- /dev/null +++ b/packages/supabase/jest.config.js @@ -0,0 +1,16 @@ +/** @type {import('ts-jest').JestConfigWithTsJest} */ +module.exports = { + forceExit: true, + preset: 'ts-jest', + testEnvironment: 'node', + + // Match both __tests__ and colocated test files + testMatch: ['**/?(*.)+(test|spec).{ts,tsx,js,jsx}'], + + // Ignore build artifacts and type declarations + testPathIgnorePatterns: ['/dist/', '\\.d\\.ts$'], + modulePathIgnorePatterns: ['/dist/'], + watchPathIgnorePatterns: ['/dist/'], + + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], +}; diff --git a/packages/supabase/package.json b/packages/supabase/package.json new file mode 100644 index 000000000..cc56ab92c --- /dev/null +++ b/packages/supabase/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pgpm/supabase", + "version": "0.1.0", + "description": "Bridge Supabase PostgREST requests to Constructive RLS claims", + "author": "Dan Lynch ", + "contributors": [ + "Constructive " + ], + "keywords": [ + "postgresql", + "pgpm", + "supabase", + "authentication" + ], + "publishConfig": { + "access": "public" + }, + "scripts": { + "bundle": "pgpm package", + "test": "jest", + "test:watch": "jest --watch" + }, + "devDependencies": { + "pgpm": "^5", + "pgsql-test": "^5.20.13" + }, + "dependencies": { + "@pgpm/verify": "workspace:*" + }, + "repository": { + "type": "git", + "url": "https://github.com/constructive-io/pgpm-modules" + }, + "homepage": "https://github.com/constructive-io/pgpm-modules", + "bugs": { + "url": "https://github.com/constructive-io/pgpm-modules/issues" + } +} diff --git a/packages/supabase/pgpm-supabase.control b/packages/supabase/pgpm-supabase.control new file mode 100644 index 000000000..f0204e979 --- /dev/null +++ b/packages/supabase/pgpm-supabase.control @@ -0,0 +1,7 @@ +# pgpm-supabase extension +comment = 'Supabase PostgREST integration for Constructive' +default_version = '0.1.0' +module_pathname = '$libdir/pgpm-supabase' +requires = 'plpgsql,pgpm-verify' +relocatable = false +superuser = false diff --git a/packages/supabase/pgpm.plan b/packages/supabase/pgpm.plan new file mode 100644 index 000000000..d22b12639 --- /dev/null +++ b/packages/supabase/pgpm.plan @@ -0,0 +1,7 @@ +%syntax-version=1.0.0 +%project=pgpm-supabase +%uri=pgpm-supabase + +schemas/supabase_integration/schema 2026-08-27T00:00:00Z Constructive # add schemas/supabase_integration/schema +roles/anon [schemas/supabase_integration/schema] 2026-08-27T00:00:00Z Constructive # add roles/anon +schemas/supabase_integration/procedures/pre_request [schemas/supabase_integration/schema roles/anon] 2026-08-27T00:00:00Z Constructive # add schemas/supabase_integration/procedures/pre_request diff --git a/packages/supabase/revert/roles/anon.sql b/packages/supabase/revert/roles/anon.sql new file mode 100644 index 000000000..791ebb0a9 --- /dev/null +++ b/packages/supabase/revert/roles/anon.sql @@ -0,0 +1,7 @@ +-- Revert roles/anon from pg + +BEGIN; + +REVOKE anonymous FROM anon; + +COMMIT; diff --git a/packages/supabase/revert/schemas/supabase_integration/procedures/pre_request.sql b/packages/supabase/revert/schemas/supabase_integration/procedures/pre_request.sql new file mode 100644 index 000000000..fb3ac0665 --- /dev/null +++ b/packages/supabase/revert/schemas/supabase_integration/procedures/pre_request.sql @@ -0,0 +1,7 @@ +-- Revert schemas/supabase_integration/procedures/pre_request from pg + +BEGIN; + +DROP FUNCTION supabase_integration.pre_request(); + +COMMIT; diff --git a/packages/supabase/revert/schemas/supabase_integration/schema.sql b/packages/supabase/revert/schemas/supabase_integration/schema.sql new file mode 100644 index 000000000..e1089ad6d --- /dev/null +++ b/packages/supabase/revert/schemas/supabase_integration/schema.sql @@ -0,0 +1,7 @@ +-- Revert schemas/supabase_integration/schema from pg + +BEGIN; + +DROP SCHEMA supabase_integration; + +COMMIT; diff --git a/packages/supabase/sql/pgpm-supabase--0.1.0.bundle.tar.gz b/packages/supabase/sql/pgpm-supabase--0.1.0.bundle.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..17bd489f0226222fc239ed9d620035a704ab6a93 GIT binary patch literal 2179 zcmV-}2z>V+iwFP!000021MOJ*Pa8=R&d>QPTHdToBq05MkWI7%h6F9xkukfcTSurL z)y`zijCW?tC0gzOeri9!5ED$qMR%vPEZOersp|f^>Z__5569C1Y=5ZB;?aL# zV2rWkeEN+szVS^YW0$h|JRw+;NBGe<7?ZlO)g$~(Z2cFGzaAshI=4k0p>A3`DE&vM z70c?}Hornu=Vj5_K`qkSoJk6M4ryYX9H*X)t+O>OguVjXK=>_h-lsJ`r$ry?XTGei zmb|yc5cbMRk<79AY=H5o{M4-iRIMHK`*aeaR_))zxvifq?40FA1H;NTd09N03Fmqd zYE|V3>Swkni>tXWDi~L#hcKz2em1V)tb#u$354mh?-m=&hcjSWV61kODMEt9(E$~d z`A8#n*l-%9h%q|JsI`g_YK;)gF-1iP!7|QB())MP+8U4S6w@E;Peo%tZe7e^enGbJ zHXal|j;rzm_~ykmhzG@wlPbSCHz?MC2vJPs7S>x-^)cR=e*TH}%A#(niEr`?KtBbz zfKfSys{Yw83AXd{CHeu`5YQTi2F2AKpx@Vc;N8P)?aJyMc&xthwYIusJd#9DM!5@l z_3YYS+JhpUIIo~iYsRDTu>NzjIbCxBRUSW0SBy$;8|y|%QM98J5cOmX)ue{%YU(QR zX53R>GR$8Knplw9z4#`;7>WRe&u1#%ElWn_r_0-!&i#=WA(@!VHm@Z0pXnl7TU%&< zDqAPgP*bAuFvb6??Db*idHS{2%Xa%2I@x=Z9q*!54^Nl9?(KH^==5awb%wf~FD*y? zE=vBsiR`3#4@Hy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R)$6puYuZS(wJ}F(T$MHW0C5(_t(3SL*m)50`HzpxS&=zONsS_Xe$k|m>3&~^-?%VwI`8igEgTHEccE9)4~bCNQhp2 zu?df0jORiajUjmFDFa0@5yD}slnW74Lp^rf7-OQxBr0X70m5hiX2kkU_i;o9?;ijC_|fh$E F008vbMos_# literal 0 HcmV?d00001 diff --git a/packages/supabase/sql/pgpm-supabase--0.1.0.sql b/packages/supabase/sql/pgpm-supabase--0.1.0.sql new file mode 100644 index 000000000..631edda70 --- /dev/null +++ b/packages/supabase/sql/pgpm-supabase--0.1.0.sql @@ -0,0 +1,34 @@ +\echo Use "CREATE EXTENSION pgpm-supabase" to load this file. \quit +CREATE SCHEMA supabase_integration; + +GRANT USAGE ON SCHEMA supabase_integration TO anon, authenticated; + +DO $EOFCODE$ +BEGIN + IF current_setting('server_version_num')::integer >= 160000 THEN + GRANT anonymous TO anon WITH INHERIT FALSE, SET TRUE; + ELSE + GRANT anonymous TO anon; + END IF; +END; +$EOFCODE$; + +CREATE FUNCTION supabase_integration.pre_request() RETURNS void LANGUAGE plpgsql AS $EOFCODE$ +DECLARE + subject text; +BEGIN + IF current_user = 'anon' THEN + PERFORM set_config('role', 'anonymous', true); + ELSIF current_user = 'authenticated' THEN + subject := nullif(current_setting('request.jwt.claims', true), '')::jsonb ->> 'sub'; + IF subject IS NOT NULL AND subject <> '' THEN + PERFORM set_config('jwt.claims.user_id', subject, true); + PERFORM set_config('jwt.claims.principal_id', subject, true); + END IF; + END IF; +END; +$EOFCODE$; + +REVOKE ALL ON FUNCTION supabase_integration.pre_request() FROM PUBLIC RESTRICT; + +GRANT EXECUTE ON FUNCTION supabase_integration.pre_request() TO anon, authenticated; \ No newline at end of file diff --git a/packages/supabase/verify/roles/anon.sql b/packages/supabase/verify/roles/anon.sql new file mode 100644 index 000000000..4fefd7cdd --- /dev/null +++ b/packages/supabase/verify/roles/anon.sql @@ -0,0 +1,12 @@ +-- Verify roles/anon from pg + +BEGIN; + +DO $$ +BEGIN + ASSERT pg_has_role('anon', 'anonymous', 'MEMBER'); + ASSERT NOT pg_has_role('anon', 'anonymous', 'USAGE'); +END; +$$; + +ROLLBACK; diff --git a/packages/supabase/verify/schemas/supabase_integration/procedures/pre_request.sql b/packages/supabase/verify/schemas/supabase_integration/procedures/pre_request.sql new file mode 100644 index 000000000..4eb1fd3f2 --- /dev/null +++ b/packages/supabase/verify/schemas/supabase_integration/procedures/pre_request.sql @@ -0,0 +1,15 @@ +-- Verify schemas/supabase_integration/procedures/pre_request from pg + +BEGIN; + +SELECT assert_function('supabase_integration.pre_request()'::regprocedure); + +DO $$ +BEGIN + ASSERT has_function_privilege('anon', 'supabase_integration.pre_request()', 'EXECUTE'); + ASSERT has_function_privilege('authenticated', 'supabase_integration.pre_request()', 'EXECUTE'); + ASSERT NOT (SELECT prosecdef FROM pg_proc WHERE oid = 'supabase_integration.pre_request()'::regprocedure); +END; +$$; + +ROLLBACK; diff --git a/packages/supabase/verify/schemas/supabase_integration/schema.sql b/packages/supabase/verify/schemas/supabase_integration/schema.sql new file mode 100644 index 000000000..aa37bdae4 --- /dev/null +++ b/packages/supabase/verify/schemas/supabase_integration/schema.sql @@ -0,0 +1,14 @@ +-- Verify schemas/supabase_integration/schema from pg + +BEGIN; + +SELECT assert_schema('supabase_integration'::regnamespace); + +DO $$ +BEGIN + ASSERT has_schema_privilege('anon', 'supabase_integration', 'USAGE'); + ASSERT has_schema_privilege('authenticated', 'supabase_integration', 'USAGE'); +END; +$$; + +ROLLBACK; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 92051e6a4..ce6b4b7c6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -404,6 +404,19 @@ importers: specifier: ^5 version: 5.8.0(@dataplan/json@1.0.0(grafast@1.0.2(graphql@16.13.0)))(@dataplan/pg@1.0.3(@dataplan/json@1.0.0(grafast@1.0.2(graphql@16.13.0)))(grafast@1.0.2(graphql@16.13.0))(graphile-config@1.0.1)(graphql@16.13.0)(pg-sql2@5.0.1)(pg@8.22.0))(@types/node@22.19.17)(grafserv@1.0.0(@types/node@22.19.17)(grafast@1.0.2(graphql@16.13.0))(graphile-config@1.0.1)(graphql@16.13.0)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)(use-sync-external-store@1.6.0(react@19.2.5))(ws@8.20.0))(graphile-build@5.0.2(grafast@1.0.2(graphql@16.13.0))(graphile-config@1.0.1)(graphql@16.13.0))(pg-sql2@5.0.1)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)(tamedevil@0.1.1)(use-sync-external-store@1.6.0(react@19.2.5))(ws@8.20.0) + packages/supabase: + dependencies: + "@pgpm/verify": + specifier: workspace:* + version: link:../verify + devDependencies: + pgpm: + specifier: ^5 + version: 5.8.0(@dataplan/json@1.0.0(grafast@1.0.2(graphql@16.13.0)))(@dataplan/pg@1.0.3(@dataplan/json@1.0.0(grafast@1.0.2(graphql@16.13.0)))(grafast@1.0.2(graphql@16.13.0))(graphile-config@1.0.1)(graphql@16.13.0)(pg-sql2@5.0.1)(pg@8.22.0))(@types/node@22.19.17)(grafserv@1.0.0(@types/node@22.19.17)(grafast@1.0.2(graphql@16.13.0))(graphile-config@1.0.1)(graphql@16.13.0)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)(use-sync-external-store@1.6.0(react@19.2.5))(ws@8.20.0))(graphile-build@5.0.2(grafast@1.0.2(graphql@16.13.0))(graphile-config@1.0.1)(graphql@16.13.0))(pg-sql2@5.0.1)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)(tamedevil@0.1.1)(use-sync-external-store@1.6.0(react@19.2.5))(ws@8.20.0) + pgsql-test: + specifier: ^5.20.13 + version: 5.20.13 + packages: 12factor-env@1.27.1: resolution: @@ -9294,6 +9307,110 @@ packages: use-sync-external-store: optional: true + 12factor-env@1.34.0: + resolution: + integrity: sha512-jyeOuen3cbNn2EKmRkbayXsNKxqeeHGnL84to4RiLoOAOa7IG98z8kJXLKO70+0yE8wrsRGIlR2UVf7xKbr21g== + "@constructive-io/coerce@0.6.0": + resolution: + integrity: sha512-1R3colAQqLmEZ5AyMoX2nO3Lv8Sjp76JoJcmOcWphpKqmpHOraUDLOluBXTHCHY2+ERywICwkkm4oJozoybSMw== + "@constructive-io/errors@0.26.0": + resolution: + integrity: sha512-2Qo08JZQOVu/dn0A7pEUniIicTQdwM0Zbp1Z0d80jxO47J7evH6r59sb4p4+ZnXlbo5jdv/9RGiSt7xJ7khfDw== + "@pgpmjs/ast@0.16.3": + resolution: + integrity: sha512-x8Ov6iQJWzhc9vIqb3wpxSxZkI1ktesscgPD3zLMJY1OdG+BGGRSSMWn4ndT1HLaFiCGOMFbsO3RPyEu3tAA0g== + "@pgpmjs/bundle@0.19.3": + resolution: + integrity: sha512-bxsibsN9lALyiB5uIuchhjiM9sayQL4/ImezJ2K7fmeDB8BuWOogFp+l9mGaxHriVuUWD4m39S9xS+V9TsxkPw== + "@pgpmjs/core@7.35.13": + resolution: + integrity: sha512-RQuWcJG9rDGQXMtsX137l3CALDVgQ9inVxU7rT7dxdvJzkYabvKFL7Po4JgfJHyg/5ZR8yVH65va4gK59YsE4g== + "@pgpmjs/diff@0.10.12": + resolution: + integrity: sha512-GKzR7CDNUjRwwuz3Sgqov+26CT0xMbV8PZJaMkk6zz2KNDCSHCyGVEiTSzajgMdaNBlZkr5XcT2vW7Ar/QF+pA== + "@pgpmjs/env@2.48.3": + resolution: + integrity: sha512-4IEDMUiDtYBi5arOlCukW01D3Y51jfztZr+zXrtvCwKrHwfGmNic30z/Oai3VqqZsP2n30AohkIcUuJytu+syA== + "@pgpmjs/logger@2.27.0": + resolution: + integrity: sha512-Jx6arlQdICAtPFbKy9Zmo8U48gAJkwQEnzDqFRTN7Pgbd5ty5m9lGN1BbYm23UJMT8Ap6z3p80P16voffBOs6w== + "@pgpmjs/naming-spec@0.6.2": + resolution: + integrity: sha512-J5t4rpGESP92vjGiY/B97Pu4heOAZ+t+RbMq6mRRWa5pgoLYRtLNoGbFu1yhbeELtjCe9nXX1kU/1Ztg+5qDvw== + "@pgpmjs/server-utils@3.30.3": + resolution: + integrity: sha512-nMT0nA/tbhSi6yOjVIJfDl8KL91QkJ/GP98hgPOMWCLNG6c/TRDk+VmHA/et9Raw2iiL9pHotpc3uPzDozTP0Q== + "@pgpmjs/slice@0.21.12": + resolution: + integrity: sha512-8f2mpH1/0C2kPkGEHpo4CPazg/IjmWG7+vx2z0KF45cmlW8LEiFJINHzPZAjQCjPxaccwyeEPmonLtUR4ey5ZQ== + "@pgpmjs/transform@0.32.8": + resolution: + integrity: sha512-2NxWSGNZemLRBRUHvNRLuWsfCAHK2qQFvo4Abv4ZhnFFmr5Q+RaAkmsUGqDr9v/fWw0QHqV1qzVOzJEeWD+Q9A== + "@pgpmjs/traverse@0.16.3": + resolution: + integrity: sha512-e/Skd3xoGjHj7Z6ZFldLQpGANNBbOzlInzRuLC5NfIUY3O65W1UwtV/DxbTcDLyMqza2UC2TT+0QQygIKS/WaQ== + "@pgpmjs/types@2.58.3": + resolution: + integrity: sha512-LLvrloG2iv90y3CH2Q7G0HdUzCF/R3AawmUDXRHdXvZgsJrNFjMaoj8Lvin06gQSvSosb+elhyZKvhoO/vU06Q== + "@pgsql/scripts@18.5.9": + resolution: + integrity: sha512-GP+QSrgZWkB4lgkDCCoYTRwmBwJjwQw6NlXeAm80k+iymjwlGkMaRt8DzBaa69tYFzoq2LyHaYPs8j3StP8qOg== + "@pgsql/semantics@18.2.9": + resolution: + integrity: sha512-SvMjcYyv5HKVTYCcZT2u+SqBjIevaQd9Mh4PQkd4HVm3nm//SHgTbzFXhr+GxPxxbe/vHhUCmglYCnsSg4xfZQ== + "@pgsql/transform@18.18.9": + resolution: + integrity: sha512-uxc+4dptLDM+UcsApeGToqCk9wLiCJML2cVT7MfHw1EP0i3M/cUbRQWls88i9ukQVCiP7D53bdYoK3K7Ym8H0g== + "@pgsql/traverse@18.8.9": + resolution: + integrity: sha512-SxkP0sSrOTCRbyeV9c8qw3pOaimr9SBJi5eyBPXWaA4OlpxyA4cviGynOBQBUqlLm7bHoowjiEYLsN3cR2ALiQ== + "@pgsql/utils@18.3.9": + resolution: + integrity: sha512-+3B46FmyN76JPAFbMWdFC+arZq8MmcQuAvdPIjJX4xCLUdzHKEwe3ybVGa1bE72Vc6IVMOMk31JAY9OUuAqPgQ== + csv-to-pg@4.16.6: + resolution: + integrity: sha512-Dnlhn4H1/dEP4FOfvnxoUDED7d4ilWJ84Ek9eFC52czasbSRZar23v14poMXQUU0xDGDJeW92BUHnZLxOxHmIA== + hasBin: true + genomic@5.6.6: + resolution: + integrity: sha512-Rcw2Q8U4c9GfoAPS5lkpY4Dtm2rvRTtS8AK4awCejlWfe6m0P0dtp2gusixsoOuPWL9VAWm616/skbPkKFeBbw== + inquirerer@4.9.4: + resolution: + integrity: sha512-ALS4QpTbm9geTdRelvU1Cg4gaFEWBf2rc/5Qqd6cUZcaTqTXLGyfE4/g3Os2wm6f4H+4RNuZyZ94n+7OHr7D7A== + libpg-query@18.2.4: + resolution: + integrity: sha512-7nqWUm+39v/fYgWP0qR+sYC7tyhmW8lctqAzx7bdKG6V0ySr9G1lcY43BdZM5+lxVSzL0Y5Yy6eM9e+uL7T79w== + pg-cache@3.30.3: + resolution: + integrity: sha512-SDW3pYrK2udVElcdoIqgXf76bKFkG1I8R+MPmWrR40H6jeUe8sn6D36KGC6NqtLB9kH1RmtqXnhYBUuKaon9gQ== + pg-env@1.33.0: + resolution: + integrity: sha512-OslZMDKoqoIv0sy+omJ8Jy6Vlc5CnHpboPwUL4nUV7usydff7bSRMsZNLOwN4c89/ZT4nyaHG1/58ujQvErVnA== + pg-seed@0.30.0: + resolution: + integrity: sha512-/xDOFqgNl6yZV/osCAUW6dbucOq8X6g+VuN59M1N1AnU2r135nj9THI2dYoctB2fIQXlRptt9jwNdxjWMONgfA== + pgsql-client@4.18.13: + resolution: + integrity: sha512-LyOJOWamIl4B/8Pr++p+x/SFK6kt5nzTLoDPx/bUu22CkP9kNKiJm+rNZssNSjcoyaiTIceDJSNJ0i0SIWWjkw== + pgsql-deparser@18.5.2: + resolution: + integrity: sha512-vR+qGJf6eU8Qbs06AGjTklAAucE+oz1NEAH3RlGwGGSBTpFpD7q4GYsriDB+24Y7FZxi8C00kFnsAtvJPP90ug== + pgsql-parser@18.4.2: + resolution: + integrity: sha512-Gjm85k5ZTt8rlXDIzviF9I3C7oGvkZD/4KEb7v0EjjjRvXnOP0hAG217UbebstyTFjD13QWk9jtEan9siL2Icw== + pgsql-seed@3.17.13: + resolution: + integrity: sha512-XfReTj/2YEK40/CaXXRblvXNjWBo657+ja4XZKB1pedB3jwr4AgPqD1nGtRN7V0iyK5/Mg1LpNLxvuriXdQ7TA== + pgsql-test@5.20.13: + resolution: + integrity: sha512-u8UulmHfUziKW6eXusp4hzkvUoHn8pqv4sd04tNuKE+z8C34ri8PBo9uuK4DAK0RgGvrn33UFNvoTbnjPoMpeQ== + plpgsql-deparser@18.3.8: + resolution: + integrity: sha512-DBnv+lXcitiXrd9hZmL68biiey1zB7KGvHHyZVR00+gXuA4ZYc3ryOCKtFLqEo7wTek1S5nOxtYJJoQhIIJFfg== + plpgsql-parser@18.6.9: + resolution: + integrity: sha512-Q2I/bu8V9San2HA9rVCqFhG+/lykT5B4eSq11+QIa0gZNTEhuWrqLrYQMKp68q9h1ooUXWq/XAkQFvMnC9esxQ== + snapshots: 12factor-env@1.27.1: dependencies: @@ -15750,3 +15867,209 @@ snapshots: optionalDependencies: react: 19.2.5 use-sync-external-store: 1.6.0(react@19.2.5) + + 12factor-env@1.34.0: + dependencies: + "@constructive-io/coerce": 0.6.0 + envalid: 8.2.0 + "@constructive-io/coerce@0.6.0": {} + "@constructive-io/errors@0.26.0": {} + "@pgpmjs/ast@0.16.3": + dependencies: + "@pgpmjs/env": 2.48.3 + "@pgpmjs/types": 2.58.3 + "@pgpmjs/bundle@0.19.3": + dependencies: + "@pgpmjs/ast": 0.16.3 + "@pgpmjs/traverse": 0.16.3 + "@pgpmjs/core@7.35.13": + dependencies: + "@pgpmjs/ast": 0.16.3 + "@pgpmjs/bundle": 0.19.3 + "@pgpmjs/diff": 0.10.12 + "@pgpmjs/env": 2.48.3 + "@pgpmjs/logger": 2.27.0 + "@pgpmjs/server-utils": 3.30.3 + "@pgpmjs/slice": 0.21.12 + "@pgpmjs/transform": 0.32.8 + "@pgpmjs/types": 2.58.3 + cross-spawn: 7.0.6 + csv-to-pg: 4.16.6 + genomic: 5.6.6 + git-changed: 0.4.0 + glob: 13.0.6 + parse-package-name: 1.0.0 + pg: 8.22.0 + pg-cache: 3.30.3 + pg-env: 1.33.0 + pgsql-deparser: 18.5.2 + pgsql-parser: 18.4.2 + semver: 7.8.5 + yaml: 2.9.0 + yanse: 0.2.2 + transitivePeerDependencies: + - pg-native + - supports-color + "@pgpmjs/diff@0.10.12": + dependencies: + "@pgpmjs/ast": 0.16.3 + "@pgpmjs/naming-spec": 0.6.2 + "@pgpmjs/transform": 0.32.8 + "@pgpmjs/env@2.48.3": + dependencies: + 12factor-env: 1.34.0 + "@pgpmjs/types": 2.58.3 + deepmerge: 4.3.1 + "@pgpmjs/logger@2.27.0": + dependencies: + yanse: 0.2.2 + "@pgpmjs/naming-spec@0.6.2": {} + "@pgpmjs/server-utils@3.30.3": + dependencies: + "@pgpmjs/logger": 2.27.0 + "@pgpmjs/types": 2.58.3 + cors: 2.8.6 + express: 5.2.1 + lru-cache: 11.3.5 + transitivePeerDependencies: + - supports-color + "@pgpmjs/slice@0.21.12": + dependencies: + "@pgpmjs/ast": 0.16.3 + "@pgpmjs/transform": 0.32.8 + minimatch: 10.2.6 + plpgsql-parser: 18.6.9 + "@pgpmjs/transform@0.32.8": + dependencies: + "@pgpmjs/ast": 0.16.3 + "@pgpmjs/naming-spec": 0.6.2 + "@pgsql/scripts": 18.5.9 + "@pgsql/semantics": 18.2.9 + "@pgsql/transform": 18.18.9 + plpgsql-parser: 18.6.9 + "@pgpmjs/traverse@0.16.3": + dependencies: + "@pgpmjs/ast": 0.16.3 + "@pgpmjs/types@2.58.3": + dependencies: + "@constructive-io/errors": 0.26.0 + pg-env: 1.33.0 + "@pgsql/scripts@18.5.9": + dependencies: + "@pgsql/quotes": 18.2.4 + "@pgsql/transform": 18.18.9 + plpgsql-parser: 18.6.9 + "@pgsql/semantics@18.2.9": + dependencies: + "@pgsql/traverse": 18.8.9 + plpgsql-parser: 18.6.9 + "@pgsql/transform@18.18.9": + dependencies: + "@pgsql/quotes": 18.2.4 + "@pgsql/semantics": 18.2.9 + "@pgsql/traverse": 18.8.9 + plpgsql-parser: 18.6.9 + "@pgsql/traverse@18.8.9": + dependencies: + "@pgsql/types": 18.0.0 + plpgsql-deparser: 18.3.8 + "@pgsql/utils@18.3.9": + dependencies: + "@pgsql/types": 18.0.0 + nested-obj: 0.2.3 + csv-to-pg@4.16.6: + dependencies: + "@pgsql/types": 18.0.0 + "@pgsql/utils": 18.3.9 + csv-parser: 3.2.1 + inquirerer: 4.9.4 + js-yaml: 4.1.1 + pgsql-deparser: 18.5.2 + genomic@5.6.6: + dependencies: + appstash: 0.8.0 + inquirerer: 4.9.4 + inquirerer@4.9.4: + dependencies: + deepmerge: 4.3.1 + find-and-require-package-json: 0.9.1 + minimist: 1.2.8 + yanse: 0.2.2 + libpg-query@18.2.4: + dependencies: + "@pgsql/types": 18.0.0 + pg-cache@3.30.3: + dependencies: + 12factor-env: 1.34.0 + "@pgpmjs/logger": 2.27.0 + "@pgpmjs/types": 2.58.3 + lru-cache: 11.3.5 + pg: 8.22.0 + pg-env: 1.33.0 + transitivePeerDependencies: + - pg-native + pg-env@1.33.0: + dependencies: + 12factor-env: 1.34.0 + pg-seed@0.30.0: + dependencies: + csv-parse: 6.2.1 + pg: 8.22.0 + pg-copy-streams: 7.0.0 + transitivePeerDependencies: + - pg-native + pgsql-client@4.18.13: + dependencies: + "@pgpmjs/core": 7.35.13 + "@pgpmjs/logger": 2.27.0 + "@pgpmjs/types": 2.58.3 + pg: 8.22.0 + pg-env: 1.33.0 + transitivePeerDependencies: + - pg-native + - supports-color + pgsql-deparser@18.5.2: + dependencies: + "@pgsql/quotes": 18.2.4 + "@pgsql/types": 18.0.0 + pgsql-parser@18.4.2: + dependencies: + "@pgsql/types": 18.0.0 + libpg-query: 18.2.4 + pgsql-deparser: 18.5.2 + pgsql-seed@3.17.13: + dependencies: + "@pgpmjs/core": 7.35.13 + "@pgpmjs/env": 2.48.3 + pg: 8.22.0 + pg-env: 1.33.0 + pg-seed: 0.30.0 + transitivePeerDependencies: + - pg-native + - supports-color + pgsql-test@5.20.13: + dependencies: + "@pgpmjs/env": 2.48.3 + "@pgpmjs/logger": 2.27.0 + "@pgpmjs/server-utils": 3.30.3 + "@pgpmjs/types": 2.58.3 + pg: 8.22.0 + pg-cache: 3.30.3 + pg-env: 1.33.0 + pgsql-client: 4.18.13 + pgsql-seed: 3.17.13 + transitivePeerDependencies: + - pg-native + - supports-color + plpgsql-deparser@18.3.8: + dependencies: + "@pgsql/types": 18.0.0 + libpg-query: 18.2.4 + pgsql-deparser: 18.5.2 + plpgsql-parser@18.6.9: + dependencies: + "@pgsql/traverse": 18.8.9 + "@pgsql/types": 18.0.0 + libpg-query: 18.2.4 + pgsql-deparser: 18.5.2 + plpgsql-deparser: 18.3.8 From a61e41bcc21cd263285dcc6517310ad151ca6482 Mon Sep 17 00:00:00 2001 From: Dan Lynch Date: Sun, 22 Nov 2026 01:56:08 +0000 Subject: [PATCH 2/7] fix(supabase): allow service roles to invoke pre-request hook --- packages/supabase/README.md | 4 ++++ packages/supabase/__tests__/supabase.test.ts | 9 +++++++++ .../procedures/pre_request.sql | 3 --- .../schemas/supabase_integration/schema.sql | 2 +- .../sql/pgpm-supabase--0.1.0.bundle.tar.gz | Bin 2179 -> 2224 bytes .../supabase/sql/pgpm-supabase--0.1.0.sql | 8 ++------ .../procedures/pre_request.sql | 8 ++++++-- .../schemas/supabase_integration/schema.sql | 8 ++++++-- 8 files changed, 28 insertions(+), 14 deletions(-) diff --git a/packages/supabase/README.md b/packages/supabase/README.md index 9a27f115c..9a42a0cda 100644 --- a/packages/supabase/README.md +++ b/packages/supabase/README.md @@ -16,6 +16,10 @@ Bridge Supabase PostgREST requests to Constructive's transaction-local RLS claim NOTIFY pgrst, 'reload config'; ``` +Schema USAGE and hook EXECUTE are available to PUBLIC so PostgREST can also +invoke the hook as `service_role` without requiring that role at deploy time. +The hook is a no-op for roles other than `anon` and `authenticated`. + The security-invoker hook switches `anon` to `anonymous`. It does not grant automatic inheritance: `anon` cannot use `anonymous` grants without switching. On PostgreSQL 16+ the membership explicitly disables inheritance and allows SET; diff --git a/packages/supabase/__tests__/supabase.test.ts b/packages/supabase/__tests__/supabase.test.ts index f16225d4e..d1e19dd8e 100644 --- a/packages/supabase/__tests__/supabase.test.ts +++ b/packages/supabase/__tests__/supabase.test.ts @@ -75,6 +75,15 @@ it('does nothing for other roles', async () => { .toEqual([{ unchanged: true, claim: null }]); }); +it('allows a role with no grants to call the hook as a no-op', async () => { + await pg.query('CREATE ROLE supabase_test_service NOINHERIT NOLOGIN'); + pg.setContext({ role: 'supabase_test_service', 'request.jwt.claims': JSON.stringify({ sub: userId }) }); + expect(await preRequestThen(`SELECT current_user, + nullif(current_setting('jwt.claims.user_id', true), '') AS claim, + nullif(current_setting('jwt.claims.principal_id', true), '') AS principal`)) + .toEqual([{ current_user: 'supabase_test_service', claim: null, principal: null }]); +}); + it('rejects malformed JWT JSON', async () => { pg.setContext({ role: 'authenticated', 'request.jwt.claims': 'invalid' }); await pg.expectError(() => pg.query('SELECT supabase_integration.pre_request()'), /invalid input syntax for type json/); diff --git a/packages/supabase/deploy/schemas/supabase_integration/procedures/pre_request.sql b/packages/supabase/deploy/schemas/supabase_integration/procedures/pre_request.sql index daf231b4a..b10a807b5 100644 --- a/packages/supabase/deploy/schemas/supabase_integration/procedures/pre_request.sql +++ b/packages/supabase/deploy/schemas/supabase_integration/procedures/pre_request.sql @@ -21,7 +21,4 @@ BEGIN END; $$; -REVOKE ALL ON FUNCTION supabase_integration.pre_request() FROM PUBLIC; -GRANT EXECUTE ON FUNCTION supabase_integration.pre_request() TO anon, authenticated; - COMMIT; diff --git a/packages/supabase/deploy/schemas/supabase_integration/schema.sql b/packages/supabase/deploy/schemas/supabase_integration/schema.sql index 59ae34e7d..3d6aeafff 100644 --- a/packages/supabase/deploy/schemas/supabase_integration/schema.sql +++ b/packages/supabase/deploy/schemas/supabase_integration/schema.sql @@ -4,6 +4,6 @@ BEGIN; CREATE SCHEMA supabase_integration; -GRANT USAGE ON SCHEMA supabase_integration TO anon, authenticated; +GRANT USAGE ON SCHEMA supabase_integration TO PUBLIC; COMMIT; diff --git a/packages/supabase/sql/pgpm-supabase--0.1.0.bundle.tar.gz b/packages/supabase/sql/pgpm-supabase--0.1.0.bundle.tar.gz index 17bd489f0226222fc239ed9d620035a704ab6a93..b01d7499d3f3d2b0638243e6c7e9538567dc4409 100644 GIT binary patch literal 2224 zcmV;h2v7GPiwFP!000021MOLPPaDY+&)@kJEpJu^2}s`uY@$bCNYH{E*=Be3))DHX z+L=5vGdnY86Rq~UKaCG;h#`>8M(;=qVbfJzRsHKax|(8CTx`2Z7RIpiuFA7Vf5X5S zW6AmS6JvbilSoX&Vs1W92o~ZIe)JW_q^fQC2!9n_|AFI=#|X79Y?el->eeo5{zj-3 z^YX&hKS5cgdDhxREz;VWQ8If0%|y{SPBkg4vlT3ez64uC_&KfLHa!1mnBG-SeO@kE z-r8&g2l*sx)Uo+&fMT3~=#~M>)-L*WI*CxL@^9h7R!-ll4R@$U5JpXeaZs=A!`I=uw+Lx4*d z=LMA2Kl}<|C(WOu?~n}v-9ynZTb=>>^&Sh}d>PZ0T0eou`V+sGsVhp}d<8()TRNP% zcFX5kUFPGJcumL9Sr?f*3)V&WJ@mZM-$*xr8!}AEq4R+}ql^aU&?&aT5^Lq=0f#LAjh-2Hq_9 zR96}1k42hTB((?Sn*ar50WzP?M7~+2jPnmyr!$@VSDJ-J#hkXaq*T8(2ie-*Mu$_{ zeIgCjIVwg?{J%(E9(VSdZwI|(e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fc4a28 100644 --- a/packages/supabase/sql/pgpm-supabase--0.1.0.sql +++ b/packages/supabase/sql/pgpm-supabase--0.1.0.sql @@ -1,7 +1,7 @@ \echo Use "CREATE EXTENSION pgpm-supabase" to load this file. \quit CREATE SCHEMA supabase_integration; -GRANT USAGE ON SCHEMA supabase_integration TO anon, authenticated; +GRANT USAGE ON SCHEMA supabase_integration TO PUBLIC; DO $EOFCODE$ BEGIN @@ -27,8 +27,4 @@ BEGIN END IF; END IF; END; -$EOFCODE$; - -REVOKE ALL ON FUNCTION supabase_integration.pre_request() FROM PUBLIC RESTRICT; - -GRANT EXECUTE ON FUNCTION supabase_integration.pre_request() TO anon, authenticated; \ No newline at end of file +$EOFCODE$; \ No newline at end of file diff --git a/packages/supabase/verify/schemas/supabase_integration/procedures/pre_request.sql b/packages/supabase/verify/schemas/supabase_integration/procedures/pre_request.sql index 4eb1fd3f2..769d9d7b1 100644 --- a/packages/supabase/verify/schemas/supabase_integration/procedures/pre_request.sql +++ b/packages/supabase/verify/schemas/supabase_integration/procedures/pre_request.sql @@ -6,8 +6,12 @@ SELECT assert_function('supabase_integration.pre_request()'::regprocedure); DO $$ BEGIN - ASSERT has_function_privilege('anon', 'supabase_integration.pre_request()', 'EXECUTE'); - ASSERT has_function_privilege('authenticated', 'supabase_integration.pre_request()', 'EXECUTE'); + ASSERT EXISTS ( + SELECT FROM pg_proc, + LATERAL aclexplode(coalesce(proacl, acldefault('f', proowner))) AS privilege + WHERE oid = 'supabase_integration.pre_request()'::regprocedure + AND privilege.grantee = 0 AND privilege.privilege_type = 'EXECUTE' + ); ASSERT NOT (SELECT prosecdef FROM pg_proc WHERE oid = 'supabase_integration.pre_request()'::regprocedure); END; $$; diff --git a/packages/supabase/verify/schemas/supabase_integration/schema.sql b/packages/supabase/verify/schemas/supabase_integration/schema.sql index aa37bdae4..55e21ee39 100644 --- a/packages/supabase/verify/schemas/supabase_integration/schema.sql +++ b/packages/supabase/verify/schemas/supabase_integration/schema.sql @@ -6,8 +6,12 @@ SELECT assert_schema('supabase_integration'::regnamespace); DO $$ BEGIN - ASSERT has_schema_privilege('anon', 'supabase_integration', 'USAGE'); - ASSERT has_schema_privilege('authenticated', 'supabase_integration', 'USAGE'); + ASSERT EXISTS ( + SELECT FROM pg_namespace, + LATERAL aclexplode(nspacl) AS privilege + WHERE nspname = 'supabase_integration' + AND privilege.grantee = 0 AND privilege.privilege_type = 'USAGE' + ); END; $$; From 9e72944c08e2022522000c4906e45fef72897da3 Mon Sep 17 00:00:00 2001 From: Dan Lynch Date: Sun, 22 Nov 2026 02:01:09 +0000 Subject: [PATCH 3/7] fix(supabase): declare verification plan dependencies --- packages/supabase/pgpm.plan | 2 +- .../sql/pgpm-supabase--0.1.0.bundle.tar.gz | Bin 2224 -> 2246 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/supabase/pgpm.plan b/packages/supabase/pgpm.plan index d22b12639..efda0e70f 100644 --- a/packages/supabase/pgpm.plan +++ b/packages/supabase/pgpm.plan @@ -2,6 +2,6 @@ %project=pgpm-supabase %uri=pgpm-supabase -schemas/supabase_integration/schema 2026-08-27T00:00:00Z Constructive # add schemas/supabase_integration/schema +schemas/supabase_integration/schema [pgpm-verify:procedures/assert_schema pgpm-verify:procedures/assert_function] 2026-08-27T00:00:00Z Constructive # add schemas/supabase_integration/schema roles/anon [schemas/supabase_integration/schema] 2026-08-27T00:00:00Z Constructive # add roles/anon schemas/supabase_integration/procedures/pre_request [schemas/supabase_integration/schema roles/anon] 2026-08-27T00:00:00Z Constructive # add schemas/supabase_integration/procedures/pre_request diff --git a/packages/supabase/sql/pgpm-supabase--0.1.0.bundle.tar.gz b/packages/supabase/sql/pgpm-supabase--0.1.0.bundle.tar.gz index b01d7499d3f3d2b0638243e6c7e9538567dc4409..05ab069eb4b29987aeb75d7903edd9c7e1a4fa4d 100644 GIT binary patch delta 2195 zcmV;E2yFMT5ylaJABzY8000000t4+>d2icB7SG@L6azJdY`}5mKI|r_V$+FHTM8t( z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#Ihhf8{RnmRPyHt9(GL z-0Kpgqjp{xCzUmta7Ta=Nv(=FV#OOW1Oqb25TwW6SmmAbmSAOp2lIb*yUd56b-nA1 zlgu|F*7u#)ahr9aSGqpG3vEQ))qwikj-m3fQIxs$;c{K1A-r|)=6};Og7%Ma^?G0EdTe4J+dJaIj36xI%e Date: Sun, 22 Nov 2026 02:01:29 +0000 Subject: [PATCH 4/7] fix(supabase): grant hook execution despite secure defaults --- .../procedures/pre_request.sql | 2 ++ .../sql/pgpm-supabase--0.1.0.bundle.tar.gz | Bin 2246 -> 2264 bytes .../supabase/sql/pgpm-supabase--0.1.0.sql | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/supabase/deploy/schemas/supabase_integration/procedures/pre_request.sql b/packages/supabase/deploy/schemas/supabase_integration/procedures/pre_request.sql index b10a807b5..dddd47645 100644 --- a/packages/supabase/deploy/schemas/supabase_integration/procedures/pre_request.sql +++ b/packages/supabase/deploy/schemas/supabase_integration/procedures/pre_request.sql @@ -21,4 +21,6 @@ BEGIN END; $$; +GRANT EXECUTE ON FUNCTION supabase_integration.pre_request() TO PUBLIC; + COMMIT; diff --git a/packages/supabase/sql/pgpm-supabase--0.1.0.bundle.tar.gz b/packages/supabase/sql/pgpm-supabase--0.1.0.bundle.tar.gz index 05ab069eb4b29987aeb75d7903edd9c7e1a4fa4d..9af1b63ea9c9ce219d4900602d935b29b60ef712 100644 GIT binary patch delta 2206 zcmV;P2x0fe5!exbABzY8000000t4+>d2ids63^fH6bm(lY`}5$KI|r_V$+FHTM8t( zEnXEEd(0|KWs)T+H$l<~p|64Ny$-kG(QL+1f$B%r+5fRsJ2E+3MNyp3^j|VO-ie&9i57 z;zBM$tumi~K=sUKd3L#XtAL`+J%niq)w806(-MB0HXzK-zFjJoj_1I%An+)y2{>Zs zxbX&Kz!(?~l6YmXi-J~QMZetRz-LnJ^42@hUGG2lQg!8$F9GO!O-J)UY56>>%Y3pD{pkd{>*9QS$+`^Y zJgZ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O*M9(1+jiFgBme+k)kTp2 diff --git a/packages/supabase/sql/pgpm-supabase--0.1.0.sql b/packages/supabase/sql/pgpm-supabase--0.1.0.sql index 3f8fc4a28..bc75b1e31 100644 --- a/packages/supabase/sql/pgpm-supabase--0.1.0.sql +++ b/packages/supabase/sql/pgpm-supabase--0.1.0.sql @@ -27,4 +27,6 @@ BEGIN END IF; END IF; END; -$EOFCODE$; \ No newline at end of file +$EOFCODE$; + +GRANT EXECUTE ON FUNCTION supabase_integration.pre_request() TO PUBLIC; \ No newline at end of file From 1afb9fc7963c8b4c77f8db0700ebc273dfa5c193 Mon Sep 17 00:00:00 2001 From: Dan Lynch Date: Sun, 22 Nov 2026 02:21:21 +0000 Subject: [PATCH 5/7] refactor(supabase-integration): rename package to avoid @pgpm/supabase collision --- .github/workflows/ci.yml | 2 +- MODULES.md | 2 +- .../.npmignore | 0 .../{supabase => supabase-integration}/LICENSE | 0 packages/supabase-integration/Makefile | 6 ++++++ .../{supabase => supabase-integration}/README.md | 4 ++-- .../__tests__/supabase.test.ts | 0 .../deploy/roles/anon.sql | 0 .../procedures/pre_request.sql | 0 .../schemas/supabase_integration/schema.sql | 0 .../jest.config.js | 0 .../package.json | 2 +- .../pgpm-supabase-integration.control} | 4 ++-- .../{supabase => supabase-integration}/pgpm.plan | 4 ++-- .../revert/roles/anon.sql | 0 .../procedures/pre_request.sql | 0 .../schemas/supabase_integration/schema.sql | 0 ...gpm-supabase-integration--0.1.0.bundle.tar.gz | Bin 0 -> 2266 bytes .../sql/pgpm-supabase-integration--0.1.0.sql} | 2 +- .../verify/roles/anon.sql | 0 .../procedures/pre_request.sql | 0 .../schemas/supabase_integration/schema.sql | 0 packages/supabase/Makefile | 6 ------ .../sql/pgpm-supabase--0.1.0.bundle.tar.gz | Bin 2264 -> 0 bytes pnpm-lock.yaml | 2 +- 25 files changed, 17 insertions(+), 17 deletions(-) rename packages/{supabase => supabase-integration}/.npmignore (100%) rename packages/{supabase => supabase-integration}/LICENSE (100%) create mode 100644 packages/supabase-integration/Makefile rename packages/{supabase => supabase-integration}/README.md (94%) rename packages/{supabase => supabase-integration}/__tests__/supabase.test.ts (100%) rename packages/{supabase => supabase-integration}/deploy/roles/anon.sql (100%) rename packages/{supabase => supabase-integration}/deploy/schemas/supabase_integration/procedures/pre_request.sql (100%) rename packages/{supabase => supabase-integration}/deploy/schemas/supabase_integration/schema.sql (100%) rename packages/{supabase => supabase-integration}/jest.config.js (100%) rename packages/{supabase => supabase-integration}/package.json (95%) rename packages/{supabase/pgpm-supabase.control => supabase-integration/pgpm-supabase-integration.control} (63%) rename packages/{supabase => supabase-integration}/pgpm.plan (89%) rename packages/{supabase => supabase-integration}/revert/roles/anon.sql (100%) rename packages/{supabase => supabase-integration}/revert/schemas/supabase_integration/procedures/pre_request.sql (100%) rename packages/{supabase => supabase-integration}/revert/schemas/supabase_integration/schema.sql (100%) create mode 100644 packages/supabase-integration/sql/pgpm-supabase-integration--0.1.0.bundle.tar.gz rename packages/{supabase/sql/pgpm-supabase--0.1.0.sql => supabase-integration/sql/pgpm-supabase-integration--0.1.0.sql} (92%) rename packages/{supabase => supabase-integration}/verify/roles/anon.sql (100%) rename packages/{supabase => supabase-integration}/verify/schemas/supabase_integration/procedures/pre_request.sql (100%) rename packages/{supabase => supabase-integration}/verify/schemas/supabase_integration/schema.sql (100%) delete mode 100644 packages/supabase/Makefile delete mode 100644 packages/supabase/sql/pgpm-supabase--0.1.0.bundle.tar.gz diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0e86edfe..3b2f3c20a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: - base32 - totp - jwt-claims - - supabase + - supabase-integration - defaults - measurements - metaschema-schema diff --git a/MODULES.md b/MODULES.md index f388161c2..37273a53d 100644 --- a/MODULES.md +++ b/MODULES.md @@ -46,7 +46,7 @@ ## Security & Authentication ### Core Security -- [ ] `packages/supabase` - Supabase PostgREST role and identity claim bridge +- [ ] `packages/supabase-integration` - Supabase PostgREST role and identity claim bridge - [ ] `packages/security/defaults` - Security defaults - [ ] `packages/security/jwt-claims` - JWT claim handling - [ ] `packages/security/totp` - Time-based One-Time Password (TOTP) diff --git a/packages/supabase/.npmignore b/packages/supabase-integration/.npmignore similarity index 100% rename from packages/supabase/.npmignore rename to packages/supabase-integration/.npmignore diff --git a/packages/supabase/LICENSE b/packages/supabase-integration/LICENSE similarity index 100% rename from packages/supabase/LICENSE rename to packages/supabase-integration/LICENSE diff --git a/packages/supabase-integration/Makefile b/packages/supabase-integration/Makefile new file mode 100644 index 000000000..79acbf829 --- /dev/null +++ b/packages/supabase-integration/Makefile @@ -0,0 +1,6 @@ +EXTENSION = pgpm-supabase-integration +DATA = sql/pgpm-supabase-integration--0.1.0.sql + +PG_CONFIG = pg_config +PGXS := $(shell $(PG_CONFIG) --pgxs) +include $(PGXS) diff --git a/packages/supabase/README.md b/packages/supabase-integration/README.md similarity index 94% rename from packages/supabase/README.md rename to packages/supabase-integration/README.md index 9a42a0cda..14e1d122f 100644 --- a/packages/supabase/README.md +++ b/packages/supabase-integration/README.md @@ -1,4 +1,4 @@ -# @pgpm/supabase +# @pgpm/supabase-integration Bridge Supabase PostgREST requests to Constructive's transaction-local RLS claims. @@ -8,7 +8,7 @@ Bridge Supabase PostgREST requests to Constructive's transaction-local RLS claim Constructive's `anonymous` role (and the other base roles). 2. Ensure Supabase's `anon` and `authenticated` roles already exist. Outside Supabase, create `anon` with `CREATE ROLE anon NOINHERIT NOLOGIN;` before deployment. -3. Install `@pgpm/supabase` and deploy `pgpm-supabase` with `pgpm deploy`. +3. Install `@pgpm/supabase-integration` and deploy `pgpm-supabase-integration` with `pgpm deploy`. 4. As the database administrator, configure PostgREST: ```sql diff --git a/packages/supabase/__tests__/supabase.test.ts b/packages/supabase-integration/__tests__/supabase.test.ts similarity index 100% rename from packages/supabase/__tests__/supabase.test.ts rename to packages/supabase-integration/__tests__/supabase.test.ts diff --git a/packages/supabase/deploy/roles/anon.sql b/packages/supabase-integration/deploy/roles/anon.sql similarity index 100% rename from packages/supabase/deploy/roles/anon.sql rename to packages/supabase-integration/deploy/roles/anon.sql diff --git a/packages/supabase/deploy/schemas/supabase_integration/procedures/pre_request.sql b/packages/supabase-integration/deploy/schemas/supabase_integration/procedures/pre_request.sql similarity index 100% rename from packages/supabase/deploy/schemas/supabase_integration/procedures/pre_request.sql rename to packages/supabase-integration/deploy/schemas/supabase_integration/procedures/pre_request.sql diff --git a/packages/supabase/deploy/schemas/supabase_integration/schema.sql b/packages/supabase-integration/deploy/schemas/supabase_integration/schema.sql similarity index 100% rename from packages/supabase/deploy/schemas/supabase_integration/schema.sql rename to packages/supabase-integration/deploy/schemas/supabase_integration/schema.sql diff --git a/packages/supabase/jest.config.js b/packages/supabase-integration/jest.config.js similarity index 100% rename from packages/supabase/jest.config.js rename to packages/supabase-integration/jest.config.js diff --git a/packages/supabase/package.json b/packages/supabase-integration/package.json similarity index 95% rename from packages/supabase/package.json rename to packages/supabase-integration/package.json index cc56ab92c..20fcbc6ea 100644 --- a/packages/supabase/package.json +++ b/packages/supabase-integration/package.json @@ -1,5 +1,5 @@ { - "name": "@pgpm/supabase", + "name": "@pgpm/supabase-integration", "version": "0.1.0", "description": "Bridge Supabase PostgREST requests to Constructive RLS claims", "author": "Dan Lynch ", diff --git a/packages/supabase/pgpm-supabase.control b/packages/supabase-integration/pgpm-supabase-integration.control similarity index 63% rename from packages/supabase/pgpm-supabase.control rename to packages/supabase-integration/pgpm-supabase-integration.control index f0204e979..32053dde9 100644 --- a/packages/supabase/pgpm-supabase.control +++ b/packages/supabase-integration/pgpm-supabase-integration.control @@ -1,7 +1,7 @@ -# pgpm-supabase extension +# pgpm-supabase-integration extension comment = 'Supabase PostgREST integration for Constructive' default_version = '0.1.0' -module_pathname = '$libdir/pgpm-supabase' +module_pathname = '$libdir/pgpm-supabase-integration' requires = 'plpgsql,pgpm-verify' relocatable = false superuser = false diff --git a/packages/supabase/pgpm.plan b/packages/supabase-integration/pgpm.plan similarity index 89% rename from packages/supabase/pgpm.plan rename to packages/supabase-integration/pgpm.plan index efda0e70f..8c49640b3 100644 --- a/packages/supabase/pgpm.plan +++ b/packages/supabase-integration/pgpm.plan @@ -1,6 +1,6 @@ %syntax-version=1.0.0 -%project=pgpm-supabase -%uri=pgpm-supabase +%project=pgpm-supabase-integration +%uri=pgpm-supabase-integration schemas/supabase_integration/schema [pgpm-verify:procedures/assert_schema pgpm-verify:procedures/assert_function] 2026-08-27T00:00:00Z Constructive # add schemas/supabase_integration/schema roles/anon [schemas/supabase_integration/schema] 2026-08-27T00:00:00Z Constructive # add roles/anon diff --git a/packages/supabase/revert/roles/anon.sql b/packages/supabase-integration/revert/roles/anon.sql similarity index 100% rename from packages/supabase/revert/roles/anon.sql rename to packages/supabase-integration/revert/roles/anon.sql diff --git a/packages/supabase/revert/schemas/supabase_integration/procedures/pre_request.sql b/packages/supabase-integration/revert/schemas/supabase_integration/procedures/pre_request.sql similarity index 100% rename from packages/supabase/revert/schemas/supabase_integration/procedures/pre_request.sql rename to packages/supabase-integration/revert/schemas/supabase_integration/procedures/pre_request.sql diff --git a/packages/supabase/revert/schemas/supabase_integration/schema.sql b/packages/supabase-integration/revert/schemas/supabase_integration/schema.sql similarity index 100% rename from packages/supabase/revert/schemas/supabase_integration/schema.sql rename to packages/supabase-integration/revert/schemas/supabase_integration/schema.sql diff --git a/packages/supabase-integration/sql/pgpm-supabase-integration--0.1.0.bundle.tar.gz b/packages/supabase-integration/sql/pgpm-supabase-integration--0.1.0.bundle.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..8198a3e21236e8acd5981161d250f44f000c45a8 GIT binary patch literal 2266 zcmV<02qpI)iwFP!000021MOIOZ`(!|&)@kJ12u(gz;@<7>?WvU(}_`A3M9ELwhD|n z-YCk-Btueef}-DjL0y&;$w!+8yNe72NSb%dn;+lFe3)PEx=9+wu=lRa(ntTm!Wd)8 z`ScrO{K+?wl9R>We4h|3=_CB;E38Rb+2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lPv6<GB!4wEI2&rcL(S^Ps1oX>U3Y7G|j*`@ zscYWhpc+2ZyX*aXF;~vB!iw|0N%{x9{xPbcKJ|GP)A2^Tf%SUksLLsAF1>c0+-dy| zvO4w6E4kGRmb&dcN7-~TN#n*RA-Ax7`~C0rwx8Ja?Bc>L)NZ1$c~|Vv(-$wAKGn5% z=aLT(E`%QrX8Essa&$CnNtgTIy+G|%W!Bq!dGB^(&S@IjTT2nEmfz!iQKp$s3p=?* z$VEWkRMzL&Ao)4jI~mTJ!Uwp|!v<2x1$TrK7YQ}m2`-oiZCD^eMMenm0G7~z!D%Lx z36uvcfCPsp>H~1QS3jkrc3v1Kl{K1hM}QJZt%^8e#TzmN12V`E zq{rS^<(>1EU}b>^^JNFthoE(JfL*?|SwF&F#ce*&UflK92iiu&ZL_S;?F1?h8%3F0 zKiO(%i`R7 Date: Sun, 22 Nov 2026 02:54:16 +0000 Subject: [PATCH 6/7] refactor(supabase): name the integration @pgpm/supabase at 1.0.0 --- .github/workflows/ci.yml | 2 +- MODULES.md | 2 +- packages/supabase-integration/Makefile | 6 ------ ...gpm-supabase-integration--0.1.0.bundle.tar.gz | Bin 2266 -> 0 bytes .../.npmignore | 0 .../{supabase-integration => supabase}/LICENSE | 0 packages/supabase/Makefile | 6 ++++++ .../{supabase-integration => supabase}/README.md | 4 ++-- .../__tests__/supabase.test.ts | 0 .../deploy/roles/anon.sql | 0 .../procedures/pre_request.sql | 0 .../schemas/supabase_integration/schema.sql | 0 .../jest.config.js | 0 .../package.json | 4 ++-- .../pgpm-supabase.control} | 6 +++--- .../{supabase-integration => supabase}/pgpm.plan | 4 ++-- .../revert/roles/anon.sql | 0 .../procedures/pre_request.sql | 0 .../schemas/supabase_integration/schema.sql | 0 .../sql/pgpm-supabase--1.0.0.bundle.tar.gz | Bin 0 -> 2263 bytes .../sql/pgpm-supabase--1.0.0.sql} | 2 +- .../verify/roles/anon.sql | 0 .../procedures/pre_request.sql | 0 .../schemas/supabase_integration/schema.sql | 0 pnpm-lock.yaml | 2 +- 25 files changed, 19 insertions(+), 19 deletions(-) delete mode 100644 packages/supabase-integration/Makefile delete mode 100644 packages/supabase-integration/sql/pgpm-supabase-integration--0.1.0.bundle.tar.gz rename packages/{supabase-integration => supabase}/.npmignore (100%) rename packages/{supabase-integration => supabase}/LICENSE (100%) create mode 100644 packages/supabase/Makefile rename packages/{supabase-integration => supabase}/README.md (94%) rename packages/{supabase-integration => supabase}/__tests__/supabase.test.ts (100%) rename packages/{supabase-integration => supabase}/deploy/roles/anon.sql (100%) rename packages/{supabase-integration => supabase}/deploy/schemas/supabase_integration/procedures/pre_request.sql (100%) rename packages/{supabase-integration => supabase}/deploy/schemas/supabase_integration/schema.sql (100%) rename packages/{supabase-integration => supabase}/jest.config.js (100%) rename packages/{supabase-integration => supabase}/package.json (93%) rename packages/{supabase-integration/pgpm-supabase-integration.control => supabase/pgpm-supabase.control} (52%) rename packages/{supabase-integration => supabase}/pgpm.plan (89%) rename packages/{supabase-integration => supabase}/revert/roles/anon.sql (100%) rename packages/{supabase-integration => supabase}/revert/schemas/supabase_integration/procedures/pre_request.sql (100%) rename packages/{supabase-integration => supabase}/revert/schemas/supabase_integration/schema.sql (100%) create mode 100644 packages/supabase/sql/pgpm-supabase--1.0.0.bundle.tar.gz rename packages/{supabase-integration/sql/pgpm-supabase-integration--0.1.0.sql => supabase/sql/pgpm-supabase--1.0.0.sql} (92%) rename packages/{supabase-integration => supabase}/verify/roles/anon.sql (100%) rename packages/{supabase-integration => supabase}/verify/schemas/supabase_integration/procedures/pre_request.sql (100%) rename packages/{supabase-integration => supabase}/verify/schemas/supabase_integration/schema.sql (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3b2f3c20a..d0e86edfe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: - base32 - totp - jwt-claims - - supabase-integration + - supabase - defaults - measurements - metaschema-schema diff --git a/MODULES.md b/MODULES.md index 37273a53d..f388161c2 100644 --- a/MODULES.md +++ b/MODULES.md @@ -46,7 +46,7 @@ ## Security & Authentication ### Core Security -- [ ] `packages/supabase-integration` - Supabase PostgREST role and identity claim bridge +- [ ] `packages/supabase` - Supabase PostgREST role and identity claim bridge - [ ] `packages/security/defaults` - Security defaults - [ ] `packages/security/jwt-claims` - JWT claim handling - [ ] `packages/security/totp` - Time-based One-Time Password (TOTP) diff --git a/packages/supabase-integration/Makefile b/packages/supabase-integration/Makefile deleted file mode 100644 index 79acbf829..000000000 --- a/packages/supabase-integration/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -EXTENSION = pgpm-supabase-integration -DATA = sql/pgpm-supabase-integration--0.1.0.sql - -PG_CONFIG = pg_config -PGXS := $(shell $(PG_CONFIG) --pgxs) -include $(PGXS) diff --git a/packages/supabase-integration/sql/pgpm-supabase-integration--0.1.0.bundle.tar.gz b/packages/supabase-integration/sql/pgpm-supabase-integration--0.1.0.bundle.tar.gz deleted file mode 100644 index 8198a3e21236e8acd5981161d250f44f000c45a8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2266 zcmV<02qpI)iwFP!000021MOIOZ`(!|&)@kJ12u(gz;@<7>?WvU(}_`A3M9ELwhD|n z-YCk-Btueef}-DjL0y&;$w!+8yNe72NSb%dn;+lFe3)PEx=9+wu=lRa(ntTm!Wd)8 z`ScrO{K+?wl9R>We4h|3=_CB;E38Rb+2RrYDrfx{u0I|l)VQ?iC_-5^_EG&Gp+?M# zOI!U6MLEjS#y)D0#?FkA+DoW6^4f9ANp77jVRw{PFf43UbI%!l0k(qh%cy!=^Z!^2 zyepsjtbirUTbmByFq@?H(QLjOARlKRJ4Jw^v5$V6ZX(nu{ad)S<JA)4YI-0^Uz*K&G;97KV+6GmskCTIGp~nrIz`wb5ar ze6UtINi`AHPz`}ODky_!M(jO^h( zJV?LKi|ifv>e)uP2kG~dVssmQklq72^xIU!6%?cRaeoC3Tb58%7jv%Lnc^h%wazz) zVk&pB-leLK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Qr6FEYQQfi{a5Iu{VM66^wDwaw3qClUeZVX?s;-hizcVNE;e8(9LAi{+j4Ob788bJ@G4p^g>iw!7>xiL zXi!v0$C#i&QWAlwXt3tQV+Gbr6BWBhF0PSII>(2dqvU@+^cVNoPy{5GiU!O*S6YFg zAt*+93?f2wBv|RJR}3r>JTlFU;(n75&D8yhz+ZVy@`b9!%B@#Q(N`TXHq7gr z2ael3etBLu2lGjCkhXf$v~iRip0>JE z2P!A7e*c3i_)s0J_wV^!Im-$w&igv)9(THDsD$dmXK5S_x0*GqpJtA#n85bJYuD+W zRBs`zM!tTXw|c>xSRg`0MhNi$me7E~ zX(p5jlm{$;1cyC{m5%YN45S;vZu5Zp0Nn1?PwA+g7sg3tjV9a?phQxuB92(`nhe2! z3^D}iu{TzE=e#9YS>VBZ-GTKXXx$uO7jJFWkFYm!n+>$fv;O)(TdTNjmi3t(L+N2F zFEZ=LJ2h?o>TatUn>#2kvh4R1itX*q18+78n}*$6ul4r_;dwMKN8uZN+twV5yvR!M z0pbl*{-*5@Z}tLEWhKVJSt>OM<{(BQgaRSC5gco&g=SO<1)4jDfio<)QO+?YHNUOd z6Ha(WHIv*B<~^s;n<%jJ)bQYCkir;4jTP7dSA+^?ofiRHW1", "contributors": [ diff --git a/packages/supabase-integration/pgpm-supabase-integration.control b/packages/supabase/pgpm-supabase.control similarity index 52% rename from packages/supabase-integration/pgpm-supabase-integration.control rename to packages/supabase/pgpm-supabase.control index 32053dde9..5ca95dd93 100644 --- a/packages/supabase-integration/pgpm-supabase-integration.control +++ b/packages/supabase/pgpm-supabase.control @@ -1,7 +1,7 @@ -# pgpm-supabase-integration extension +# pgpm-supabase extension comment = 'Supabase PostgREST integration for Constructive' -default_version = '0.1.0' -module_pathname = '$libdir/pgpm-supabase-integration' +default_version = '1.0.0' +module_pathname = '$libdir/pgpm-supabase' requires = 'plpgsql,pgpm-verify' relocatable = false superuser = false diff --git a/packages/supabase-integration/pgpm.plan b/packages/supabase/pgpm.plan similarity index 89% rename from packages/supabase-integration/pgpm.plan rename to packages/supabase/pgpm.plan index 8c49640b3..efda0e70f 100644 --- a/packages/supabase-integration/pgpm.plan +++ b/packages/supabase/pgpm.plan @@ -1,6 +1,6 @@ %syntax-version=1.0.0 -%project=pgpm-supabase-integration -%uri=pgpm-supabase-integration +%project=pgpm-supabase +%uri=pgpm-supabase schemas/supabase_integration/schema [pgpm-verify:procedures/assert_schema pgpm-verify:procedures/assert_function] 2026-08-27T00:00:00Z Constructive # add schemas/supabase_integration/schema roles/anon [schemas/supabase_integration/schema] 2026-08-27T00:00:00Z Constructive # add roles/anon diff --git a/packages/supabase-integration/revert/roles/anon.sql b/packages/supabase/revert/roles/anon.sql similarity index 100% rename from packages/supabase-integration/revert/roles/anon.sql rename to packages/supabase/revert/roles/anon.sql diff --git a/packages/supabase-integration/revert/schemas/supabase_integration/procedures/pre_request.sql b/packages/supabase/revert/schemas/supabase_integration/procedures/pre_request.sql similarity index 100% rename from packages/supabase-integration/revert/schemas/supabase_integration/procedures/pre_request.sql rename to packages/supabase/revert/schemas/supabase_integration/procedures/pre_request.sql diff --git a/packages/supabase-integration/revert/schemas/supabase_integration/schema.sql b/packages/supabase/revert/schemas/supabase_integration/schema.sql similarity index 100% rename from packages/supabase-integration/revert/schemas/supabase_integration/schema.sql rename to packages/supabase/revert/schemas/supabase_integration/schema.sql diff --git a/packages/supabase/sql/pgpm-supabase--1.0.0.bundle.tar.gz b/packages/supabase/sql/pgpm-supabase--1.0.0.bundle.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..8bee249b47c7300dd5cc6db3044f26a232817505 GIT binary patch literal 2263 zcmV;|2q^a-iwFP!000021MOIOZ`;Na&)@kJ3pIsoz;X6I>?WvU(}_`A3M9ELUKJR7 z%qmP}k|ilOLDBF2KpnR1$XA;NeGgd(khC*9JM-h5EXKvzQ#Z}R1h(H-dG_cZSQuk0 zIiG!FjIVtYDHvJqE%ph)5HZK&c0nLmX7DZv=nxMg76U&%Z1?HcxR~R z41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j2mY0n+J}A zlkVQ|u-9E%*SA+>Y-~1JaCp-14$yg?hEaCZ>ApH?nuEn8Im$YNS=!i7_KrIJnFCc* z*Sy0)HGHUd*ZcQkuAFCu73Y1E^bdOdV^l$X>hmn7-Ef0ms8kWdhI&7)A}7` zb?Tc}a;q0Cb=!H4vgu@!#*I%xZejcO``_zrKe6fA#f4j_-9%sWuGpccFJ3f#s%!7g zB_AGK2tORm@?ZDl=xElGF89BCf!eFethe{_-tESm(=@cVmLgUyzsLEaOf#Prc5;i5 zi-5kVtk1JS@^i9xGMqJq4{)D{4WyC_?g%F?5^A&)TrdyXut0>0j1b}hETI8|(@ZE6 zC=XZw2@ZP@D;?t(8AxvkyPF5p2jF(Eeo9B}yf98GYc%1G040)I6>-FhH)IF~WRM|9 zkG-+VJLfII$^sAO%MPp$LF?)OyL@Z2euTY>+kBwCxa+SEw2g?{W?7%x2~-|7iZZu; zvenQQuj@A2vAuo^r`3(~Jfdgf)swDSTuyYEVW8p{-&8yJ$T(286Z@ l6v3KYe@F8ep|_9!eEjI^`ntZZuj}8v{tG;lDewR!003IVa6AA2 literal 0 HcmV?d00001 diff --git a/packages/supabase-integration/sql/pgpm-supabase-integration--0.1.0.sql b/packages/supabase/sql/pgpm-supabase--1.0.0.sql similarity index 92% rename from packages/supabase-integration/sql/pgpm-supabase-integration--0.1.0.sql rename to packages/supabase/sql/pgpm-supabase--1.0.0.sql index d185c6bf5..bc75b1e31 100644 --- a/packages/supabase-integration/sql/pgpm-supabase-integration--0.1.0.sql +++ b/packages/supabase/sql/pgpm-supabase--1.0.0.sql @@ -1,4 +1,4 @@ -\echo Use "CREATE EXTENSION pgpm-supabase-integration" to load this file. \quit +\echo Use "CREATE EXTENSION pgpm-supabase" to load this file. \quit CREATE SCHEMA supabase_integration; GRANT USAGE ON SCHEMA supabase_integration TO PUBLIC; diff --git a/packages/supabase-integration/verify/roles/anon.sql b/packages/supabase/verify/roles/anon.sql similarity index 100% rename from packages/supabase-integration/verify/roles/anon.sql rename to packages/supabase/verify/roles/anon.sql diff --git a/packages/supabase-integration/verify/schemas/supabase_integration/procedures/pre_request.sql b/packages/supabase/verify/schemas/supabase_integration/procedures/pre_request.sql similarity index 100% rename from packages/supabase-integration/verify/schemas/supabase_integration/procedures/pre_request.sql rename to packages/supabase/verify/schemas/supabase_integration/procedures/pre_request.sql diff --git a/packages/supabase-integration/verify/schemas/supabase_integration/schema.sql b/packages/supabase/verify/schemas/supabase_integration/schema.sql similarity index 100% rename from packages/supabase-integration/verify/schemas/supabase_integration/schema.sql rename to packages/supabase/verify/schemas/supabase_integration/schema.sql diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4076428e1..ce6b4b7c6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -404,7 +404,7 @@ importers: specifier: ^5 version: 5.8.0(@dataplan/json@1.0.0(grafast@1.0.2(graphql@16.13.0)))(@dataplan/pg@1.0.3(@dataplan/json@1.0.0(grafast@1.0.2(graphql@16.13.0)))(grafast@1.0.2(graphql@16.13.0))(graphile-config@1.0.1)(graphql@16.13.0)(pg-sql2@5.0.1)(pg@8.22.0))(@types/node@22.19.17)(grafserv@1.0.0(@types/node@22.19.17)(grafast@1.0.2(graphql@16.13.0))(graphile-config@1.0.1)(graphql@16.13.0)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)(use-sync-external-store@1.6.0(react@19.2.5))(ws@8.20.0))(graphile-build@5.0.2(grafast@1.0.2(graphql@16.13.0))(graphile-config@1.0.1)(graphql@16.13.0))(pg-sql2@5.0.1)(react-dom@19.2.5(react@19.2.5))(react@19.2.5)(tamedevil@0.1.1)(use-sync-external-store@1.6.0(react@19.2.5))(ws@8.20.0) - packages/supabase-integration: + packages/supabase: dependencies: "@pgpm/verify": specifier: workspace:* From 737d4b39cf668cfdb140364e949588e3e1705013 Mon Sep 17 00:00:00 2001 From: Dan Lynch Date: Sun, 22 Nov 2026 03:10:06 +0000 Subject: [PATCH 7/7] ci(supabase): isolate Supabase CI in its own workflow --- .github/workflows/ci.yml | 2 - .github/workflows/integration-test.yml | 3 +- .github/workflows/supabase.yml | 87 ++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/supabase.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0e86edfe..328d79b55 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,6 @@ jobs: - base32 - totp - jwt-claims - - supabase - defaults - measurements - metaschema-schema @@ -117,7 +116,6 @@ jobs: - name: Seed pg and app_user run: | pgpm admin-users bootstrap --client --yes - psql -v ON_ERROR_STOP=1 -c 'CREATE ROLE anon NOINHERIT NOLOGIN;' # optional, but added to avoid concurrent attempts to add user pgpm admin-users add --test --yes # the platform components' one login (NOBYPASSRLS); the reader tests diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index d572df4a3..f5adacb60 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -86,7 +86,6 @@ jobs: - name: Seed pg users run: | pgpm admin-users bootstrap --client --yes - psql -v ON_ERROR_STOP=1 -c 'CREATE ROLE anon NOINHERIT NOLOGIN;' - name: Run Integration Tests - run: pgpm test-packages --full-cycle + run: pgpm test-packages --full-cycle --exclude pgpm-supabase diff --git a/.github/workflows/supabase.yml b/.github/workflows/supabase.yml new file mode 100644 index 000000000..198272cec --- /dev/null +++ b/.github/workflows/supabase.yml @@ -0,0 +1,87 @@ +name: Supabase integration +on: + push: + branches: + - main + paths: + - 'packages/supabase/**' + - '.github/workflows/supabase.yml' + pull_request: + paths: + - 'packages/supabase/**' + - '.github/workflows/supabase.yml' + workflow_dispatch: + +jobs: + supabase: + runs-on: ubuntu-latest + + env: + PGHOST: localhost + PGPORT: 5432 + PGUSER: postgres + PGPASSWORD: password + PGPM_VERSION: 5.18.0 + + services: + pg_db: + image: constructiveio/postgres-plus:18 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password + options: >- + --health-cmd "pg_isready -U postgres" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + steps: + - name: Configure Git (for tests) + run: | + git config --global user.name "CI Test User" + git config --global user.email "ci@example.com" + + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup pnpm + uses: pnpm/action-setup@v2 + with: + version: 9 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'pnpm' + + - name: Install + run: pnpm install + + - name: Cache pgpm CLI + uses: actions/cache@v4 + with: + path: ~/.npm + key: pgpm-${{ env.PGPM_VERSION }} + + - name: Install pgpm CLI globally + run: npm install -g pgpm@${{ env.PGPM_VERSION }} + + - name: Tune Postgres for CI (disable durability) + run: pgpm tune --yes + + - name: Seed Supabase users + run: | + pgpm admin-users bootstrap --client --yes + pgpm admin-users add --test --yes + psql -v ON_ERROR_STOP=1 -c 'CREATE ROLE anon NOINHERIT NOLOGIN;' + + - name: Test Supabase + run: pnpm --dir packages/supabase test + + - name: Full cycle for Supabase only + run: | + excludes=$(find packages -name '*.control' ! -path 'packages/supabase/*' -printf '%f\n' | sed 's/\.control$//' | paste -sd, -) + pgpm test-packages --full-cycle --exclude "$excludes"