Skip to content

Commit 36de7c4

Browse files
committed
fix: resolve jwks when initialising realtime tenant
1 parent 04a0dfc commit 36de7c4

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

internal/db/start/start.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ func InitSchema14(ctx context.Context, conn *pgx.Conn) error {
272272
return file.ExecBatch(ctx, conn)
273273
}
274274

275-
func initRealtimeJob(host string) utils.DockerJob {
275+
func initRealtimeJob(host, jwks string) utils.DockerJob {
276276
return utils.DockerJob{
277277
Image: utils.Config.Realtime.Image,
278278
Env: []string{
@@ -284,6 +284,7 @@ func initRealtimeJob(host string) utils.DockerJob {
284284
"DB_NAME=postgres",
285285
"DB_AFTER_CONNECT_QUERY=SET search_path TO _realtime",
286286
"DB_ENC_KEY=" + utils.Config.Realtime.EncryptionKey,
287+
fmt.Sprintf("API_JWT_JWKS=%s", jwks),
287288
"API_JWT_SECRET=" + utils.Config.Auth.JwtSecret.Value,
288289
"METRICS_JWT_SECRET=" + utils.Config.Auth.JwtSecret.Value,
289290
"APP_NAME=realtime",
@@ -341,7 +342,11 @@ func initSchema15(ctx context.Context, host string) error {
341342
// Apply service migrations
342343
var initJobs []utils.DockerJob
343344
if utils.Config.Realtime.Enabled {
344-
initJobs = append(initJobs, initRealtimeJob(host))
345+
jwks, err := utils.Config.Auth.ResolveJWKS(context.Background())
346+
if err != nil {
347+
return err
348+
}
349+
initJobs = append(initJobs, initRealtimeJob(host, jwks))
345350
}
346351
if utils.Config.Storage.Enabled {
347352
initJobs = append(initJobs, initStorageJob(host))

internal/start/start.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func run(ctx context.Context, fsys afero.Fs, excludedContainers []string, dbConf
146146
excluded[name] = true
147147
}
148148

149-
jwks, err := utils.Config.Auth.ResolveJWKS(ctx, fsys)
149+
jwks, err := utils.Config.Auth.ResolveJWKS(ctx)
150150
if err != nil {
151151
return err
152152
}

pkg/config/config.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"github.com/go-errors/errors"
2929
"github.com/go-viper/mapstructure/v2"
3030
"github.com/joho/godotenv"
31-
"github.com/spf13/afero"
3231
"github.com/spf13/viper"
3332
"github.com/supabase/cli/pkg/cast"
3433
"github.com/supabase/cli/pkg/fetcher"
@@ -1428,7 +1427,7 @@ type (
14281427
// ResolveJWKS creates the JWKS from the JWT secret and Third-Party Auth
14291428
// configs by resolving the JWKS via the OIDC discovery URL.
14301429
// It always returns a JWKS string, except when there's an error fetching.
1431-
func (a *auth) ResolveJWKS(ctx context.Context, fsys afero.Fs) (string, error) {
1430+
func (a *auth) ResolveJWKS(ctx context.Context) (string, error) {
14321431
var jwks remoteJWKS
14331432

14341433
if issuerURL := a.ThirdParty.IssuerURL(); issuerURL != "" {

0 commit comments

Comments
 (0)