initial commit

This commit is contained in:
ston1th 2022-07-10 01:10:31 +02:00
commit f48fa210bb
49 changed files with 4058 additions and 0 deletions

36
pkg/core/config.go Normal file
View file

@ -0,0 +1,36 @@
// 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"`
}

19
pkg/core/types.go Normal file
View file

@ -0,0 +1,19 @@
// Copyright (C) 2022 Marius Schellenberger
package core
type User struct {
Username string
Email string
Password string
Created string
Secret string
Admin bool
Locked int
}
type Users []*User
func (u Users) Len() int { return len(u) }
func (u Users) Swap(i, j int) { u[i], u[j] = u[j], u[i] }
func (u Users) Less(i, j int) bool { return u[i].Username < u[j].Username }