Compare commits

...

3 Commits

Author SHA1 Message Date
Stavros
c54267f50d fix: parse users correctly 2025-01-26 22:40:55 +02:00
Stavros
4de12ce5c1 fix: no need to log that the provider is empty 2025-01-26 21:36:41 +02:00
Stavros
0cf0aafc14 fix: configure secrets before config validation 2025-01-26 21:13:26 +02:00
6 changed files with 18 additions and 16 deletions

3
.gitignore vendored
View File

@@ -11,4 +11,5 @@ docker-compose.test.yml
users.txt
# secret test file
secret.txt
secret.txt
secret_oauth.txt

View File

@@ -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")

View File

@@ -1 +1 @@
v2.0.0
v2.0.1

View File

@@ -73,7 +73,6 @@ func (hooks *Hooks) UseUserContext(c *gin.Context) types.UserContext {
}
}
log.Error().Msg("Provider does not exist")
return types.UserContext{
Username: "",
IsLoggedIn: false,

View File

@@ -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"`

View File

@@ -77,7 +77,7 @@ func ParseFileToLine(content string) string {
continue
}
users = append(users, line)
users = append(users, strings.TrimSpace(line))
}
return strings.Join(users, ",")
@@ -122,7 +122,9 @@ func GetUsers(env string, file string) (types.Users, error) {
if fileErr == nil {
log.Debug().Str("users", ParseFileToLine(fileContents)).Msg("Using users from file")
users += ","
if users != "" {
users += ","
}
users += ParseFileToLine(fileContents)
}
}