36 lines
734 B
Go
36 lines
734 B
Go
// Copyright (C) 2022 Marius Schellenberger
|
|
|
|
package core
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
)
|
|
|
|
const (
|
|
defIssuer = "GoAcc"
|
|
)
|
|
|
|
func LoadConfig(file string) (c *Config, err error) {
|
|
f, err := os.Open(file)
|
|
if err != nil {
|
|
return
|
|
}
|
|
c = new(Config)
|
|
err = json.NewDecoder(f).Decode(c)
|
|
if c.Issuer == "" {
|
|
c.Issuer = defIssuer
|
|
}
|
|
return
|
|
}
|
|
|
|
type Config struct {
|
|
DataDir string `json:"data_dir,omitempty"`
|
|
Listen string `json:"listen,omitempty"`
|
|
Secret string `json:"secret,omitempty"`
|
|
HydraAdminURL string `json:"hydra_admin_url"`
|
|
Issuer string `json:"issuer"`
|
|
Version string `json:"-"`
|
|
Admin bool `json:"admin,omitempty"`
|
|
SecureCookie bool `json:"secure_cookie,omitempty"`
|
|
}
|