Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion services/trex/provision/d2e-bootstrap/bootstrap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ Deno.test("creates the three supabase roles with the documented attributes", ()
const stmts = buildBootstrapStatements(CFG).join("\n");
assertEquals(stmts.includes("CREATE ROLE anon NOLOGIN INHERIT"), true);
assertEquals(stmts.includes("CREATE ROLE authenticated NOLOGIN INHERIT"), true);
assertEquals(stmts.includes("CREATE ROLE service_role NOLOGIN INHERIT BYPASSRLS"), true);
// Without BYPASSRLS: it requires superuser, which managed Postgres does not
// grant, so requesting it leaves service_role uncreated.
assertEquals(stmts.includes("CREATE ROLE service_role NOLOGIN INHERIT"), true);
assertEquals(stmts.includes("BYPASSRLS"), false);
});

Deno.test("grants per-schema privileges and default privileges to reader and writer", () => {
Expand Down
8 changes: 7 additions & 1 deletion services/trex/provision/d2e-bootstrap/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,13 @@ export function buildBootstrapStatements(cfg: BootstrapConfig): string[] {
// ── Supabase roles (PostGraphile connects as authenticator and SET ROLEs) ──
out.push(createGroupRole("anon", "NOLOGIN INHERIT"));
out.push(createGroupRole("authenticated", "NOLOGIN INHERIT"));
out.push(createGroupRole("service_role", "NOLOGIN INHERIT BYPASSRLS"));
// No BYPASSRLS: setting that attribute requires superuser, which managed
// Postgres (Azure Flexible Server included) never grants -- even to a role
// that already holds it. Requesting it fails the statement outright with
// "must be superuser to change bypassrls attribute", leaving service_role
// absent on every greenfield install. Reachability of storage.buckets is
// provided by the service_role buckets policy migration instead.
out.push(createGroupRole("service_role", "NOLOGIN INHERIT"));

for (const dbKey of Object.keys(cfg.manageConfig.databases)) {
if (!dbKey.startsWith("+")) continue; // only creation scenarios
Expand Down
Loading