Replies: 2 comments 2 replies
|
Correction after rechecking the docs: the pooled/direct split is documented, but I overstated what it proves. Prisma documents the same generated The decisive check is to run this through each URL, before any SELECT
session_user,
current_user,
(SELECT rolsuper FROM pg_roles WHERE rolname = session_user) AS session_is_superuser;If both URLs report For (b), So the least-privilege solution is still a connection credential that authenticates as a non-superuser. If Prisma does not expose one, |
|
The pooled/direct split is real, but I don't think it can be the thing that selects the role. Prisma's own docs use the same USER:PASSWORD on both URLs and only change the hostname, and you already found that the role is resolved from the credential rather than from the string, so moving to the pooled host shouldn't take you off prisma_migration. Worth confirming rather than arguing about, though: run select current_user, (select rolsuper from pg_roles where rolname = current_user); through each URL. If both report prisma_migration, there's no URL-level answer to (a), and for what it's worth prisma_application doesn't appear anywhere in Prisma's public repos or docs, which makes it look like an internal provisioning role rather than something you're meant to connect as. On (b), I'd push back on dismissing SET ROLE: the pooling docs say session state is lost after each transaction boundary, and SET LOCAL lives inside one, so begin; set local role app_runtime; ... commit; does survive the pooler. That's the same shape PostgREST runs on. Just don't reach for RLS before that, since prisma_migration is both superuser and the owner of all 19 tables and so bypasses it twice over, and FORCE ROW LEVEL SECURITY only closes the owner half. |
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I run a small production app on Prisma Postgres (region: ap-northeast-1).
I would like the application to connect with least privilege, but I cannot find a way
to obtain a connection string that maps to a non-superuser role.
What I observe (all verified by querying the database directly):
My current direct connection string (postgres://@db.prisma.io:5432/postgres)
authenticates as the role
prisma_migration.The database already contains a role named
prisma_application.I could not find any way to get a connection string that authenticates as
prisma_application:"generate new connection string" button; it shows the same key I already use
which suggests the role is decided server-side from the key
My questions:
a) Is there a supported way to obtain a connection string that authenticates as
prisma_application(or any non-superuser role) for a Prisma Postgres database?b) If not, is there another recommended way to run an application without superuser
privileges on Prisma Postgres?
c) If neither exists today, is it on the roadmap?
For context, this is a construction-industry app holding customer names and addresses in
drawings, so limiting blast radius matters to us.
Thanks in advance.
All reactions