Repository navigation
Conversation
FORCE RLS does not apply to superusers or bypassrls roles, and postgres on Supabase has bypassrls. Restrictive policies do not grant access on their own. UPDATE with WHERE or RETURNING also needs a SELECT policy. Policy expressions need EXECUTE (and schema USAGE) on helper functions. auth.jwt() returns claims jsonb. Co-authored-by: Miranda Limonczenko <[email protected]>
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
6 Skipped Deployments
|
## Problem The guide alternated between context, procedure, and reference on almost every heading. A reader who wanted to write a policy passed through four context or reference sections to reach one. A reader who wanted the model had to skip three procedures. ## Solution - Group into three sections by information type: `Understand Row Level Security`, `Secure a table with RLS`, and `RLS reference`, with a navigation intro. - Merge the four policy sections. They repeated the same setup block, burying the clause that differed. One setup block now precedes four short policy examples. - Move the auto-enable recipe into `event-triggers.mdx`, whose stub section's entire body was a link back here. - Relocate the stranded `auth.uid()` caution into the `auth.uid()` reference. - Lift the revoke-and-grant procedure out of the danger admonition and merge it with the two other places that taught `enable row level security`. - Point the Grafana IO chart entry at the performance guide. Its `#rls-performance-recommendations` anchor went away when tuning split out in #49016. 765 lines to 582. 30 headings to 25. Headings are demoted rather than renamed wherever anything links to them. Every inbound anchor in the repo still resolves; the only one removed, `#auto-enable-rls-for-new-tables`, was referenced solely by the `event-triggers.mdx` stub this PR replaces. ## Note on the history Rebuilt from `master` after #49011, #49015, and #49016 merged. The branch previously carried those 10 commits plus rebase churn against them. Rebasing naively would have reverted review feedback from #49016 (`70fa812`), which removed the benchmarks table and the "This guide" opener from the performance guide. Those are deliberately not restored here. The only changes to that file are two missing `await`s and a join predicate that was a tautology while unqualified. The three PRs stacked on this one (#49268, #49269, #49270) have been rebased onto the new base. ## Manual testing 1. Open the [Row Level Security guide](https://docs-git-docs-rls-restructure-supabase.vercel.app/docs/guides/database/postgres/row-level-security) on the preview. Three top-level sections appear in the table of contents. 2. Select each link in the intro. All three jump to their section. 3. Open [Event triggers](https://docs-git-docs-rls-restructure-supabase.vercel.app/docs/guides/database/postgres/event-triggers). The auto-enable section holds the full recipe instead of a link. 4. Open the [performance guide](https://docs-git-docs-rls-restructure-supabase.vercel.app/docs/guides/database/postgres/row-level-security-performance). No benchmarks table, and the three bullets at the top link into the RLS guide. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Reworked the Row Level Security guide with clearer guidance on grants, policies, permissions, performance, testing, views, and secure functions. * Added a complete example for automatically enabling RLS on newly created public tables. * Improved SQL examples and clarified table references in RLS performance guidance. * Corrected grammar in the Grafana chart troubleshooting documentation. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 5 <[email protected]>
I have read the CONTRIBUTING.md file.
YES
What kind of change does this PR introduce?
Docs update (claim-by-claim verification), stacked on #49268, which is stacked on #49017.
Review #49017, then #49268, then this PR.
Stack (bottom → top):
#49017(docs/rls-restructure→master) →#49268(cursor/rls-accuracy-f756→docs/rls-restructure) → this PR (cursor/rls-claim-verify-f756→cursor/rls-accuracy-f756).Local tracking is via
gh stack(gh stack add/gh stack submit). Creating the GitHub Stack object failed here withResource not accessible by integration. To attach official GitHub Stack metadata from a token that can write stacks:What is the current behavior?
A claim-by-claim check of the restructured RLS guide against Postgres, the Auth helpers, and the Supabase role catalog found several remaining inaccuracies in #49268 (some introduced by the previous accuracy pass).
What is the new behavior?
Accuracy-only edits to
row-level-security.mdx:bypassrlsare subject to FORCE. Superusers andbypassrlsalways skip. On Supabase,postgresis not a superuser but hasbypassrls(demote-postgres.sql), so the SQL Editor skips policies even after FORCE.where,returning, Data API filters) also needs a SELECT policy. Without one, the update matches zero rows. The previous “representation-only / Data API” wording was wrong for typical API updates (CREATE POLICY, PostgREST How to use scripts to conditionally alter a table? #2423).executefrompublicand grantusage+executeto the policy’s role. Revoking fromauthenticatedbreaks the policy that calls the function (CREATE POLICY notes).auth.jwt()returns claims asjsonb, not the token string.security_invokerdefaults to false), notsecurity definersyntax.user_idfilter still needs its own index (without claiming Postgres can never use a non-leading column).supabase test new profiles_rls.testmatches the example filename and the testing overview.Claims that checked out and were left alone include: grants-before-policies, default-deny with no policy,
to authenticatedshort-circuit,auth.uid()null = unknown, initPlan wrapping,with checkvsusing, 42501 for missing grants and WITH CHECK, secret key →service_role+bypassrls, JWT?for a text array of team IDs,updateUser()onuser_metadata, cookie 4096, MFAaal2.Additional context
Base is
cursor/rls-accuracy-f756(#49268), notmaster. Files changed vs that PR is this verification commit only.