add a simple auth function
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
e1aff8d16b
commit
87fe581353
10 changed files with 206 additions and 8 deletions
|
|
@ -11,6 +11,7 @@ type Config struct {
|
|||
DataDir string `mapstructure:"data_dir"`
|
||||
Sync SyncConfig `mapstructure:"sync"`
|
||||
Log LogConfig `mapstructure:"log"`
|
||||
Auth AuthConfig `mapstructure:"auth"`
|
||||
}
|
||||
|
||||
type ServerConfig struct {
|
||||
|
|
@ -31,6 +32,10 @@ type LogConfig struct {
|
|||
Format string `mapstructure:"format"`
|
||||
}
|
||||
|
||||
type AuthConfig struct {
|
||||
LocalhostPrivileged bool `mapstructure:"localhost_privileged"`
|
||||
}
|
||||
|
||||
func (l LogConfig) SlogLevel() slog.Level {
|
||||
switch l.Level {
|
||||
case "debug":
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ func Load(cfgFile string) (*Config, error) {
|
|||
viper.SetDefault("sync.interval", "1h")
|
||||
viper.SetDefault("log.level", "info")
|
||||
viper.SetDefault("log.format", "text")
|
||||
viper.SetDefault("auth.localhost_privileged", true)
|
||||
|
||||
if err := viper.ReadInConfig(); err != nil {
|
||||
if _, ok := err.(viper.ConfigFileNotFoundError); !ok {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue