The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Update Data API docs to include explicit grants (#42969)
Saxon Fletcher6b8772a33e69
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.tsindex 9d4b2bf0e40..3e9a854c652 100644--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts@@ -1494,7 +1494,7 @@ export const api: NavMenuConstant = {items: [{ name: 'How API Keys work', url: '/guides/api/api-keys' },{ name: 'Securing your API', url: '/guides/api/securing-your-api' },- { name: 'Hardening the Data API', url: '/guides/api/hardening-data-api' },+ { name: 'Data API', url: '/guides/database/data-api' },{name: 'Custom Claims & RBAC',url: '/guides/api/custom-claims-and-role-based-access-control-rbac',@@ -2485,7 +2485,7 @@ export const security: NavMenuConstant = {url: '/guides/deployment/shared-responsibility-model' as `/${string}`,},{ name: 'Row Level Security', url: '/guides/database/postgres/row-level-security' },- { name: 'Hardening the Data API', url: '/guides/api/hardening-data-api' },+ { name: 'Data API', url: '/guides/database/data-api' },],},],diff --git a/apps/docs/content/_partials/quickstart_db_setup.mdx b/apps/docs/content/_partials/quickstart_db_setup.mdxindex 7c9489d64bb..ab4f09b4da3 100644--- a/apps/docs/content/_partials/quickstart_db_setup.mdx+++ b/apps/docs/content/_partials/quickstart_db_setup.mdx@@ -32,7 +32,7 @@ curl -X POST https://api.supabase.com/v1/projects \<StepHikeCompact.Details>-When your project is up and running, go to the [Table Editor](/dashboard/project/_/editor), create a new table and insert some data.+When your project is up and running, go to the [**Table Editor**](/dashboard/project/_/editor) section of the Dashboard, create a new table and insert some data. Then in the [**Integrations > Data API**](/dashboard/project/_/integrations/data_api/settings) section of the Dashboard, expose the specific tables or functions you want to access. To automatically grant access for new tables and functions in `public`, enable **Default privileges for new entities**.Alternatively, you can run the following snippet in your project's [SQL Editor](/dashboard/project/_/sql/new). This will create an `instruments` table with some sample data.@@ -54,6 +54,9 @@ Alternatively, you can run the following snippet in your project's [SQL Editor](('cello');alter table instruments enable row level security;++ -- Enable read access for the Data API+ grant select on public.instruments to anon;```</StepHikeCompact.Code>diff --git a/apps/docs/content/guides/api/creating-routes.mdx b/apps/docs/content/guides/api/creating-routes.mdxindex 7c84e6cc82e..7d52ed85137 100644--- a/apps/docs/content/guides/api/creating-routes.mdx+++ b/apps/docs/content/guides/api/creating-routes.mdx@@ -25,29 +25,39 @@ This creates a corresponding route `todos` which can accept `GET`, `POST`, `PATC1. Click **Save**.1. Click **New Column** and create a column with the name `task` and type `text`.1. Click **Save**.--<video width="99%" muted playsInline controls={true}>- <source- src="https://xguihxuzqibwxjnimxev.supabase.co/storage/v1/object/public/videos/docs/api/api-create-table-sm.mp4"- type="video/mp4"- />-</video>+1. In the [**Integrations > Data API**](/dashboard/project/_/integrations/data_api/settings) section of the Dashboard, expose specific tables like `todos` or the functions you want to access. To automatically grant access for new tables and functions in `public`, enable **Default privileges for new entities**.</TabPanel><TabPanel id="sql" label="SQL">```sql- -- Create a table called "todos" with a column to store tasks.+-- Create a table called "todos" with a column to store tasks.create tabletodos (id bigint generated by default as identity primary key,task text check (char_length(task) > 3));++-- Enable Data API access with least-privilege grants+-- Allow read-only access for anonymous clients+grant select on public.todos to anon;+-- Allow full CRUD for authenticated clients+grant select, insert, update, delete on public.todos to authenticated;+-- Allow full CRUD for the server-side service role+grant select, insert, update, delete on public.todos to service_role;+-- Important: enable Row Level Security and create appropriate policies+-- before granting write access to client roles (see RLS guide)```</TabPanel></Tabs>+<Admonition type="note" title="What it means to expose tables or functions via the API">++Granting privileges (like `select` or `execute`) to roles such as `anon` or `authenticated` makes those tables or functions accessible through the Data API. Behind the scenes, the API checks your Postgres permissions—only objects with explicit grants are exposed, and all other access is denied by default.++</Admonition>+## API URL and keysEvery Supabase project has a unique API URL. Your API is secured behind an API gateway which requires an API Key for every request.@@ -92,6 +102,7 @@ using the API URL (`SUPABASE_URL`) and Key (`SUPABASE_PUBLISHABLE_KEY`) we provi```javascript// Initialize the JS clientimport { createClient } from '@supabase/supabase-js'+const supabase = createClient(SUPABASE_URL, SUPABASE_PUBLISHABLE_KEY)// Make a requestdiff --git a/apps/docs/content/guides/api/hardening-data-api.mdx b/apps/docs/content/guides/api/hardening-data-api.mdxdeleted file mode 100644index 7c6e017d59f..00000000000--- a/apps/docs/content/guides/api/hardening-data-api.mdx+++ /dev/null@@ -1,137 +0,0 @@-----title: 'Hardening the Data API'------Your database's auto-generated Data API exposes the `public` schema by default. You can change this to any schema in your database, or even disable the Data API completely.--Any tables that are accessible through the Data API _must_ have [Row Level Security](/docs/guides/database/postgres/row-level-security) enabled. Row Level Security (RLS) is enabled by default when you create tables from the Supabase Dashboard. If you create a table using the SQL editor or your own SQL client or migration runner, you*must* enable RLS yourself.--## Shared responsibility--Your application's security is your responsibility as a developer. This includes RLS, falling under the [Shared Responsibility](/docs/guides/deployment/shared-responsibility-model) model. To help you:--- Supabase sends daily emails warning of any tables that are exposed to the Data API which do not have RLS enabled.-- Supabase provides a Security Advisor and other tools in the Supabase Dashboard to fix any issues.--## Private schemas--We highly recommend creating a `private` schema for storing tables that you do not want to expose via the Data API. These tables can be accessed via Supabase Edge Functions or any other serverside tool. In this model, you should implement your security model in your serverside code. Although it's not required, we _still_ recommend enabling RLS for private tables and then connecting to your database using a Postgres role with `bypassrls` privileges.--## Managing the public schema--If your `public` schema is used by other tools as a default space, you might want to lock down this schema. This helps prevent accidental exposure of data that's automatically added to `public`.--There are several levels of security hardening for the Data API:--- [Disabling the Data API entirely](#disabling-the-data-api). This is recommended if you _never_ need to access your database via Supabase client libraries or the REST and GraphQL endpoints.-- [Exposing a custom schema](#exposing-a-custom-schema-instead-of-public) instead of `public`, giving you explicit control over what is accessible.-- [Automatically enabling RLS on new tables](#automatically-enabling-rls-on-new-tables) using an event trigger.-- [Adjusting table-level grants](#table-level-grants) to control which roles can access specific tables.--## Disabling the Data API--You can disable the Data API entirely if you never intend to use the Supabase client libraries or the REST and GraphQL data endpoints. For example, if you only access your database via a direct connection on the server, disabling the Data API gives you the greatest layer of protection.--1. Go to [API Settings](/dashboard/project/_/settings/api) in the Supabase Dashboard.-1. Under **Data API Settings**, toggle **Enable Data API** off.--## Exposing a custom schema instead of `public`--If you want to use the Data API but with increased security, you can expose a custom schema instead of `public`. By not using `public`, which is often used as a default space and has laxer default permissions, you get more conscious control over your exposed data.--Any data, views, or functions that should be exposed need to be deliberately put within your custom schema (which we will call `api`), rather than ending up there by default.--### Step 1: Remove `public` from exposed schemas--1. Go to [**API Settings**](/dashboard/project/_/settings/api) in the Supabase Dashboard.-1. Under **Data API Settings**, remove `public` from **Exposed schemas**. Also remove `public` from **Extra search path**.-1. Click **Save**.-1. Go to [**Database Extensions**](/dashboard/project/_/database/extensions) and disable the `pg_graphql` extension.--### Step 2: Create an `api` schema and expose it--1. Connect to your database. You can use `psql`, the [Supabase SQL Editor](/dashboard/project/_/sql), or the Postgres client of your choice.--1. Create a new schema named `api`:-- ```sql- create schema if not exists api;- ```--1. Grant the `anon` and `authenticated` roles usage on this schema.-- ```sql- grant usage on schema api to anon, authenticated;- ```--1. Go to [API Settings](/dashboard/project/_/settings/api) in the Supabase Dashboard.--1. Under **Data API Settings**, add `api` to **Exposed schemas**. Make sure it is the first schema in the list, so that it will be searched first by default.--1. Under these new settings, `anon` and `authenticated` can execute functions defined in the `api` schema, but they have no automatic permissions on any tables. On a table-by-table basis, you can grant them permissions. For example:-- ```sql- grant select on table api.<your_table> to anon;- grant select, insert, update, delete on table api.<your_table> to authenticated;- ```--## Automatically enabling RLS on new tables--Tables created via the Supabase Dashboard have RLS enabled by default. However, if you or your team create tables using the SQL editor, migrations, or an external tool, RLS will not be enabled automatically.--You can use an [event trigger](/docs/guides/database/postgres/event-triggers#example-trigger-function---auto-enable-row-level-security) to automatically enable RLS whenever a new table is created in the `public` schema. This ensures that no table is accidentally left exposed without RLS protection.--## Table-level grants--By default, tables in the `public` schema are granted full access (`SELECT`, `INSERT`, `UPDATE`, `DELETE`) to the `anon` and `authenticated` roles. This allows the Data API to query those tables on behalf of users.--You can adjust these privileges on a per-table basis to restrict which operations each role can perform. For example, you might want to:--- Allow `anon` users to only `SELECT` from a table, preventing anonymous writes.-- Prevent `anon` users from accessing a table entirely, making it available only to authenticated users.-- Restrict `authenticated` users to `SELECT` and `INSERT` only, preventing updates and deletes.--<Admonition type="tip">--Table-level privileges work alongside [Row Level Security](/docs/guides/database/postgres/row-level-security). Privileges control _which operations_ are possible, while RLS policies control _which rows_ are accessible. For full protection, use both: restrict privileges to limit operation types, and use RLS policies to control row-level access.--</Admonition>--### Adjusting table-level grants via the Dashboard--<Admonition type="note">--Adjusting table-level privileges via the Dashboard is currently in beta and will be available via gradual roll-out.--</Admonition>--1. Go to [**Table Editor**](/dashboard/project/_/editor) in the Supabase Dashboard.-2. Select the table you want to configure.-3. Click the vertical dots icon to open the table menu and select "Edit table".-4. Under **Data API Access**, click the settings icon to open **Adjust API privileges per role**.-5. For each role (`anon` and `authenticated`), select or deselect the privileges you want to grant.-6. Click **Save**.--### Adjusting table-level grants via SQL--You can also adjust privileges using SQL. For example, to allow only `SELECT` access for `anon` on a table:--```sql--- Revoke all existing privileges-revoke all on table public.your_table from anon;---- Grant only SELECT-grant select on table public.your_table to anon;-```--To remove all access for `anon` from a table:--```sql-revoke all on table public.your_table from anon;-```--To restore full access:--```sql-grant select, insert, update, delete on table public.your_table to anon;-```diff --git a/apps/docs/content/guides/api/quickstart.mdx b/apps/docs/content/guides/api/quickstart.mdxindex 81558335907..08a0bc9e17e 100644--- a/apps/docs/content/guides/api/quickstart.mdx+++ b/apps/docs/content/guides/api/quickstart.mdx@@ -38,17 +38,21 @@ We'll create a database table called `todos` for storing tasks. This creates a cid serial primary key,task text);++ -- Enable Data API access+ -- Allow read-only access for anonymous clients+ grant select on public.todos to anon;```</TabPanel><TabPanel id="dashboard" label="Dashboard">- <video width="99%" muted playsInline controls={true}>- <source- src="https://xguihxuzqibwxjnimxev.supabase.co/storage/v1/object/public/videos/docs/api/api-create-table-sm.mp4"- type="video/mp4"- />- </video>+ 1. Go to the [**Table editor**](/dashboard/project/_/editor) section in the Dashboard.+ 2. Click **New Table** and create a table with the name `todos`.+ 3. Click **Save**.+ 4. Click **New Column** and create a column with the name `task` and type `text`.+ 5. Click **Save**.+ 6. In the [**Integrations > Data API**](/dashboard/project/_/integrations/data_api/settings) section of the Dashboard, expose the `todos` table. To automatically grant access for new tables and functions in `public`, enable **Default privileges for new entities**.</TabPanel></Tabs>@@ -61,7 +65,7 @@ We'll create a database table called `todos` for storing tasks. This creates a c<StepHikeCompact.Details title="Allow public access">- Let's turn on Row Level Security for this table and allow public access.+ Let's turn on Row Level Security for this table, create the required policies, and then grant any write access.</StepHikeCompact.Details>@@ -78,6 +82,18 @@ We'll create a database table called `todos` for storing tasks. This creates a cfor selectto anonusing (true);++ -- Allow authenticated users to read and modify todos+ create policy "Allow authenticated users to manage todos"+ on todos+ for all+ to authenticated+ using (true)+ with check (true);++ -- Grant write access only after RLS and policies are in place+ grant select, insert, update, delete on public.todos to authenticated;+ grant select, insert, update, delete on public.todos to service_role;```</StepHikeCompact.Code>diff --git a/apps/docs/content/guides/api/securing-your-api.mdx b/apps/docs/content/guides/api/securing-your-api.mdxindex 416476cf744..59d667a4a6e 100644--- a/apps/docs/content/guides/api/securing-your-api.mdx+++ b/apps/docs/content/guides/api/securing-your-api.mdx@@ -8,15 +8,15 @@ The data APIs are designed to work with Postgres Row Level Security (RLS). If yoTo control access to your data, you can use [Policies](/docs/guides/auth#policies).-## Enabling row level security+## Add RLS policies-Any table you create in the `public` schema will be accessible via the Supabase Data API.+Enable Row Level Security (RLS) on all tables and views you have exposed via the Data API. You can then write RLS policies to grant users access to specific database rows based on their authentication token.-To restrict access, enable Row Level Security (RLS) on all tables, views, and functions in the `public` schema. You can then write RLS policies to grant users access to specific database rows or functions based on their authentication token.+For functions, RLS does not apply. Instead, control access by granting `EXECUTE` privileges only to the roles that should be able to call the function, and review any `SECURITY DEFINER` functions carefully.<Admonition type="danger">-Always enable Row Level Security on tables, views, and functions in the `public` schema to protect your data.+Always enable Row Level Security on tables and views you expose via the Data API to protect your data. For functions, restrict access by granting `EXECUTE` only to appropriate roles.</Admonition>@@ -49,14 +49,10 @@ With RLS enabled, you can create Policies that allow or disallow users to access<Admonition type="danger">-Any table **without RLS enabled** in the `public` schema will be accessible to the public, using the `anon` role. Always make sure that RLS is enabled or that you've got other security measures in place to avoid unauthorized access to your project's data!+Any exposed table **without RLS enabled** can be accessed by roles with matching Data API grants (for example, `anon`). Always make sure RLS is enabled, or that you've got other controls in place to avoid unauthorized access to your project's data.</Admonition>-## Disable the API or restrict to custom schema--If you don't use the Data API, or if you don't want to expose the `public` schema, you can either disable it entirely or change the automatically exposed schema to one of your choice. See **[Hardening the Data API](/docs/guides/api/hardening-data-api)** for instructions.-## Enforce additional rules on each requestUsing Row Level Security policies may not always be adequate or sufficient to protect APIs.@@ -66,7 +62,7 @@ Here are some common situations where additional protections are necessary:- Enforcing per-IP or per-user rate limits.- Checking custom or additional API keys before allowing further access.- Rejecting requests after exceeding a quota or requiring payment.-- Disallowing direct access to certain tables, views or functions in the `public` schema.+- Disallowing direct access to certain tables, views, or functions in exposed schemas.You can build these cases in your application by creating a Postgres function that will read information from the request and perform additional checks, such as counting the number of requests received or checking that an API key is already registered in your database before serving the response.diff --git a/apps/docs/content/guides/database/data-api.mdx b/apps/docs/content/guides/database/data-api.mdxnew file mode 100644index 00000000000..3db9204f64e--- /dev/null+++ b/apps/docs/content/guides/database/data-api.mdx@@ -0,0 +1,47 @@+---+title: 'Data API'+description: 'Quick options for managing Data API exposure and access.'+---++The Supabase Data API is a standalone server that sits between your application client code and your database. It automatically generates a fully RESTful API based on your database structure, allowing you to interact with your database through HTTP endpoints.++With the Data API, you have granular control over exposure: expose specific tables and functions by granting Data API roles the access they need, or enable **Default privileges for new entities** to automatically grant access to new tables and functions in `public`.++<Admonition type="caution">++Any table that is exposed through the Data API should have [Row Level Security (RLS) enabled](/docs/guides/database/postgres/row-level-security) to prevent unauthorized data access.++</Admonition>++## Expose specific tables and functions (recommended)++In [Data API integrations settings](/dashboard/project/_/integrations/data_api/settings), expose specific tables and functions and grant only the privileges each role needs.++```sql+grant select on table public.your_table to anon;+grant select, insert, update, delete on table public.your_table to authenticated;+grant execute on function public.your_function to anon, authenticated;+```++## Use default privileges for new entities in `public`++If you want new entities in `public` to be accessible automatically, enable **Default privileges for new entities** in the [**Integrations > Data API**](/dashboard/project/_/integrations/data_api/settings) section of the Dashboard. This applies only to new tables and functions in `public`.++```sql+alter default privileges for role postgres in schema public+grant select, insert, update, delete on tables to anon, authenticated, service_role;++alter default privileges for role postgres in schema public+grant execute on functions to anon, authenticated, service_role;+```++## Disable the Data API completely++If your app never uses Supabase client libraries, REST, or GraphQL data endpoints:++1. In the [**Integrations > Data API**](/dashboard/project/_/integrations/data_api/overview) section of the Dashboard.+1. Turn **Enable Data API** off.++## Learn more++To learn more about the Data API, see the [full guide](/docs/guides/api).diff --git a/apps/docs/content/guides/database/secure-data.mdx b/apps/docs/content/guides/database/secure-data.mdxindex 3ddd3adef16..0b23425dda1 100644--- a/apps/docs/content/guides/database/secure-data.mdx+++ b/apps/docs/content/guides/database/secure-data.mdx@@ -28,6 +28,6 @@ Supabase and Postgres provide you with multiple ways to manage security, includi- [Row Level Security](/docs/guides/database/postgres/row-level-security)- [Column Level Security](/docs/guides/database/postgres/column-level-security)-- [Hardening the Data API](/docs/guides/api/hardening-data-api)+- [Data API](/docs/guides/database/data-api)- [Managing Postgres roles](/docs/guides/database/postgres/roles)- [Managing secrets with Vault](/docs/guides/database/vault)diff --git a/apps/docs/content/guides/security/product-security.mdx b/apps/docs/content/guides/security/product-security.mdxindex f400d93829e..2acf856faa8 100644--- a/apps/docs/content/guides/security/product-security.mdx+++ b/apps/docs/content/guides/security/product-security.mdx@@ -19,7 +19,7 @@ Various products at Supabase have their own hardening and configuration guides,- [Row Level Security](/docs/guides/database/postgres/row-level-security)- [Column Level Security](/docs/guides/database/postgres/column-level-security)-- [Hardening the Data API](/docs/guides/api/hardening-data-api)+- [Data API](/docs/guides/database/data-api)- [Additional security controls for the Data API](/docs/guides/api/securing-your-api)- [Custom claims and role based access control](/docs/guides/api/custom-claims-and-role-based-access-control-rbac)- [Managing Postgres roles](/docs/guides/database/postgres/roles)diff --git a/apps/docs/content/troubleshooting/database-api-42501-errors.mdx b/apps/docs/content/troubleshooting/database-api-42501-errors.mdxindex 8251081019b..0e0f30b35cf 100644--- a/apps/docs/content/troubleshooting/database-api-42501-errors.mdx+++ b/apps/docs/content/troubleshooting/database-api-42501-errors.mdx@@ -49,7 +49,7 @@ If you created a custom schema, you will have to give the Database API permissioIf you see an error like `permission denied for table your_table`, the querying role may not have the required privilege for the operation.-By default, tables in the `public` schema are granted `SELECT`, `INSERT`, `UPDATE`, and `DELETE` to the `anon` and `authenticated` roles. However, these privileges can be adjusted via the [Dashboard Table Editor](/dashboard/project/_/editor) or via SQL.+By default, tables in the `public` schema are granted `SELECT`, `INSERT`, `UPDATE`, and `DELETE` to the `anon` and `authenticated` roles. However, you can change these privileges in the [**Integrations > Data API**](/dashboard/project/_/integrations/data_api/settings) section of the Dashboard or via SQL.To check the current privileges on a table:@@ -75,7 +75,7 @@ grant select, insert, update, delete on table public.your_table to anon, authentGranting privileges allows access to your table through the Data API, so you should ensure you [enable RLS](/docs/guides/database/postgres/row-level-security) and write appropriate policies to protect your data.-For more information, see [Adjusting table-level privileges](/docs/guides/api/hardening-data-api#adjusting-table-level-privileges).+For more information, see [Data API](/docs/guides/database/data-api).</Admonition>diff --git a/apps/docs/docs/ref/csharp/installing.mdx b/apps/docs/docs/ref/csharp/installing.mdxindex 89fac0df7fa..602fb136ed1 100644--- a/apps/docs/docs/ref/csharp/installing.mdx+++ b/apps/docs/docs/ref/csharp/installing.mdx@@ -33,3 +33,36 @@ custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supab</RefSubLayout.Examples></RefSubLayout.EducationRow>++### Enable Data API access++<RefSubLayout.EducationRow>+ <RefSubLayout.Details>++ supabase-csharp uses the Data API to query and mutate your Postgres data. You first need to grant Data API roles permissions to access your tables and functions.++ In the [**Integrations > Data API**](/dashboard/project/_/integrations/data_api/settings) section of the Dashboard, expose the specific tables and functions you want to access. To automatically grant access for new tables and functions in `public`, enable **Default privileges for new entities**.++ Alternatively, use SQL to grant the required permissions:++ </RefSubLayout.Details>++ <RefSubLayout.Examples>++ ```sql+ -- Before granting access to client roles, make sure RLS is enabled+ -- and create the policies required for each role's allowed operations.+ alter table public.your_table enable row level security;+ -- create policy ... on public.your_table ...;++ -- Grant least-privilege access to tables after RLS and policies are in place+ grant select on public.your_table to anon;+ grant select, insert, update, delete on public.your_table to authenticated;+ grant all on public.your_table to service_role;++ -- Grant execute on functions after verifying any table access they rely on+ grant execute on function public.your_function to authenticated, service_role;+ ```++ </RefSubLayout.Examples>+</RefSubLayout.EducationRow>diff --git a/apps/docs/docs/ref/dart/installing.mdx b/apps/docs/docs/ref/dart/installing.mdxindex 3508de723c2..fb6071df865 100644--- a/apps/docs/docs/ref/dart/installing.mdx+++ b/apps/docs/docs/ref/dart/installing.mdx@@ -40,3 +40,36 @@ custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supab</RefSubLayout.Examples></RefSubLayout.EducationRow>++### Enable Data API access++<RefSubLayout.EducationRow>+ <RefSubLayout.Details>++ supabase_flutter uses the Data API to query and mutate your Postgres data. You first need to grant Data API roles permissions to access your tables and functions.++ In [Data API integrations settings](/dashboard/project/_/integrations/data_api/settings), expose the specific tables and functions you want to access. To automatically grant access for new tables and functions in `public`, enable **Default privileges for new entities**.++ Alternatively, use SQL to grant the required permissions:++ </RefSubLayout.Details>++ <RefSubLayout.Examples>++ ```sql+ -- Before granting access to client roles, make sure RLS is enabled+ -- and create the policies required for each role's allowed operations.+ alter table public.your_table enable row level security;+ -- create policy ... on public.your_table ...;++ -- Grant least-privilege access to tables after RLS and policies are in place+ grant select on public.your_table to anon;+ grant select, insert, update, delete on public.your_table to authenticated;+ grant all on public.your_table to service_role;++ -- Grant execute on functions after verifying any table access they rely on+ grant execute on function public.your_function to authenticated, service_role;+ ```++ </RefSubLayout.Examples>+</RefSubLayout.EducationRow>diff --git a/apps/docs/docs/ref/javascript/installing.mdx b/apps/docs/docs/ref/javascript/installing.mdxindex 58e1b6555e2..4df46be0f57 100644--- a/apps/docs/docs/ref/javascript/installing.mdx+++ b/apps/docs/docs/ref/javascript/installing.mdx@@ -85,3 +85,36 @@ custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supab</RefSubLayout.Examples></RefSubLayout.EducationRow>++### Enable Data API access++<RefSubLayout.EducationRow>+ <RefSubLayout.Details>++ supabase-js uses the Data API to query and mutate your Postgres data. You first need to grant Data API roles permissions to access your tables and functions.++ In [Data API integrations settings](/dashboard/project/_/integrations/data_api/settings), expose the specific tables and functions you want to access. To automatically grant access for new tables and functions in `public`, enable **Default privileges for new entities**.++ Alternatively, use SQL to grant the required permissions:++ </RefSubLayout.Details>++ <RefSubLayout.Examples>++ ```sql+ -- Before granting access to client roles, make sure RLS is enabled+ -- and create the policies required for each role's allowed operations.+ alter table public.your_table enable row level security;+ -- create policy ... on public.your_table ...;++ -- Grant least-privilege access to tables after RLS and policies are in place+ grant select on public.your_table to anon;+ grant select, insert, update, delete on public.your_table to authenticated;+ grant all on public.your_table to service_role;++ -- Grant execute on functions after verifying any table access they rely on+ grant execute on function public.your_function to authenticated, service_role;+ ```++ </RefSubLayout.Examples>+</RefSubLayout.EducationRow>diff --git a/apps/docs/docs/ref/kotlin/installing.mdx b/apps/docs/docs/ref/kotlin/installing.mdxindex 510b368371c..9dac15be39f 100644--- a/apps/docs/docs/ref/kotlin/installing.mdx+++ b/apps/docs/docs/ref/kotlin/installing.mdx@@ -397,3 +397,37 @@ By default, [KotlinX Serialization](https://github.com/Kotlin/kotlinx.serializat</RefSubLayout.Examples></RefSubLayout.EducationRow>++### Enable Data API access++<RefSubLayout.EducationRow>+ <RefSubLayout.Details>++ supabase-kt uses the Data API to query and mutate your Postgres data. You first need to grant Data API roles permissions to access your tables and functions.++ In [Data API integrations settings](/dashboard/project/_/integrations/data_api/settings), expose the specific tables and functions you want to access. To automatically grant access for new tables and functions in `public`, enable **Default privileges for new entities**.++ Alternatively, use SQL to grant the required permissions:++ </RefSubLayout.Details>++ <RefSubLayout.Examples>++ ```sql+ -- Before granting access to client roles, make sure RLS is enabled+ -- and create the policies required for each role's allowed operations.+ alter table public.your_table enable row level security;+ -- create policy ... on public.your_table ...;++ -- Grant least-privilege access to tables after RLS and policies are in place+ grant select on public.your_table to anon;+ grant select, insert, update, delete on public.your_table to authenticated;+ grant all on public.your_table to service_role;++ -- Grant execute on functions after verifying any table access they rely on+ grant execute on function public.your_function to authenticated, service_role;+ ```++ </RefSubLayout.Examples>++</RefSubLayout.EducationRow>diff --git a/apps/docs/docs/ref/python/installing.mdx b/apps/docs/docs/ref/python/installing.mdxindex fb1be005e46..33dbd199571 100644--- a/apps/docs/docs/ref/python/installing.mdx+++ b/apps/docs/docs/ref/python/installing.mdx@@ -40,3 +40,36 @@ custom_edit_url: https://github.com/supabase/supabase/edit/master/apps/docs/spec</RefSubLayout.Examples></RefSubLayout.EducationRow>++### Enable Data API access++<RefSubLayout.EducationRow>+ <RefSubLayout.Details>++ supabase-py uses the Data API to query and mutate your Postgres data. You first need to grant Data API roles permissions to access your tables and functions.++ In [Data API integrations settings](/dashboard/project/_/integrations/data_api/settings), expose the specific tables and functions you want to access. To automatically grant access for new tables and functions in `public`, enable **Default privileges for new entities**.++ Alternatively, use SQL to grant the required permissions:++ </RefSubLayout.Details>++ <RefSubLayout.Examples>++ ```sql+ -- Before granting access to client roles, make sure RLS is enabled+ -- and create the policies required for each role's allowed operations.+ alter table public.your_table enable row level security;+ -- create policy ... on public.your_table ...;++ -- Grant least-privilege access to tables after RLS and policies are in place+ grant select on public.your_table to anon;+ grant select, insert, update, delete on public.your_table to authenticated;+ grant all on public.your_table to service_role;++ -- Grant execute on functions after verifying any table access they rely on+ grant execute on function public.your_function to authenticated, service_role;+ ```++ </RefSubLayout.Examples>+</RefSubLayout.EducationRow>diff --git a/apps/docs/docs/ref/swift/installing.mdx b/apps/docs/docs/ref/swift/installing.mdxindex 2ba0b701403..218674a413d 100644--- a/apps/docs/docs/ref/swift/installing.mdx+++ b/apps/docs/docs/ref/swift/installing.mdx@@ -65,3 +65,36 @@ custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supab</RefSubLayout.Examples></RefSubLayout.EducationRow>++### Enable Data API access++<RefSubLayout.EducationRow>+ <RefSubLayout.Details>++ supabase-swift uses the Data API to query and mutate your Postgres data. You first need to grant Data API roles permissions to access your tables and functions.++ In [Data API integrations settings](/dashboard/project/_/integrations/data_api/settings), expose the specific tables and functions you want to access. To automatically grant access for new tables and functions in `public`, enable **Default privileges for new entities**.++ Alternatively, use SQL to grant the required permissions:++ </RefSubLayout.Details>++ <RefSubLayout.Examples>++ ```sql+ -- Before granting access to client roles, make sure RLS is enabled+ -- and create the policies required for each role's allowed operations.+ alter table public.your_table enable row level security;+ -- create policy ... on public.your_table ...;++ -- Grant least-privilege access to tables after RLS and policies are in place+ grant select on public.your_table to anon;+ grant select, insert, update, delete on public.your_table to authenticated;+ grant all on public.your_table to service_role;++ -- Grant execute on functions after verifying any table access they rely on+ grant execute on function public.your_function to authenticated, service_role;+ ```++ </RefSubLayout.Examples>+</RefSubLayout.EducationRow>diff --git a/apps/www/lib/redirects.js b/apps/www/lib/redirects.jsindex 32ce2730f50..9394dd61e32 100644--- a/apps/www/lib/redirects.js+++ b/apps/www/lib/redirects.js@@ -7,7 +7,12 @@ module.exports = [{permanent: true,source: '/docs/guides/database/hardening-data-api',- destination: '/docs/guides/api/hardening-data-api',+ destination: '/docs/guides/api/securing-your-api',+ },+ {+ permanent: true,+ source: '/docs/guides/api/hardening-data-api',+ destination: '/docs/guides/api/securing-your-api',},{permanent: true,