Public API key used by frontend clients.
public
role in DB.Not secret. You're expected to ship it in your frontend code.
Even with the anon key, users can only access the data you explicitly allow based on RLS.
You MUST enable RLS
.
anon
key alone will allow anyone to read or write everything.RLS stands for row-level security.
CREATE POLICY "Users can only access their own todos" ON todos FOR SELECT USING (auth.uid() = user_id);
Setup
Manu > Authentication > Create
Optionally add Providers
after creation step.
Providers
are auth services like Phone (Twillio), Google, Apple, etc.
In Database where you want to make a column user_id
which would be a foreign key to auth.uid()
.
Then, you can enable RLS
policy.
Get started quickly
.In the policy creation page, define which CRUD operation each role group would be allowed to perform.
Using Expression
is for queries with WHERE
.
read
).With Check Expression
is for Mutation.
insert
(creation) and update
(update)