How to Secure a Supabase Application
Start a Supabase security audit by identifying the schemas and tables exposed through the Data API. Table grants determine which operations a database role can perform. Row Level Security (RLS) limits the rows those operations can affect. Review the two layers together.
Model the lifecycle of a row
For a quotation, identify the customer organisation, creator and approver. Decide who can read it, create it, transfer ownership and delete it. In an RLS policy, USING limits the existing rows available to an operation. WITH CHECK constrains the proposed new row on insert or update.
Cover access outside the normal user path
- A publishable key is intended for client applications. Secret keys and legacy service_role credentials belong in trusted server environments.
- Review background jobs, privileged views and functions separately. Record where the caller’s authority over a customer record is checked.
- Review Storage policies as well. Turn expected outcomes for each role and operation into regression tests with synthetic records.
Example of a membership change
When an employee moves from company A to company B, decide what happens to old quotations. The history may remain with company A while the employee loses access. Document whether the policy uses current membership records or a claim in a token, and when the change becomes effective.
Frequently asked questions
Is enabling RLS on a table enough?
Define appropriate policies and table grants for intended use. Verify the normal application roles and separately review privileged server paths. A successful query run as the database owner tells you little about an ordinary user’s access.