Skip to content
Module
Module 3 of 6Lesson 2 of 2~26 min

Row Level Security: everyone's own data, proven with two accounts

If the database does not defend itself, a curious user can read other people's data by going around the interface. This lesson teaches you to specify and have the agent write Row Level Security rules for your tables, to build in a plan limit, then to prove with test accounts that the isolation really works.

Updated September 29, 2026.

In short

Row Level Security (RLS) is a PostgreSQL feature, used by Supabase, that enforces access rules row by row inside the database itself. Each user can only read or change the data they are allowed to, even if they bypass the interface. Without RLS, a publishable key is often enough to read every user's data.

Lesson objective

By the end of this lesson, you will be able to specify and have written the Row Level Security rules for your tables (read, create, update, delete), add a plan limit to them, then prove with two test accounts that one user can neither read nor change another's data, even when the interface is bypassed.

Questions this lesson answers

  • What is Row Level Security in Supabase for?

    It makes the database itself enforce access rights: every query only reaches the rows the signed-in user is allowed to read or change.

  • How do you prove one user cannot read another user's data?

    Create two test accounts, add data with the first, then try to read or change it with the second, including by querying the database without going through the interface.

  • Can RLS policies enforce a plan limit in a SaaS app?

    Yes, a policy can check a condition before allowing an insert, such as a maximum number of items per plan. The limit then holds even if the interface is bypassed.

Topics covered

  • Row Level Security
  • Supabase RLS
  • access policies
  • data security
  • PostgreSQL

In the glossary

Full glossary

Guide on this topic

Where it fits

Store the data and protect access to it

How do I have the agent create tables, and guarantee that everyone only sees their own data?

Lessons in this module

  1. Have the agent create your tables, then check them
  2. Row Level Security: everyone's own data, proven with two accounts (this lesson)

What you will learn in the course

This lesson is part of the course Add a database, authentication and payments to your app