feat(example): Allow configuring some parameters with env variables (#663)

Co-authored-by: Andrey Rusakov <andrey.rusakov@camptocamp.com>
This commit is contained in:
lanseg 2024-10-21 20:59:28 +02:00 committed by GitHub
parent 9f7cbb0dbf
commit 24869d2811
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 262 additions and 21 deletions

View file

@ -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{