Files
user-manager-api/app/common/config.go
Arthur Lu f17ae26506 implement pool-group and group-user ownership routes,
fix issue with config var scoping,
fix missing return in early exit conditions
2026-03-26 19:35:55 +00:00

49 lines
1.0 KiB
Go

package app
import (
"encoding/json"
"os"
)
type LDAPConfig struct {
LdapURL string `json:"ldapURL"`
StartTLS bool `json:"startTLS"`
BaseDN string `json:"baseDN"`
}
type PVEConfig struct {
URL string `json:"url"`
PAASClientRole string `json:"paas-client-role"`
}
type RealmConfig struct {
Handler string `json:"handler"`
}
type Config struct {
ListenPort int `json:"listenPort"`
SessionCookieName string `json:"sessionCookieName"`
SessionCookie struct {
Path string `json:"path"`
HttpOnly bool `json:"httpOnly"`
Secure bool `json:"secure"`
MaxAge int `json:"maxAge"`
}
LDAP LDAPConfig `json:"ldap"`
PVE PVEConfig `json:"pve"`
Realms map[string]RealmConfig `json:"realms"`
}
func GetConfig(configPath string) (Config, error) {
content, err := os.ReadFile(configPath)
if err != nil {
return Config{}, err
}
var config Config
err = json.Unmarshal(content, &config)
if err != nil {
return Config{}, err
}
return config, nil
}