aboutsummaryrefslogtreecommitdiffstats
path: root/internal/config/config.go
blob: 1acda1ee4ea30a64a8c4cddcd3c588287c1729cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package config

import (
	"os"

	"gopkg.in/yaml.v3"
)

type Config struct {
	Server struct {
		Host string `yaml:"host"`
		Port string `yaml:"port"`
	} `yaml:"server"`
	Database struct {
		ConnString string `yaml:"connString"`
	} `yaml:"database"`
	Conference struct {
		ScheduleURL string `yaml:"scheduleURL"`
	} `yaml:"conference"`
	Auth struct {
		EnableBasicAuth bool           `yaml:"enableBasicAuth"`
		AuthProviders   []AuthProvider `yaml:"authProviders"`
	}
	AcceptRegistrations bool   `yaml:"acceptRegistrations"`
	BaseURL             string `yaml:"baseURL"`
}

type AuthProvider struct {
	Identifier               string   `yaml:"identifier"`
	Name                     string   `yaml:"name"`
	ClientID                 string   `yaml:"clientID"`
	ClientSecret             string   `yaml:"clientSecret"`
	Endpoint                 string   `yaml:"endpoint"`
	LoginFilter              string   `yaml:"loginFilter"`
	LoginFilterAllowedValues []string `yaml:"loginFilterAllowedValues"`
	UserSyncFilter           string   `yaml:"userSyncFilter"`
}

func ReadConfig(configPath string, dst *Config) error {
	config, err := os.ReadFile(configPath)
	if err != nil {
		return err
	}

	if err := yaml.Unmarshal(config, dst); err != nil {
		return err
	}
	return nil
}