How do I test RLS?
Last checked 31 Aug 2026
Short answer
Try reading and writing data as a different logged-in user and as a logged-out visitor to confirm row-level security actually blocks what it should, rather than assuming the policy is correct.
What RLS is and why testing it matters
Row-level security (RLS) is the Postgres-level rule set that decides which rows a given request can read or write, based on who's logged in. A missing or misconfigured policy is one of the most common real-world Lovable security gaps — it's invisible until someone actually tries to access data they shouldn't.
How to test it
Create two test accounts (or one account plus a logged-out session).
As account A, create some data — a post, an order, a profile field.
Log in as account B and try to view or edit account A's data directly — through the normal UI first, then (if you're comfortable) by inspecting the network request and adjusting the ID.
As a logged-out visitor, try to load pages/API calls that should require login.
Ask Lovable to list every table and its current RLS status rather than trying to infer it from the UI:
List every table in the database, whether RLS is enabled, and summarise what each policy allows. Flag any table with no RLS or with a policy that looks too permissive.
For anything flagged, ask for a fix and re-test the same scenario afterwards.
What usually goes wrong
- A table created without RLS enabled at all — depending on configuration this can mean fully open or fully blocked; either is usually wrong.
- A policy written against
auth.uid()that's correct for read but forgotten for insert/update/delete (RLS is per-operation). - Roles checked from a column on the user's own row instead of a separate
user_rolestable, letting a user potentially edit their own role. - Policies that work for the builder's own admin-like test account but were never tried as a genuine second user.
See also /questions/is-my-supabase-anon-key-safe-to-expose and /questions/how-do-i-test-admin-permissions.
Sources
Was this answer helpful?
Related questions
- AnswerHow do I back up my project before launch?Bookmark the current state in Version history, and push to a connected GitHub/GitLab repo via Git sync so you have a full backup outside Lovable too.
- AnswerHow do I test SEO?Check that every page has a unique title and meta description, images have alt text, the site generates a sitemap, and preview the page as a search engine or social share would see it.
- AnswerHow do I test admin permissions?Log in as a non-admin account and try to reach every admin action directly (URLs, buttons, API calls) to confirm the server — not just the UI — blocks it.
- AnswerHow do I test my Lovable app?Work through core user flows manually in Preview and on a published link, on desktop and mobile, as a logged-out user and as a normal account — not just as the builder.