flâneur — a map of the web's best reading

Understanding API Keys | Supabase Docs

supabase.com · 1,616 words · saved by 1 readers

Supabase provides two default keys when you create a project: an anon key, and a service_role key. You can find both keys in the API Settings. The data APIs are designed to work with Postgres Row Level Security (RLS). These keys both map to Postgres roles. You can find an anon user and a service_role user in the Roles section of the dashboard. The keys are both long-lived JWTs. If you decode these keys, you will see that they contain the "role", an "issued date", and an "expiry date" ~10 years in the future. The anon key has very few privileges. You can use it in your RLS policies for "anonymous" access. For example, this policy will allow access to the profiles table: And similarity for disallowing access: If you are using Supabase Auth, then the anon role will automatically update to authenticated once a user is logged in: The "service_role" is a predefined Postgres role with elevated privileges, designed to perform various administrative and service-related tasks. It can bypass Row

Supabase gives you fine-grained control over which application components are allowed to access your project through API keys. Looking for your API Keys? In most cases, you can get the correct key from the Project's Connect dialog , but if you want a specific key, you can find all keys in the Settings > API Keys section of the Dashboard: API keys provide the first layer of authentication for data access. Auth then builds upon that. This chart covers the differences: Responsibility Question Answer API keys What is accessing the project? Web page, mobile app, server, Edge Function... Supabase Au

Explore this link on the map →

related reading