feat(example): Allow configuring some parameters with env variables
This commit is contained in:
parent
5ae555e191
commit
73d827bf88
6 changed files with 262 additions and 21 deletions
|
@ -2,6 +2,8 @@ package storage
|
|||
|
||||
import (
|
||||
"crypto/rsa"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/text/language"
|
||||
|
@ -35,6 +37,18 @@ type userStore struct {
|
|||
users map[string]*User
|
||||
}
|
||||
|
||||
func StoreFromFile(path string) (UserStore, error) {
|
||||
users := map[string]*User{}
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := json.Unmarshal(data, &users); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return userStore{users}, nil
|
||||
}
|
||||
|
||||
func NewUserStore(issuer string) UserStore {
|
||||
hostname := strings.Split(strings.Split(issuer, "://")[1], ":")[0]
|
||||
return userStore{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue