Skip to content

BE-DP-09 · Before the merge: explicit grants on the local stack, every test and the app

ID BE-DP-09 · Level L0 · Pack Pack G3 · Explicit grants · Run order row 0f, first: before the pull request for #247 is merged, and before 2026-10-30 · Issue #247

On the pull request's branch, the local stack behaves as hosted Supabase will from 2026-10-30: nothing in public is granted by default, and every table and view is granted explicitly beside its policies (R-ACC-72). Every pgTAP test passes, apps/web still reads and writes through PostgREST, the E2E logins script still writes through /rest/v1 as service_role, and the generated files are unchanged or committed (D33).

  • The pull request for #247 is open on the branch be/247-explicit-grants, with DOC's rule R-ACC-72 on it, so its checks are green.
  • You are at the root of your clone, the local stack is running, and git status --short prints nothing.

1 · The branch, rebuilt from nothing, and every test

Section titled “1 · The branch, rebuilt from nothing, and every test”
Terminal window
git fetch origin be/247-explicit-grants
git switch be/247-explicit-grants
pnpm supabase db reset
pnpm supabase test db
Terminal window
docker exec supabase_db_opleet psql -U postgres -d postgres -c "select grantee, count(distinct table_name) as tables from information_schema.role_table_grants where table_schema = 'public' and grantee in ('anon', 'authenticated', 'service_role') group by grantee order by grantee"

3 · The E2E logins, through /rest/v1 as service_role

Section titled “3 · The E2E logins, through /rest/v1 as service_role”
Terminal window
pnpm db:e2e-users

4 · apps/web, through PostgREST as authenticated

Section titled “4 · apps/web, through PostgREST as authenticated”

Playwright starts the built app; it doesn't build it.

Terminal window
pnpm --filter web build
pnpm --filter web e2e
Terminal window
pnpm db:types
pnpm docs:reference
git status --short
  • Block 1: "Finished supabase db reset", then All tests successful., Files=16, Tests=399 and Result: PASS. The new file is 43_grants.test.sql, whose descriptions start R-ACC-72 and R-ACC-02.
  • Block 2: two rows: authenticated | 75 and service_role | 76. That's 71 tables and 5 views. The app's users hold nothing on document_sequences, which only app.next_document_number() touches. There's no anon row.
  • Block 3: eleven lines starting kept or made, then 11 logins in the E2E organization, all pools.
  • Block 4: next build lists its routes, then every spec passes.
  • Block 5: nothing listed. The pull request already carries the reference pages, and no table's columns changed, so db:types writes the same file. If a file is listed, commit it as BE-M0-40's block 4 does.
Terminal window
docker exec supabase_db_opleet psql -U postgres -d postgres -At -c "select count(*) from pg_default_acl d, aclexplode(d.defaclacl) a where d.defaclrole = 'postgres'::regrole and d.defaclnamespace = 'public'::regnamespace and d.defaclobjtype = 'r' and a.grantee in ('anon'::regrole, 'authenticated'::regrole, 'service_role'::regrole)"

0: no default privilege hands a new public table to anyone.

  • A 43_grants test fails: paste the not ok line and the lines under it starting with # into #247. A row after # have: names a table and a privilege that differ from what the generator grants.
  • Block 3 or 4 fails with 42501 or permission denied for table …: a table the app or the script uses isn't granted. Paste the table's name and the failing spec into #247. Don't merge.
  • Block 2 shows an anon row: stop and paste it. anon must hold nothing (R-ACC-02).

git switch main && pnpm supabase db reset puts the local stack back on main. Nothing here touches staging or production.

Log each run as a comment on #247: the date, block 1's last lines, block 2's two rows, blocks 3 and 4's summaries, block 5's git status --short and the Check's number.