Skip to content

docs(database): verify and correct remaining RLS guide claims - #49269

Closed
czenko wants to merge 1 commit into
cursor/rls-accuracy-f756from
cursor/rls-claim-verify-f756
Closed

czenko wants to merge 1 commit into
cursor/rls-accuracy-f756from
cursor/rls-claim-verify-f756

Conversation

@czenko

@czenko czenko commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

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 with Resource not accessible by integration. To attach official GitHub Stack metadata from a token that can write stacks:

gh stack link --base master 49017 49268 49269

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:

  • FORCE RLS: only table owners without bypassrls are subject to FORCE. Superusers and bypassrls always skip. On Supabase, postgres is not a superuser but has bypassrls (demote-postgres.sql), so the SQL Editor skips policies even after FORCE.
  • Permissive vs restrictive: a second permissive policy widens access. Restrictive policies only reduce access after at least one permissive policy has granted it. The MFA example now says so.
  • UPDATE + SELECT: an update that reads the row (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).
  • EXECUTE on helpers: policy expressions run as the caller, so revoke execute from public and grant usage + execute to the policy’s role. Revoking from authenticated breaks the policy that calls the function (CREATE POLICY notes).
  • auth.jwt() returns claims as jsonb, not the token string.
  • Views: owner rights (security_invoker defaults to false), not security definer syntax.
  • Indexes: a composite PK leads with its first column; a user_id filter still needs its own index (without claiming Postgres can never use a non-leading column).
  • supabase test new profiles_rls.test matches 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 authenticated short-circuit, auth.uid() null = unknown, initPlan wrapping, with check vs using, 42501 for missing grants and WITH CHECK, secret key → service_role + bypassrls, JWT ? for a text array of team IDs, updateUser() on user_metadata, cookie 4096, MFA aal2.

Additional context

Base is cursor/rls-accuracy-f756 (#49268), not master. Files changed vs that PR is this verification commit only.

Open in Web Open in Cursor 

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]>
@supabase

supabase Bot commented Aug 19, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5c6e7e2e-bbae-4a91-96a2-8b58e06e8bab

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@vercel

vercel Bot commented Aug 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, v0 Aug 19, 2026 6:33pm
6 Skipped Deployments
Project Deployment Actions Updated (UTC)
studio Ignored Ignored Aug 19, 2026 6:33pm
design-system Skipped Skipped Aug 19, 2026 6:33pm
studio-self-hosted Skipped Skipped Aug 19, 2026 6:33pm
studio-staging Skipped Skipped Aug 19, 2026 6:33pm
ui-library Skipped Skipped Aug 19, 2026 6:33pm
zone-www-dot-com Skipped Skipped v0 Aug 19, 2026 6:33pm

Request Review

@czenko

czenko commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #49274, which carries this work as a single PR stacked on #49017. Nothing is lost: the combined branch produces a byte-identical guide to this chain's tip.

Closing and deleting the branch.

czenko added a commit that referenced this pull request Aug 19, 2026
## 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants