Offering three small RLS fixes in apps/studio (defaults, templates, grants) #49609
IshwaryaSuresh
started this conversation in
Contribute to Supabase
Replies: 1 comment
|
) |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
This category is for small tasks contributors can pick up, so rather than a proposal, here are three specific things I found and am offering to fix. All from reading
apps/studio/components/interfaces/Database/Policies/PolicyEditorPanel/at master.1. The policy editor's role default contradicts the docs.
With no target role selected the editor emits
to public, and the helper text says so: "Defaults to all (public) roles if none selected." The RLS guide says "Always name the role a policy applies to, using thetoclause," and gives the un-scoped form as the anti-example.2. Six of eight policy templates ship without a
toclause.In
Policies.constants.ts, six of the eight general templates carryroles: []. Two of them,Enable delete for users based on user_idandEnable insert for users based on user_id, generateauth.uid() = user_idwith noto authenticated. Templates are where most policies start, so this teaches the un-scoped habit at scale. These same templates were corrected in 2024 to wrap(select auth.uid())after #21882; this is the same class of fix, unmade.3. Grants are never mentioned in the policy editor.
The string "grant" doesn't appear anywhere in it. In 438 RLS discussions I coded, 13.7% are grant failures wearing a policy error's clothes:
42501, raised before any policy runs. The editor shows one half of Postgres's access-control model with no indication the other half exists. Even a one-line hint on an empty result would cover most of them.Happy to open these as separate PRs if useful, or as issues first if you'd rather scope them. 1 and 2 are small and mechanical. 3 is a copy and interaction change, so I'd want a steer before writing it.
Context for why I was in there: I've been researching where the policy editor loses people, written up here with a working prototype. Not trying to redirect this thread to that; the three fixes above stand on their own.
All reactions