mirror of
https://github.com/supabase/supabase.git
synced 2026-10-10 20:05:06 +03:00
Updates our documentation pages around the Data API to include instructions on how to grant the necessary privileges across API roles across tables and functions. Current behaviour means this is largely unnecessary as privileges are granted by default on public schema, but adding instructions will help cover scenarios where this isn't the case and expose some of the underlying magic happening. ## To test: - These updates refer to new settings that are added to the data api that give more visibility and control over what tables and functions are accessible via the api. - To view these settings you'll need enable `tableEditorApiAccessToggle ` feature flag <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Added a new "Data API" guide and removed the old "Hardening the Data API" page * Updated navigation links to surface the new Data API guide * Expanded quickstarts, SDK install pages, and security guides with step‑by‑step Data API exposure, default‑privileges, RLS guidance, and SQL GRANT examples (including function EXECUTE notes) * Updated troubleshooting references and added redirects for legacy documentation paths <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: SaxonF <1072756+SaxonF@users.noreply.github.com> Co-authored-by: Chris Chinchilla <chris.ward@supabase.io> Co-authored-by: Chris Chinchilla <chris@chrischinchilla.com>
80 lines
2.4 KiB
Plaintext
80 lines
2.4 KiB
Plaintext
<StepHikeCompact.Details title="Create a Supabase project">
|
|
|
|
Go to [database.new](https://database.new) and create a new Supabase project.
|
|
|
|
Alternatively, you can create a project using the Management API:
|
|
|
|
</StepHikeCompact.Details>
|
|
|
|
<StepHikeCompact.Code>
|
|
|
|
```bash
|
|
# First, get your access token from https://supabase.com/dashboard/account/tokens
|
|
export SUPABASE_ACCESS_TOKEN="your-access-token"
|
|
|
|
# List your organizations to get the organization ID
|
|
curl -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \
|
|
https://api.supabase.com/v1/organizations
|
|
|
|
# Create a new project (replace <org-id> with your organization ID)
|
|
curl -X POST https://api.supabase.com/v1/projects \
|
|
-H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"organization_id": "<org-id>",
|
|
"name": "My Project",
|
|
"region": "us-east-1",
|
|
"db_pass": "<your-secure-password>"
|
|
}'
|
|
```
|
|
|
|
</StepHikeCompact.Code>
|
|
|
|
<StepHikeCompact.Details>
|
|
|
|
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.
|
|
|
|
</StepHikeCompact.Details>
|
|
|
|
<StepHikeCompact.Code>
|
|
|
|
```sql SQL_EDITOR
|
|
-- Create the table
|
|
create table instruments (
|
|
id bigint primary key generated always as identity,
|
|
name text not null
|
|
);
|
|
-- Insert some sample data into the table
|
|
insert into instruments (name)
|
|
values
|
|
('violin'),
|
|
('viola'),
|
|
('cello');
|
|
|
|
alter table instruments enable row level security;
|
|
|
|
-- Enable read access for the Data API
|
|
grant select on public.instruments to anon;
|
|
```
|
|
|
|
</StepHikeCompact.Code>
|
|
|
|
<StepHikeCompact.Details>
|
|
|
|
Make the data in your table publicly readable by adding an RLS policy:
|
|
|
|
</StepHikeCompact.Details>
|
|
|
|
<StepHikeCompact.Code>
|
|
|
|
```sql SQL_EDITOR
|
|
create policy "public can read instruments"
|
|
on public.instruments
|
|
for select to anon
|
|
using (true);
|
|
```
|
|
|
|
</StepHikeCompact.Code>
|