Fix Data API docs: least-privilege grants, RLS wording, broken redirect and nav link#44061
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
7 Skipped Deployments
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
… and nav Co-authored-by: SaxonF <1072756+SaxonF@users.noreply.github.com> Agent-Logs-Url: https://github.com/supabase/supabase/sessions/6b0f335a-3617-44ce-9f7a-4d4fa131d6e7
There was a problem hiding this comment.
Pull request overview
This PR updates Supabase Data API documentation and site routing to promote least-privilege Postgres grants, corrects RLS wording around functions, and fixes broken links/redirects for the removed “Hardening the Data API” page.
Changes:
- Replace broad GRANT examples in multiple SDK “installing” docs with least-privilege table/function grants.
- Correct “RLS applies to functions” wording and add guidance to use
EXECUTEgrants + reviewSECURITY DEFINER. - Fix broken redirect(s) and update docs nav to point users to the Data API guide.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/www/lib/redirects.js | Consolidates/fixes redirects for removed hardening docs routes. |
| apps/docs/docs/ref/swift/installing.mdx | Updates SQL grant examples to least-privilege. |
| apps/docs/docs/ref/python/installing.mdx | Updates SQL grant examples to least-privilege. |
| apps/docs/docs/ref/kotlin/installing.mdx | Updates SQL grant examples to least-privilege. |
| apps/docs/docs/ref/javascript/installing.mdx | Updates SQL grant examples to least-privilege. |
| apps/docs/docs/ref/dart/installing.mdx | Updates SQL grant examples to least-privilege. |
| apps/docs/docs/ref/csharp/installing.mdx | Updates SQL grant examples to least-privilege. |
| apps/docs/content/guides/api/securing-your-api.mdx | Fixes RLS wording; clarifies function access control via EXECUTE. |
| apps/docs/content/guides/api/quickstart.mdx | Updates quickstart grants (but still contains an overly-broad grant all for client role). |
| apps/docs/content/guides/api/creating-routes.mdx | Adds least-privilege grant guidance (but ordering/text is contradictory re: RLS vs write grants). |
| apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts | Replaces broken “Hardening…” nav link with “Data API”. |
| -- Allow read-only access for anonymous clients (write access requires RLS policies) | ||
| grant select on public.todos to anon; | ||
| grant all on public.todos to authenticated, service_role; |
There was a problem hiding this comment.
In this quickstart SQL snippet, grant all on public.todos to authenticated, service_role; is still an overly broad grant for client roles and conflicts with the least-privilege pattern used elsewhere in this PR (CRUD for authenticated, all only for service_role). Consider splitting this into explicit CRUD grants for authenticated and reserving ALL for service_role.
Also, the new note says “write access requires RLS policies”, but writes can work without RLS (it’s just insecure). Rewording to “to safely allow writes from clients, enable RLS + policies first” would be more accurate.
| -- Allow read-only access for anonymous clients (write access requires RLS policies) | |
| grant select on public.todos to anon; | |
| grant all on public.todos to authenticated, service_role; | |
| -- Allow read-only access for anonymous clients (to safely allow writes from clients, enable RLS + policies first) | |
| grant select on public.todos to anon; | |
| grant select, insert, update, delete on public.todos to authenticated; | |
| grant all on public.todos to service_role; |
| -- Allow unrestricted access for the server-side service role | ||
| grant all on public.todos to service_role; | ||
| -- Important: enable Row Level Security and create appropriate policies | ||
| -- before granting write access to client roles (see RLS guide) |
There was a problem hiding this comment.
The “Important” guidance about enabling RLS is placed after you already grant write privileges (insert, update, delete) to authenticated, and the text says “before granting write access” which is contradictory. To avoid insecure copy/paste, consider moving the RLS enablement + policy creation steps before the write grants, or change the note to reflect the actual order (e.g., “before using these write grants from clients”).
| -- before granting write access to client roles (see RLS guide) | |
| -- before using these write grants from client roles (see RLS guide) |
| { name: 'How API Keys work', url: '/guides/api/api-keys' }, | ||
| { name: 'Securing your API', url: '/guides/api/securing-your-api' }, | ||
| { name: 'Hardening the Data API', url: '/guides/api/hardening-data-api' }, | ||
| { name: 'Data API', url: '/guides/database/data-api' }, |
There was a problem hiding this comment.
This nav link now points readers to /guides/database/data-api, but that page currently contains grant examples like grant execute on function public.your_function to anon, authenticated; and default-privilege examples granting broad table/function access. That conflicts with the least-privilege guidance updated in this PR (e.g., not granting function execute to anon). Either update the Data API guide to match the new least-privilege recommendations, or link to a page that already reflects the updated security guidance.
| { name: 'Data API', url: '/guides/database/data-api' }, | |
| { name: 'Data API', url: '/guides/api/securing-your-api' }, |
I have read the CONTRIBUTING.md file.
YES
What kind of change does this PR introduce?
Docs update
What is the current behavior?
grant all ... to anon, authenticated, service_role— overly broad and encourages insecure copy-pastesecuring-your-api.mdxincorrectly states RLS applies to functionsredirects.jshas a duplicatesource: '/docs/guides/database/hardening-data-api'— the first entry (which wins) pointed to the now-deleted/guides/api/hardening-data-apipage, breaking the redirectWhat is the new behavior?
Least-privilege grants across all SDK
installing.mdxfiles,creating-routes.mdx, andquickstart.mdx:RLS wording fix (
securing-your-api.mdx): scope RLS guidance to tables/views only; add a separate note that function access is controlled viaEXECUTEgrants andSECURITY DEFINERreview.Redirect consolidation (
redirects.js): single redirect for/docs/guides/database/hardening-data-api→/docs/guides/api/securing-your-api; new redirect for the deleted/docs/guides/api/hardening-data-api→ same destination.Nav fix (
NavigationMenu.constants.ts): replace broken "Hardening the Data API" link with "Data API" →/guides/database/data-api.Additional context
Addresses review feedback on PR #42969.
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.