Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load configuration from config file and verify config is defined #34

Merged
merged 2 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"`
}
Loading