add a simple auth function

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2026-04-25 20:11:46 +02:00
commit 87fe581353
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
10 changed files with 206 additions and 8 deletions

View file

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

View file

@ -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 {