Skip to content

Commit

Permalink
fix: pass down jwt secret as database config (#1432)
Browse files Browse the repository at this point in the history
* fix: pass down jwt secret as database config

* chore: add jwt_exp to app.settings for feature parity
  • Loading branch information
sweatybridge authored Aug 29, 2023
1 parent b801ad5 commit 1522d23
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/db/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ func NewContainerConfig() container.Config {
"POSTGRES_HOST=/var/run/postgresql",
"POSTGRES_INITDB_ARGS=--lc-ctype=C.UTF-8",
"POSTGRES_INITDB_ARGS=--lc-collate=C.UTF-8",
"JWT_SECRET=" + utils.Config.Auth.JwtSecret,
fmt.Sprintf("JWT_EXP=%d", utils.Config.Auth.JwtExpiry),
},
Healthcheck: &container.HealthConfig{
Test: []string{"CMD", "pg_isready", "-U", "postgres", "-h", "localhost", "-p", "5432"},
Expand Down
6 changes: 6 additions & 0 deletions internal/db/start/templates/schema.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
\set pgpass `echo "$PGPASSWORD"`
\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';

ALTER USER authenticator WITH PASSWORD :'pgpass';
ALTER USER pgbouncer WITH PASSWORD :'pgpass';
ALTER USER supabase_auth_admin WITH PASSWORD :'pgpass';
ALTER USER supabase_storage_admin WITH PASSWORD :'pgpass';
ALTER USER supabase_replication_admin WITH PASSWORD :'pgpass';
ALTER USER supabase_read_only_user WITH PASSWORD :'pgpass';

create schema if not exists _realtime;
alter schema _realtime owner to postgres;
Expand Down
1 change: 1 addition & 0 deletions internal/utils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ var Config = config{
"workos": {},
"zoom": {},
},
JwtExpiry: 3600,
JwtSecret: "super-secret-jwt-token-with-at-least-32-characters-long",
AnonKey: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0",
ServiceRoleKey: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU",
Expand Down

0 comments on commit 1522d23

Please sign in to comment.