This repository has been archived on 2025-08-23. You can view files and clone it, but cannot push or open issues or pull requests.
Files
GreenCoast/internal/config/config.go
Dani e2651456da Fixed up the .gitignore
More push to move towards a deployment stage
2025-08-21 20:57:23 -04:00

90 lines
2.5 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"`
UI struct {
Enable bool `yaml:"enable"`
Path string `yaml:"path"`
BaseURL string `yaml:"base_url"`
FrontendHTTP string `yaml:"frontend_http"` // NEW
} `yaml:"ui"`
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
}