In short
- Auth says who the caller is. Row level security says which rows they get. A policy for
authenticatedwith the conditiontrueopens the table to any stranger who creates an account. - Sign-up is a project setting, not a page of your app. Unless Allow new users to sign up is off, the Auth API creates accounts whatever your interface shows.
- In server code, Supabase's docs say never to trust
getSession(): the session cookie can be forged. UsegetClaims(), which verifies the token's signature, orgetUser(). user_metadatacan be edited by the user. Authorize onapp_metadataor on a table of your own; the Security Advisor reports a policy that readsuser_metadataas an error.- Before launch: confirm email on, exact redirect URLs, your own SMTP (the built-in one sends 2 emails an hour, to team addresses only), CAPTCHA on sign-up, sign-in and password reset.
On this page
- What Supabase Auth does, and what it does not
- The gap that leaks data: signed in does not mean allowed
- The settings to check before launch
- Email: confirmation, the built-in mailer and link scanners
- Redirect URLs: where a sign-in link may send your user
- Rate limits, CAPTCHA and leaked passwords
- On the server: getClaims, not getSession
- Roles and admin flags: never authorize on user_metadata
- Anonymous sign-ins and MFA change what signed in means
- How to check your own project in fifteen minutes
- Questions
- Sources
What Supabase Auth does, and what it does not
Supabase Auth is the service in every Supabase project that creates users and signs them in: email and password, magic links and one-time codes, social providers, phone, and anonymous sessions. When a sign-in succeeds, it issues two things. An access token, a JSON Web Token (JWT) that expires after one hour by default, and a refresh token that never expires but can be used only once, to get a new pair. The access token guide takes the token apart field by field.
The token is a signed statement about the caller: their user id, the Postgres role authenticated, how strongly they proved their identity (aal1 for one factor, aal2 after a second), whether the session is anonymous, and two bags of metadata. Your database reads that statement on every request, through auth.uid() and auth.jwt(). Nothing in it says which rows the caller may read. That decision is yours, written as row level security (RLS) policies.
| Question | Who answers it | Where it lives |
|---|---|---|
| Who is calling? | Supabase Auth | The signed access token |
| May this role touch the table at all? | Postgres grants | Privileges of anon and authenticated on each table |
| Which rows may this user read or change? | RLS policies | Each table, usually comparing a column to auth.uid() |
| Is this user an admin, or a member of this team? | Your own data | A table you control or app_metadata, checked inside a policy |
The gap that leaks data: signed in does not mean allowed
The most common auth mistake we find in generated apps is not in Auth at all. The app has a login page, so the builder trusts that the data is behind it. The policies say something weaker: any signed-in user may read every row.
-- Passes for every account, including one created a minute ago
create policy "Signed-in users can read orders" on public.orders
for select to authenticated using (true);
-- Each user reads only their own rows
create policy "Users read their own orders" on public.orders
for select to authenticated using ((select auth.uid()) = user_id);The first policy is only as strong as your sign-up, and sign-up is open by default. It is a project setting, not a page of your app. Supabase's docs describe it in one line: with Allow new users to sign up disabled, only existing users can sign in. While it is enabled, the Auth API accepts new accounts from anyone who has your project URL and public key, and both are in your JavaScript. An internal tool with no sign-up screen is still open to sign-ups.
curl -X POST "https://YOUR_PROJECT_REF.supabase.co/auth/v1/signup" \
-H "apikey: YOUR_PUBLISHABLE_KEY" \
-H "Content-Type: application/json" \
-d '{"email": "[email protected]", "password": "a-long-test-passphrase"}'The settings to check before launch
These live under Authentication in the Supabase dashboard. The names are those of the documentation in November 2026.
| Setting | Where | What to set | Why |
|---|---|---|---|
| Allow new users to sign up | Sign In / Providers | Off for internal and invite-only apps | While on, anyone can create an account through the API |
| Confirm email | Sign In / Providers, email provider | On | Off, an address is treated as confirmed without any proof the user owns it |
| Site URL and Redirect URLs | URL Configuration | Your production URL, and exact paths | They decide where a sign-in link may send the user |
| Custom SMTP | Emails, SMTP Settings | Your own email provider | The built-in mailer sends 2 emails an hour, to your team's addresses only |
| CAPTCHA | Attack Protection | hCaptcha or Cloudflare Turnstile | Covers sign-up, sign-in and password reset |
| Password rules | Sign In / Providers, email provider | 8 characters or more, required character types, leaked password protection | Shorter than 8 is not recommended by the docs; the leak check needs the Pro plan or above |
| Email OTP expiry | Sign In / Providers, email provider | 3,600 seconds or lower | The same setting governs confirmation, recovery, email change and invitation links |
| Rate limits | Rate Limits | Read the defaults, lower what you can | They cap what one address can attempt |
Email: confirmation, the built-in mailer and link scanners
With Confirm email on, a user must confirm their address before signing in for the first time. With it off, Supabase marks the address as confirmed without checking. Anyone can then hold an account under an address that belongs to someone else. That becomes a hole the moment a policy or a piece of code trusts the email, for example by treating every address at your company's domain as a team member.
Confirmation needs working email, and the default does not work for real users. Supabase's docs say the built-in email service is not meant for production use: it sends 2 messages an hour, a value they warn can change without notice, comes with no delivery guarantee, and refuses any address that is not on your project's team. Set up your own SMTP provider before the first outside user. Once you do, Supabase starts you at a low limit of 30 messages an hour, which you can raise on the Rate Limits page.
Two details bite after that. Some corporate mail scanners open every link in a message before the user does, and a sign-in link works once; Supabase's production guide points this out and tells you to disable link tracking at your email provider. And the expiry of email codes and links is one setting: the production checklist says to keep it at 3,600 seconds or lower.
Redirect URLs: where a sign-in link may send your user
Magic links, confirmations, password resets and social sign-ins all end by sending the browser to a URL, carrying the proof of sign-in. Site URL is the default destination, and the Redirect URLs list says which other destinations your code may ask for with redirectTo. A value that is not on the list is ignored: the docs say so for invitation links, which then go to the Site URL with no error. That is why a project whose Site URL was never changed from http://localhost:3000 sends its users to localhost.
The list accepts wildcards. A single * matches a run of characters without a dot or a slash, and a double star matches anything. They exist for local development and preview deployments, and the docs recommend exact paths for your production site. The danger is a pattern that matches hosts you do not control: if any project on a hosting platform fits it, a link crafted by a stranger can carry your user's sign-in to a page the stranger deployed. Scope preview patterns to your own team, the way the docs show:
# Site URL
https://app.yourdomain.com
# Redirect URLs
https://app.yourdomain.com/auth/callback
http://localhost:3000/**
https://*-YOUR-TEAM-SLUG.vercel.app/**Rate limits, CAPTCHA and leaked passwords
Supabase limits Auth requests on its side and answers 429 when a limit is passed. Its rate limits page lists these defaults:
| What | Default | Can you change it? |
|---|---|---|
| Emails from the built-in mailer | 2 per hour | Only by using your own SMTP |
| Sign-up and sign-in requests, per IP address | 30 per 5 minutes | Yes |
| Magic link, one-time code, confirmation or reset for the same user | One every 60 seconds | Yes |
| Anonymous sign-ins, per IP address | 30 per hour | Yes |
| MFA challenge and verify | 15 per minute | No |
Limits per address do little against a script that changes address. CAPTCHA is the answer for forms: Supabase supports hCaptcha and Cloudflare Turnstile, on sign-up, sign-in and password reset, and strongly recommends it if you allow anonymous sign-ins.
For passwords, set a minimum length and the required character types, and turn on leaked password protection if your plan has it: Supabase checks new passwords against the Pwned Passwords list of HaveIBeenPwned and refuses the ones found in known breaches. It is available on the Pro plan and above.
On the server: getClaims, not getSession
The Supabase client has three ways to ask who the user is, and in server code only two of them are safe. getSession() returns what is stored in the cookie without checking it again. The server-side guide is blunt about it: never trust getSession() inside server code, because anyone can forge the session cookie, and trusting it lets an attacker render another user's page.
| Method | What it does | Use it for |
|---|---|---|
getClaims() | Verifies the token's signature on every call and returns its claims | Protecting pages, routes and server actions |
getUser() | Asks the Auth server for the user record, over the network | When you need the current record, for example after a ban or an email change |
getSession() | Reads the session from storage with no new check | Getting the raw token to pass along, never deciding access on a server |
// In a server component, a route handler or a server action
const supabase = await createClient();
const { data } = await supabase.auth.getClaims();
const claims = data?.claims;
if (!claims) redirect("/login");
// claims.sub is the user id; RLS still applies to every query made with this client
const { data: orders } = await supabase.from("orders").select("*");getClaims() is cheap when your project signs tokens with an asymmetric key, which is the default for new projects: the client checks the signature against the public keys your project publishes at /auth/v1/.well-known/jwks.json. Older projects sign with a shared secret, the legacy JWT secret, which the docs no longer recommend. A shared secret that leaks lets its holder sign a token for any user. You can move to signing keys from the JWT signing keys page of the project settings; the docs describe the steps as reversible until you revoke the old secret.
Roles and admin flags: never authorize on user_metadata
Each user carries two metadata fields, and they are not equal. user_metadata is meant for profile details such as a display name, and the user can change it: the docs say the value is editable by the user without any checks. A policy or a server check that reads an is_admin or role value from it can be passed by any signed-in user who writes that value into their own profile. Supabase's Security Advisor reports such a policy as an error, under the name rls_references_user_metadata.
-- Policies that read user-editable metadata
select schemaname, tablename, policyname
from pg_policies
where qual ilike '%user_metadata%'
or with_check ilike '%user_metadata%';Put authorization data where the user cannot write: app_metadata, which the docs say cannot be updated by the user and is set from your server with a secret key, or a table of your own with RLS on it.
-- Role set by your server in app_metadata
create policy "Admins read every order" on public.orders
for select to authenticated
using ((select auth.jwt() -> 'app_metadata' ->> 'role') = 'admin');One more leak sits next to this one. A view in an exposed schema that selects from auth.users hands your users' emails to whoever can call your API, because a view skips the policies of the tables it reads unless it is created with security_invoker. The Security Advisor reports it as auth_users_exposed. Keep public profile fields in a profiles table with its own policies instead.
Anonymous sign-ins and MFA change what signed in means
An anonymous user is not the anon role. Supabase gives anonymous sessions the authenticated role, with an is_anonymous claim in the token. Every policy written to authenticated therefore passes for a visitor who never gave an email. The docs tell you to review your policies before enabling the feature, and to turn on CAPTCHA, since anyone can create these users in bulk and grow your database.
-- Anonymous sessions may read, but not post
create policy "Only permanent users can post" on public.posts
as restrictive for insert to authenticated
with check ((select (auth.jwt() ->> 'is_anonymous')::boolean) is false);
-- Rows that need a second factor
create policy "Second factor required" on public.payouts
as restrictive to authenticated
using ((select auth.jwt() ->> 'aal') = 'aal2');as restrictive.Multi-factor authentication has the same shape. Supabase supports authenticator apps (TOTP) and phone codes, and a session that passed the second factor carries aal2. If MFA is only enforced by your screens, a session at aal1, password alone, still reads the same rows through the API. The second policy above is what makes the second factor count.
How to check your own project in fifteen minutes
- 1
Open the Security Advisor
In the dashboard, or with
supabase db advisors. Look first forrls_references_user_metadata,auth_users_exposed,rls_disabled_in_publicand the notice about anonymous sign-ins. - 2
List the policies that pass for everyone
Run
select tablename, policyname, cmd, roles from pg_policies where schemaname = 'public' and (qual = 'true' or with_check = 'true');. For each row, ask whether every account on the internet should have that access. - 3
Try to sign up
Run the sign-up command from the top of this page against your own project. If your app is internal or invite-only and an account is created, turn Allow new users to sign up off.
- 4
Read as a second user
Sign in with a second account and ask for the first account's rows: its orders, its messages, its profile by id. The IDOR guide gives the steps.
- 5
Follow one email link
Request a magic link or a password reset and check where the link lands, on production and on a preview deployment. Then read your Redirect URLs list for any pattern wider than your own hosts.
- 6
Search your server code
Search for
getSessionin route handlers, server components, server actions and middleware. Every place that decides access from it should callgetClaims()orgetUser().
- No policy for
authenticatedwith the conditiontrueon a table that holds user data - Sign-up off for internal apps; confirm email on
- Site URL is the production URL; redirect URLs are exact in production
- Custom SMTP configured, link tracking off
- CAPTCHA on sign-up, sign-in and password reset
- No policy or server check reads
user_metadata - Server code uses
getClaims()orgetUser(), nevergetSession(), to decide access - If MFA or anonymous sign-ins are on, a restrictive policy checks
aaloris_anonymous
The dashboard tells you what the settings say. What a stranger can do with them shows only from outside, signed out and then signed up. The Supabase security overview covers the rest of the project: keys, storage, functions and realtime.
Questions
What is the difference between getUser, getSession and getClaims in Supabase?
getSession() reads the session from storage without checking it again, so server code must not decide access from it. getClaims() verifies the token's signature and returns its claims. getUser() asks the Auth server for the current user record, which costs a network call and reflects changes such as a ban.
Can people sign up if my app has no sign-up page?
Yes, unless you turned the setting off. Sign-up is handled by your project's Auth API, which answers anyone who has the project URL and the public key, and both are in your JavaScript. Disable Allow new users to sign up for internal or invite-only apps, and only existing users can sign in.
Should I turn on email confirmation in Supabase?
For any app with real users, yes. With it off, Supabase treats every address as confirmed, so someone can hold an account under an address they do not own. Confirmation needs your own SMTP provider: the built-in mailer sends 2 emails an hour and only to your team's addresses.
How long does a Supabase session last?
The access token lasts one hour by default and is renewed with a refresh token, which never expires but works only once. A session therefore lasts until the user signs out or you end it. Time-boxed sessions and inactivity timeouts are available on the Pro plan and up.
Is user_metadata safe to use in RLS policies?
No. The user can edit their own user_metadata, so a policy that reads a role or an admin flag from it can be passed by any signed-in user. Use app_metadata, which only your server can set, or a table of your own. The Security Advisor flags the unsafe pattern as an error.
What are the Supabase Auth rate limits?
By default the docs list 30 sign-up and sign-in requests per 5 minutes per IP address, one email link or code per user every 60 seconds, 30 anonymous sign-ins per hour per IP, and 2 emails per hour from the built-in mailer. Most can be changed on the Rate Limits page; requests over a limit get a 429 answer.
Does MFA protect my data on its own?
Only if your policies check it. A session that passed a second factor carries aal2 in its token. Add a restrictive policy that requires aal2 on the tables that matter, or a session with a password alone reads the same rows through the API.
Sources
- 1.General configuration, Supabase Docs
- 2.Creating a Supabase client for SSR, Supabase Docs
- 3.Row Level Security, Supabase Docs
- 4.Redirect URLs, Supabase Docs
- 5.Rate limits, Supabase Docs
- 6.Send emails with custom SMTP, Supabase Docs
- 7.Password security, Supabase Docs
- 8.User sessions, Supabase Docs
- 9.JWT signing keys, Supabase Docs
- 10.Anonymous sign-ins, Supabase Docs
- 11.Multi-factor authentication, Supabase Docs
- 12.Users, Supabase Docs
- 13.Performance and security advisors, Supabase Docs
- 14.Production checklist, Supabase Docs
- 15.Going into production, Supabase Docs