84 lines
2.3 KiB
Go
84 lines
2.3 KiB
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
type Config struct {
|
|
ShardID string `yaml:"shard_id"`
|
|
Listen struct {
|
|
HTTP string `yaml:"http"`
|
|
HTTPS string `yaml:"https"`
|
|
WS string `yaml:"ws"`
|
|
} `yaml:"listen"`
|
|
TLS struct {
|
|
Enable bool `yaml:"enable"`
|
|
CertFile string `yaml:"cert_file"`
|
|
KeyFile string `yaml:"key_file"`
|
|
} `yaml:"tls"`
|
|
Federation struct {
|
|
MTLSEnable bool `yaml:"mtls_enable"`
|
|
Listen string `yaml:"listen"`
|
|
CertFile string `yaml:"cert_file"`
|
|
KeyFile string `yaml:"key_file"`
|
|
ClientCAFile string `yaml:"client_ca_file"`
|
|
} `yaml:"federation"`
|
|
Storage struct {
|
|
Backend string `yaml:"backend"`
|
|
Path string `yaml:"path"`
|
|
MaxObjectKB int `yaml:"max_object_kb"`
|
|
} `yaml:"storage"`
|
|
Security struct {
|
|
ZeroTrust bool `yaml:"zero_trust"`
|
|
RequireMTLSForFederation bool `yaml:"require_mtls_for_federation"`
|
|
AcceptClientSignedTokens bool `yaml:"accept_client_signed_tokens"`
|
|
LogLevel string `yaml:"log_level"`
|
|
} `yaml:"security"`
|
|
Privacy struct {
|
|
RetainIP string `yaml:"retain_ip"`
|
|
RetainUserAgent string `yaml:"retain_user_agent"`
|
|
RetainTimestamps string `yaml:"retain_timestamps"`
|
|
} `yaml:"privacy"`
|
|
Auth struct {
|
|
SigningSecret string `yaml:"signing_secret"`
|
|
SSO struct {
|
|
Discord struct {
|
|
Enabled bool `yaml:"enabled"`
|
|
ClientID string `yaml:"client_id"`
|
|
ClientSecret string `yaml:"client_secret"`
|
|
RedirectURI string `yaml:"redirect_uri"`
|
|
} `yaml:"discord"`
|
|
Google struct {
|
|
Enabled bool `yaml:"enabled"`
|
|
ClientID string `yaml:"client_id"`
|
|
ClientSecret string `yaml:"client_secret"`
|
|
RedirectURI string `yaml:"redirect_uri"`
|
|
} `yaml:"google"`
|
|
Facebook struct {
|
|
Enabled bool `yaml:"enabled"`
|
|
ClientID string `yaml:"client_id"`
|
|
ClientSecret string `yaml:"client_secret"`
|
|
RedirectURI string `yaml:"redirect_uri"`
|
|
} `yaml:"facebook"`
|
|
} `yaml:"sso"`
|
|
TwoFactor struct {
|
|
WebAuthnEnabled bool `yaml:"webauthn_enabled"`
|
|
TOTPEnabled bool `yaml:"totp_enabled"`
|
|
} `yaml:"two_factor"`
|
|
} `yaml:"auth"`
|
|
}
|
|
|
|
func Load(path string) (*Config, error) {
|
|
b, err := os.ReadFile(path)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var c Config
|
|
if err := yaml.Unmarshal(b, &c); err != nil {
|
|
return nil, err
|
|
}
|
|
return &c, nil
|
|
}
|