mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
> [!WARNING] > This PR relies on #54282 being merged first. ## Problem Database password and token access appear as separate sections in Database Settings, although both control connections to Postgres. ## Solution Group the existing controls under **Database access**, with **Password access** first and the switch beside **Token access**. Nest **Members** inside the Token access card and label its action **Add member**. Preserve the existing feature gates, permissions, toggle behaviour, dialogs and section anchors. Use shared card headings for Members, centre the token switch beside its description, and darken the Members table header. Update the matching token-access and password-reset docs instructions. ```text Database access ├── Password access └── Token access [switch] └── Members [Add member] ``` | After | | --- | | <img width="735" height="818" alt="CleanShot 2026-12-01 at 15 56 50" src="https://github.com/user-attachments/assets/f1207a2f-80d5-480a-9529-e110b960f427" /> | | _App [token] access coming separately in https://github.com/supabase/supabase/pull/53917._ | ## Review instructions 1. Open a project's **Database → Settings** page. Check that **Database access** contains **Password access** first, with the existing **Reset database password** button. 2. With the database token access preview enabled, check that **Token access** has its switch on the same row and **Members** appears inside the same card when enabled. Check that **Add member** opens the existing access rule sheet. 3. Check the existing enable confirmation and password reset dialog. Projects requiring SSL enforcement or a Postgres upgrade should keep their existing notices and actions.
87 lines
4.4 KiB
Plaintext
87 lines
4.4 KiB
Plaintext
---
|
|
title: 'Database token access'
|
|
description: 'Enable database token access for short-lived database connections tied to a Supabase user.'
|
|
---
|
|
|
|
Your Supabase project supports connecting to the Postgres database using either your Supabase API token (Personal Access Token) or your current dashboard session token (JWT). This is called database token access. The authentication tokens can be short-lived and tied directly to a specific Supabase user. Database token access is disabled by default.
|
|
|
|
Enabling database token access only applies to connections to Postgres and the shared pooler ([Supavisor](https://supabase.github.io/supavisor/)). All HTTP APIs offered by Supabase (e.g., PostgREST, Storage, Auth) require authentication tokens specific to the service and are independent of the Supabase platform user(s).
|
|
|
|
<Admonition type="note">
|
|
|
|
[Enforce SSL](/docs/guides/platform/ssl-enforcement) on incoming connections must be enabled before database token access can be used.
|
|
|
|
</Admonition>
|
|
|
|
<Admonition type="note">
|
|
|
|
Projects need to be at least on Postgres 17.6.1.081 (or higher) to enable database token access. You can find the Postgres version of your project on the [General Settings](/dashboard/project/_/settings/general) page. If your project is on an older version, you will need to [upgrade](/docs/guides/platform/upgrading) to use this feature.
|
|
|
|
</Admonition>
|
|
|
|
## Manage database token access in the Dashboard [#manage-temporary-access-via-the-dashboard]
|
|
|
|
In [Database Settings](/dashboard/project/_/database/settings), go to **Database access** and turn on **Token access**.
|
|
|
|
## Manage database token access with the Management API [#manage-temporary-access-via-the-management-api]
|
|
|
|
You can also manage database token access using the Management API.
|
|
|
|
```bash
|
|
# Get your access token from https://supabase.com/dashboard/account/tokens
|
|
export SUPABASE_MANAGEMENT_API_TOKEN="your-access-token"
|
|
export PROJECT_REF="your-project-ref"
|
|
|
|
# Get the current database token access status
|
|
curl -X GET "https://api.supabase.com/v1/projects/$PROJECT_REF/jit-access" \
|
|
-H "Authorization: Bearer $SUPABASE_MANAGEMENT_API_TOKEN"
|
|
|
|
# Enable database token access
|
|
curl -X PUT "https://api.supabase.com/v1/projects/$PROJECT_REF/jit-access" \
|
|
-H "Authorization: Bearer $SUPABASE_MANAGEMENT_API_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"state":"enabled"
|
|
}'
|
|
|
|
# Disable database token access
|
|
curl -X PUT "https://api.supabase.com/v1/projects/$PROJECT_REF/jit-access" \
|
|
-H "Authorization: Bearer $SUPABASE_MANAGEMENT_API_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"state":"disabled"
|
|
}'
|
|
```
|
|
|
|
## Configure member access [#configure-user-access]
|
|
|
|
After you enable database token access, use member access rules to map each team member to the [Postgres roles](/docs/guides/database/postgres/roles) they can assume. You can also limit each role by expiry and by network. For more information, see [Map team members to Postgres roles](/docs/guides/platform/team-database-access).
|
|
|
|
## Connect with database token access [#using-temporary-access]
|
|
|
|
<Admonition type="note">
|
|
|
|
This feature does not work with the dedicated pooler. Direct connections and connections through the shared pooler are fully supported.
|
|
|
|
</Admonition>
|
|
|
|
To log in to the database using database token access, existing connection strings can be used and only the password needs to be changed to the user's API or dashboard token.
|
|
|
|
For example, if a user has been authorized to assume the `postgres` role:
|
|
|
|
```
|
|
psql 'postgres://postgres:sbp_111222333aaabbbccc@db.{project-ref}.supabase.co/postgres'
|
|
```
|
|
|
|
Since Supabase API tokens can be used, it is also possible to generate API tokens for services you don't want to share your Postgres role password with (for example a GitHub Action). The API token can be configured with an expiry time and database token access restrictions can also be applied.
|
|
|
|
Connecting via the shared [connection pooler](/docs/guides/database/connecting-to-postgres/pooling-and-limits) requires the addition of a new connection option. This can be applied either directly in the connection URI or as `conninfo` (easier to read):
|
|
|
|
```
|
|
# directly in the URI
|
|
psql 'postgres://postgres.{project-ref}:sbp_111222333aaabbbccc@aws-1-us-west-1.pooler.supabase.com:5432/postgres?options=-c%20jit%3dtrue'
|
|
|
|
# or as a connection info string
|
|
psql "host=aws-1-us-west-1.pooler.supabase.com user=postgres.{project-ref} options='-c jit=true'"
|
|
```
|