mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-10-29 21:25:43 +00:00
Compare commits
3 Commits
v2.0.0-alp
...
v2.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c54267f50d | ||
|
|
4de12ce5c1 | ||
|
|
0cf0aafc14 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -11,4 +11,5 @@ docker-compose.test.yml
|
|||||||
users.txt
|
users.txt
|
||||||
|
|
||||||
# secret test file
|
# secret test file
|
||||||
secret.txt
|
secret.txt
|
||||||
|
secret_oauth.txt
|
||||||
16
cmd/root.go
16
cmd/root.go
@@ -28,6 +28,14 @@ var rootCmd = &cobra.Command{
|
|||||||
parseErr := viper.Unmarshal(&config)
|
parseErr := viper.Unmarshal(&config)
|
||||||
HandleError(parseErr, "Failed to parse 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
|
// Validate config
|
||||||
log.Info().Msg("Validating config")
|
log.Info().Msg("Validating config")
|
||||||
validator := validator.New()
|
validator := validator.New()
|
||||||
@@ -46,14 +54,6 @@ var rootCmd = &cobra.Command{
|
|||||||
log.Fatal().Err(usersErr).Msg("Failed to parse users")
|
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
|
// Create oauth whitelist
|
||||||
oauthWhitelist := strings.Split(config.OAuthWhitelist, ",")
|
oauthWhitelist := strings.Split(config.OAuthWhitelist, ",")
|
||||||
log.Debug().Strs("oauth_whitelist", oauthWhitelist).Msg("Parsed OAuth whitelist")
|
log.Debug().Strs("oauth_whitelist", oauthWhitelist).Msg("Parsed OAuth whitelist")
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
v2.0.0
|
v2.0.1
|
||||||
@@ -73,7 +73,6 @@ func (hooks *Hooks) UseUserContext(c *gin.Context) types.UserContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Error().Msg("Provider does not exist")
|
|
||||||
return types.UserContext{
|
return types.UserContext{
|
||||||
Username: "",
|
Username: "",
|
||||||
IsLoggedIn: false,
|
IsLoggedIn: false,
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ type User struct {
|
|||||||
type Users []User
|
type Users []User
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Port int `validate:"number" mapstructure:"port"`
|
Port int `mapstructure:"port"`
|
||||||
Address string `mapstructure:"address, ip4_addr"`
|
Address string `validate:"ip4_addr" mapstructure:"address"`
|
||||||
Secret string `validate:"required,len=32" mapstructure:"secret"`
|
Secret string `validate:"len=32" mapstructure:"secret"`
|
||||||
SecretFile string `mapstructure:"secret-file"`
|
SecretFile string `mapstructure:"secret-file"`
|
||||||
AppURL string `validate:"required,url" mapstructure:"app-url"`
|
AppURL string `validate:"required,url" mapstructure:"app-url"`
|
||||||
Users string `mapstructure:"users"`
|
Users string `mapstructure:"users"`
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ func ParseFileToLine(content string) string {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
users = append(users, line)
|
users = append(users, strings.TrimSpace(line))
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.Join(users, ",")
|
return strings.Join(users, ",")
|
||||||
@@ -122,7 +122,9 @@ func GetUsers(env string, file string) (types.Users, error) {
|
|||||||
|
|
||||||
if fileErr == nil {
|
if fileErr == nil {
|
||||||
log.Debug().Str("users", ParseFileToLine(fileContents)).Msg("Using users from file")
|
log.Debug().Str("users", ParseFileToLine(fileContents)).Msg("Using users from file")
|
||||||
users += ","
|
if users != "" {
|
||||||
|
users += ","
|
||||||
|
}
|
||||||
users += ParseFileToLine(fileContents)
|
users += ParseFileToLine(fileContents)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user