diff --git a/cmd/root.go b/cmd/root.go index fcb3f87..0ec6f12 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -28,6 +28,14 @@ var rootCmd = &cobra.Command{ parseErr := viper.Unmarshal(&config) HandleError(parseErr, "Failed to parse config") + // Secrets + log.Info().Msg("Parsing secrets") + + config.Secret = utils.GetSecret(config.Secret, config.SecretFile) + config.GithubClientSecret = utils.GetSecret(config.GithubClientSecret, config.GithubClientSecretFile) + config.GoogleClientSecret = utils.GetSecret(config.GoogleClientSecret, config.GoogleClientSecretFile) + config.GenericClientSecret = utils.GetSecret(config.GenericClientSecret, config.GenericClientSecretFile) + // Validate config log.Info().Msg("Validating config") validator := validator.New() @@ -46,14 +54,6 @@ var rootCmd = &cobra.Command{ log.Fatal().Err(usersErr).Msg("Failed to parse users") } - // Secrets - log.Info().Msg("Parsing secrets") - - config.Secret = utils.GetSecret(config.Secret, config.SecretFile) - config.GithubClientSecret = utils.GetSecret(config.GithubClientSecret, config.GithubClientSecretFile) - config.GoogleClientSecret = utils.GetSecret(config.GoogleClientSecret, config.GoogleClientSecretFile) - config.GenericClientSecret = utils.GetSecret(config.GenericClientSecret, config.GenericClientSecretFile) - // Create oauth whitelist oauthWhitelist := strings.Split(config.OAuthWhitelist, ",") log.Debug().Strs("oauth_whitelist", oauthWhitelist).Msg("Parsed OAuth whitelist") diff --git a/internal/types/types.go b/internal/types/types.go index a5f7584..bfd0782 100644 --- a/internal/types/types.go +++ b/internal/types/types.go @@ -19,9 +19,9 @@ type User struct { type Users []User type Config struct { - Port int `validate:"number" mapstructure:"port"` - Address string `mapstructure:"address, ip4_addr"` - Secret string `validate:"required,len=32" mapstructure:"secret"` + Port int `mapstructure:"port"` + Address string `validate:"ip4_addr" mapstructure:"address"` + Secret string `validate:"len=32" mapstructure:"secret"` SecretFile string `mapstructure:"secret-file"` AppURL string `validate:"required,url" mapstructure:"app-url"` Users string `mapstructure:"users"`