The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix(self-hosted): remove expose of app.settings.jwt_secret (#45003)
Manuel Rubioe693f206f505
diff --git a/docker/CONFIG.md b/docker/CONFIG.mdindex 7570528711a..0cc6a74784b 100644--- a/docker/CONFIG.md+++ b/docker/CONFIG.md@@ -788,7 +788,7 @@ The fields below are repeated for each provider. Substitute `<PROVIDER>` with on|---|---|---|---|---|| `PGRST_ADMIN_SERVER_HOST` | string | Self-hosted | Hostname for the PostgREST admin server. | Defaults to `server-host` value || `PGRST_ADMIN_SERVER_PORT` | integer | Both | Port for the PostgREST admin server. The admin server is disabled unless a port is set, and it must differ from `PGRST_SERVER_PORT`. | No default (admin server disabled when unset) |-| `PGRST_APP_SETTINGS_*` | string | Self-hosted | Arbitrary settings exposed to PostgreSQL via `current_setting('app.settings.<name>')`. The suffix after `PGRST_APP_SETTINGS_` becomes the setting name (case-insensitive). | Used for `PGRST_APP_SETTINGS_JWT_SECRET` and `PGRST_APP_SETTINGS_JWT_EXP` in self-hosted |+| `PGRST_APP_SETTINGS_*` | string | Self-hosted | Arbitrary settings exposed to PostgreSQL via `current_setting('app.settings.<name>')`. The suffix after `PGRST_APP_SETTINGS_` becomes the setting name (case-insensitive). | Used for `PGRST_APP_SETTINGS_JWT_EXP` in self-hosted || `PGRST_CLIENT_ERROR_VERBOSITY` | enum | Self-hosted | Controls verbosity of client-facing error responses. | Default: `verbose` (other value: `minimal`) || `PGRST_DB_AGGREGATES_ENABLED` | boolean | Self-hosted | Allows the use of aggregate functions (`max`, `sum`, etc.) in queries. Disabled by default due to potential performance risks. | Default: `false` || `PGRST_DB_ANON_ROLE` | string | Both | Database role used for unauthenticated requests. When unset, anonymous access is blocked. | No default |@@ -1380,7 +1380,7 @@ The fields below are repeated for each provider. Substitute `<PROVIDER>` with on| Variable | Type | Set by | Description | Notes ||---|---|---|---|---|-| `JWT_SECRET` | string | Both | HS256 secret stored as `app.settings.jwt_secret` on the `postgres` database. Read by `volumes/db/jwt.sql`. PostgREST and pgjwt-using functions read it via `current_setting()`. | Required. Sourced from `JWT_SECRET` in `.env.example` |+| `JWT_SECRET` | string | Both | HS256 secret used by GoTrue, PostgREST, and other services to sign and verify JWTs. Not exposed to SQL; store it in [Vault](https://supabase.com/docs/guides/database/vault) if a database function needs it. | Required. Sourced from `JWT_SECRET` in `.env.example` || `JWT_EXP` | integer (seconds) | Both | Default JWT expiry (seconds) stored as `app.settings.jwt_exp` on the `postgres` database. Read by `volumes/db/jwt.sql`. | Sourced from `JWT_EXPIRY` in `.env.example` |---diff --git a/docker/docker-compose.yml b/docker/docker-compose.ymlindex ce94117ffd4..a37d39dc7c7 100644--- a/docker/docker-compose.yml+++ b/docker/docker-compose.yml@@ -275,7 +275,6 @@ services:PGRST_JWT_SECRET: ${JWT_JWKS:-${JWT_SECRET}}PGRST_DB_USE_LEGACY_GUCS: "false"- PGRST_APP_SETTINGS_JWT_SECRET: ${JWT_SECRET}PGRST_APP_SETTINGS_JWT_EXP: ${JWT_EXPIRY}command:[@@ -484,7 +483,7 @@ services:- ./volumes/db/webhooks.sql:/docker-entrypoint-initdb.d/init-scripts/98-webhooks.sql:Z# Must be superuser to alter reserved role- ./volumes/db/roles.sql:/docker-entrypoint-initdb.d/init-scripts/99-roles.sql:Z- # Initialize the database settings with JWT_SECRET and JWT_EXP+ # Initialize the database settings with JWT_EXP- ./volumes/db/jwt.sql:/docker-entrypoint-initdb.d/init-scripts/99-jwt.sql:Z# PGDATA directory is persisted between restarts- ./volumes/db/data:/var/lib/postgresql/data:Z@@ -517,7 +516,6 @@ services:POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}PGDATABASE: ${POSTGRES_DB}POSTGRES_DB: ${POSTGRES_DB}- JWT_SECRET: ${JWT_SECRET}JWT_EXP: ${JWT_EXPIRY}command:[diff --git a/docker/volumes/db/jwt.sql b/docker/volumes/db/jwt.sqlindex cfd3b16028f..09a72836662 100644--- a/docker/volumes/db/jwt.sql+++ b/docker/volumes/db/jwt.sql@@ -1,5 +1,3 @@-\set jwt_secret `echo "$JWT_SECRET"`\set jwt_exp `echo "$JWT_EXP"`-ALTER DATABASE postgres SET "app.settings.jwt_secret" TO :'jwt_secret';ALTER DATABASE postgres SET "app.settings.jwt_exp" TO :'jwt_exp';