We are designing a least-privilege PostgreSQL runtime architecture for a Next.js application hosted on Vercel. #48555
Replies: 1 comment
|
Not Supabase staff, but four of these are already settled in this repo and one of them has a live report from two days ago that your design walks straight into. Taking them in order. 1 and 2 and 3 — transaction pinning and Short version: in transaction mode the transaction is the unit of multiplexing, so a backend is held from That distinction decides your question 2. On statement cancellation specifically: cancelling a statement inside an explicit transaction puts it in the aborted state, and you can only 4 — transaction-level advisory locks. Fine, and the qualifier in your wording is doing the work. 5 — prepared statements with node-postgres. Yes, disable. This is explicit in the docs: Disabling prepared statements — "although the direct connections and Supavisor in session mode support prepared statements, Supavisor in transaction mode does not." For const query = {
name: 'fetch-user', // <-- this is the thing to remove
text: 'select * from app.thing where id = $1',
values: [id],
}6 — custom LOGIN role with SET-only membership in a NOLOGIN runtime role. Supported, and this is the one I would slow down on, because #48783 was opened two days ago by someone whose architecture is shaped almost exactly like yours and who is now locked out of their own roles. Their migration created seven custom They can neither manage memberships nor grants on roles their own application depends on, from the SQL Editor or anywhere else. Your plan has the same shape — a restricted
select r.rolname as role, m.rolname as member, am.admin_option
from pg_auth_members am
join pg_roles r on r.oid = am.roleid
join pg_roles m on m.oid = am.member
where r.rolname = '<runtime_role>';One version note on the SET-only membership itself: The fail-closed instinct in the rest of the design is the right one. Just make sure the role-management path is fail-closed too, which is precisely what #48783 was not. |
Uh oh!
There was an error while loading. Please reload this page.
Hello Supabase Support,
We are designing a least-privilege PostgreSQL runtime architecture for a Next.js application hosted on Vercel.
Our planned architecture is:
Dedicated application LOGIN
→ Transaction Pooler (port 6543)
→ SET-only membership
→ Restricted NOLOGIN runtime role
→ Single approved SECURITY DEFINER function
Before implementation, we would like to confirm the following:
In Transaction Pooler mode, does an explicit BEGIN...COMMIT remain pinned to the same PostgreSQL backend for the whole transaction?
Are SET ROLE and SET LOCAL ROLE supported inside that explicit transaction?
Is role/session state fully cleared after:
before the backend is reused?
Are transaction-level advisory locks fully supported in Transaction Pooler mode?
Should prepared statements be disabled when using node-postgres (pg) with Transaction Pooler?
Are custom PostgreSQL LOGIN roles with SET-only membership in a custom NOLOGIN runtime role fully supported in hosted Supabase?
We are requesting architectural guidance only.
No credentials, connection strings, or customer data are included.
Thank you.
All reactions