Skip to content

Commit

Permalink
fix(tenants): JWKS URL configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
TimVosch committed May 6, 2024
1 parent 4ef94c2 commit 61d4fb9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion services/tenants/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var (
HTTP_WEBUI_ADDR = env.Could("HTTP_WEBUI_ADDR", ":3001")
HTTP_WEBUI_BASE = env.Could("HTTP_WEBUI_BASE", "http://localhost:3000/auth")
KRATOS_ADMIN_API = env.Could("KRATOS_ADMIN_API", "http://kratos:4434/")
AUTH_JWKS_URL = env.Could("AUTH_JWKS_URL", "http://oathkeeper:4456/.well-known/jwks.json")
SB_API = env.Must("SB_API")
DB_DSN = env.Must("DB_DSN")
)
Expand Down Expand Up @@ -129,7 +130,14 @@ func runWebUI(errC chan<- error, db *sqlx.DB) (func(context.Context), error) {
apiKeyStore := tenantsinfra.NewAPIKeyStorePSQL(db)
apiKeySvc := apikeys.NewAPIKeyService(tenantStore, apiKeyStore)

ui, err := webui.New(HTTP_WEBUI_BASE, SB_API, tenantSvc, apiKeySvc, userPreferences)
ui, err := webui.New(
HTTP_WEBUI_BASE,
AUTH_JWKS_URL,
SB_API,
tenantSvc,
apiKeySvc,
userPreferences,
)
if err != nil {
errC <- err
return noopCleanup, nil
Expand Down
3 changes: 2 additions & 1 deletion services/tenants/transports/webui/webui.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type WebUI struct {

func New(
baseURLString,
jwksURL,
sensorbucketAPIEndpoint string,
tenantsService *tenants.TenantService,
apiKeys *apikeys.Service,
Expand All @@ -51,7 +52,7 @@ func New(
client := api.NewAPIClient(cfg)

ui.router.Use(middleware.Logger)
jwks := auth.NewJWKSHttpClient("http://oathkeeper:4456/.well-known/jwks.json")
jwks := auth.NewJWKSHttpClient(jwksURL)
ui.router.Use(auth.Authenticate(jwks))
// Middleware to pass on basic auth to the client api
// TODO: This also exists in dashboard/main.go, perhaps make it a package?
Expand Down

0 comments on commit 61d4fb9

Please sign in to comment.