mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 00:19:08 +00:00
## Problem The Securing your API guide explains how to stop new objects in `public` from getting Data API grants. It doesn't say that this only changes the defaults for objects created later. Existing tables keep their grants and stay reachable through the Data API. Related to [FDBKIN-41883](https://linear.app/supabase/issue/FDBKIN-41883) Closes [DOCS-1685](https://linear.app/supabase/issue/DOCS-1685) ## Solution Adds text to `apps/docs/content/guides/api/securing-your-api.mdx` and rewrites no existing text: - **Default privileges:** a new paragraph says that changes to default privileges, including the platform default change, apply only to new objects, so existing tables keep their grants and stay reachable through the Data API. A per-table revoke follows it: `revoke all on table public.your_table from anon, authenticated, service_role;`. A sentence after it says that leaving out `service_role` keeps server-side access with a secret key. - **Revoke default privileges:** a new sentence says that existing tables, sequences, and functions keep their current grants. It links to the per-table revoke in `#default-privileges`. Sources for the behavior: - The Dashboard toggle's SQL (`buildDefaultPrivilegesSql` in `packages/pg-meta/src/sql/studio/database/privileges.ts`) runs only `alter default privileges … grant/revoke` statements. It runs no revoke on existing tables. - The Postgres docs for `ALTER DEFAULT PRIVILEGES` say it affects only objects created later. - `getting-started/api-keys.mdx` says that a secret key uses `service_role`, which bypasses RLS but still needs table grants. - Checked on PGlite (PostgreSQL 18.6). After `alter default privileges … revoke all on tables`, a table created earlier kept its `anon`, `authenticated`, and `service_role` grants, and a table created later had none. After the per-table revoke, `has_table_privilege('anon', 'public.old_t', 'select')` returned false. With `service_role` left out of the revoke, `service_role` still read an RLS-enabled table. With `service_role` included, it got `permission denied`. Checks run: `pnpm turbo run lint --filter='[origin/master]'` (0 errors), `pnpm turbo run typecheck --filter='...[origin/master]'`, Prettier `--check` on the changed file, and `pnpm -C apps/docs run check:removed-anchors`. `pnpm build:guides-markdown` didn't run locally: its federated-content step needs GitHub credentials. The docs tests weren't run because they need Docker. ## Checklist - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [x] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide) --------- Co-authored-by: supabase-vercel-tedd[bot] <336548405+supabase-vercel-tedd[bot]@users.noreply.github.com>