Skip to content

Commit

Permalink
load configuration from config file and verify config is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
joelrebel committed Mar 27, 2024
1 parent 18156cb commit ceb9321
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ func serve(ctx context.Context) {
"address", viper.GetString("listen"),
)

logger.Infow("oidc enabled", "oidc", viper.GetString("oidc"))

var authCfgs []ginjwt.AuthConfig
if viper.GetViper().GetBool("oidc.enabled") {
authCfgs, err = ginjwt.GetAuthConfigsFromFlags(viper.GetViper())
if err != nil {
logger.Fatal(err)
logger.Infow("OIDC enabled")

if len(config.AppConfig.APIServerJWTAuth) == 0 {
logger.Fatal("OIDC enabled without configuration")
}
} else {
logger.Infow("OIDC disabled")
}

hs := &httpsrv.Server{
Expand All @@ -118,7 +118,7 @@ func serve(ctx context.Context) {
Debug: config.AppConfig.Logging.Debug,
DB: db,
SecretsKeeper: keeper,
AuthConfigs: authCfgs,
AuthConfigs: config.AppConfig.APIServerJWTAuth,
}

// init event stream - for now, only when nats.url is specified
Expand Down
3 changes: 3 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package config

import (
"go.hollow.sh/toolbox/ginjwt"
"go.infratographer.com/x/crdbx"
"go.infratographer.com/x/loggingx"
"go.infratographer.com/x/otelx"
Expand All @@ -12,4 +13,6 @@ var AppConfig struct {
CRDB crdbx.Config
Logging loggingx.Config
Tracing otelx.Config
// APIServerJWTAuth sets the JWT verification configuration for the conditionorc API service.
APIServerJWTAuth []ginjwt.AuthConfig `mapstructure:"ginjwt_auth"`
}

0 comments on commit ceb9321

Please sign in to comment.