-
-
Notifications
You must be signed in to change notification settings - Fork 2
feat(docker): remove superuser access #1592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 5 commits
03bbe10
f024b97
af2237f
d093806
1abd994
5f7b954
c020ef8
a7f57cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,71 @@ | ||||||
| --- | ||||||
| title: 'Remove superuser access' | ||||||
| description: 'Learn how to remove superuser access from studio and migrate from the supabase_admin to postgres role in self-hosted Supabase.' | ||||||
| subtitle: 'Learn how to remove superuser access from studio and migrate from the supabase_admin to postgres role in self-hosted Supabase.' | ||||||
| --- | ||||||
|
|
||||||
| ## Overview | ||||||
|
|
||||||
| In late 2022, Supabase introduced a security change in hosted projects that removed superuser access from dashboard SQL editor and shifted ownership of user-created database objects away from `supabase_admin` toward the `postgres` role. | ||||||
| You can read more about it in the [official announcement](https://github.com/orgs/supabase/discussions/9314). | ||||||
|
|
||||||
| However, this migration was never automatically applied to self-hosted Supabase instances. | ||||||
| As a result: | ||||||
|
|
||||||
| - Objects created via the dashboard may still be owned by `supabase_admin` | ||||||
| - Behavior differs from hosted Supabase | ||||||
| - Some migrations may fail when run as postgres | ||||||
|
|
||||||
| This guide explains how to bring your self-hosted Supabase instance in line with the security enhancements and ownership model used in hosted Supabase. | ||||||
|
|
||||||
| <Admonition type="tip"> | ||||||
|
|
||||||
| This migration only updates ownership for database objects in the `public` schema. Supabase managed schemas are not affected. | ||||||
|
|
||||||
| </Admonition> | ||||||
|
|
||||||
| ## Configuration | ||||||
|
|
||||||
| ### Step 1: Run the ownership migration script | ||||||
|
|
||||||
| Execute the script that reassigns ownership of database objects in the `public` schema from `supabase_admin` to `postgres` | ||||||
|
|
||||||
| ```sh | ||||||
| sh ./utils/remove-superuser-access | ||||||
| ``` | ||||||
|
|
||||||
| ### Step 2: Update environment variables in docker-compose.yml | ||||||
|
|
||||||
| - Open your docker-compose.yml file and locate the `studio` service environment variables. | ||||||
| Uncomment the following line so studio uses `postgres` role for read/write access: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [rdjsonl] reported by reviewdog 🐶 |
||||||
|
|
||||||
| ```yml | ||||||
| studio: | ||||||
| environment: | ||||||
| POSTGRES_USER_READ_WRITE: postgres | ||||||
| ``` | ||||||
|
|
||||||
| - Next, locate the `meta` service environment variables. Change the `PG_META_DB_USER` environment variable from `supabase_admin` to `postgres`: | ||||||
|
|
||||||
| ```yml | ||||||
| meta: | ||||||
| environment: | ||||||
| PG_META_DB_USER: postgres | ||||||
| ``` | ||||||
|
|
||||||
| - Save the file and exit. | ||||||
|
|
||||||
| ### Step 3: Restart services | ||||||
|
|
||||||
| ```sh | ||||||
| docker compose down && docker compose up -d | ||||||
| ``` | ||||||
|
|
||||||
| ## Verify the configuration | ||||||
|
|
||||||
| After restarting your services, verify that Supabase Studio is now using the postgres role. Run the following query in the Supabase Studio SQL Editor: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [rdjsonl] reported by reviewdog 🐶
Suggested change
|
||||||
|
|
||||||
| ```sql | ||||||
| select current_user; | ||||||
| -- expected result: postgres | ||||||
| ``` | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #!/bin/sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [rdjsonl] reported by reviewdog 🐶
[Rule003Spelling] Word not found in dictionary: postgres (configure rule at supa-mdx-lint/Rule003Spelling.toml)