This commit is contained in:
Daniel Ponte 2022-11-13 09:05:52 -05:00
parent 3ab5b5b78a
commit 3981025fa4
2 changed files with 20 additions and 20 deletions

View file

@ -66,11 +66,11 @@ func (ss *SessionStore) verify(tr *TokenRequest, r *http.Request) (provider.Prov
} }
type Credential struct { type Credential struct {
ID CredID `json:"id"` ID CredID `json:"id"`
UserID UserID `json:"user_id"` UserID UserID `json:"user_id"`
AuthProviderType string `json:"auth_provider_type"` AuthProviderType string `json:"auth_provider_type"`
AuthProviderID *string `json:"auth_provider_id"` AuthProviderID *string `json:"auth_provider_id"`
DataRaw *json.RawMessage `json:"data,omitempty"` DataRaw *json.RawMessage `json:"data,omitempty"`
user provider.ProviderUser `json:"-"` user provider.ProviderUser `json:"-"`
} }

View file

@ -19,7 +19,7 @@ var (
) )
const ( const (
SecretMode os.FileMode = 0600 SecretMode os.FileMode = 0600
DefaultMode os.FileMode = 0644 DefaultMode os.FileMode = 0644
) )
@ -27,10 +27,10 @@ type Data interface {
} }
type item struct { type item struct {
Version int `json:"version"` Version int `json:"version"`
MinorVersion *int `json:"minor_version,omitempty"` MinorVersion *int `json:"minor_version,omitempty"`
Key string `json:"key"` Key string `json:"key"`
Data interface{} `json:"data"` Data interface{} `json:"data"`
fmode os.FileMode fmode os.FileMode
dirty bool dirty bool
@ -44,11 +44,11 @@ type Item interface {
ItemKey() string ItemKey() string
} }
func (i *item) Dirty() { i.dirty = true } func (i *item) Dirty() { i.dirty = true }
func (i *item) IsDirty() bool { return i.dirty } func (i *item) IsDirty() bool { return i.dirty }
func (i *item) GetData() interface{} { return i.Data } func (i *item) GetData() interface{} { return i.Data }
func (i *item) SetData(d interface{}) { i.Data = d; i.Dirty() } func (i *item) SetData(d interface{}) { i.Data = d; i.Dirty() }
func (i *item) ItemKey() string { return i.Key } func (i *item) ItemKey() string { return i.Key }
func (it *item) mode() os.FileMode { func (it *item) mode() os.FileMode {
if it.fmode != 0 { if it.fmode != 0 {
@ -61,7 +61,7 @@ func (it *item) mode() os.FileMode {
type fsStore struct { type fsStore struct {
fs.FS fs.FS
storeRoot string storeRoot string
s map[string]*item s map[string]*item
} }
type Store interface { type Store interface {
@ -147,10 +147,10 @@ func (s *fsStore) Put(key string, version, minorVersion int, secretMode bool, da
} }
it := &item{ it := &item{
Version: version, Version: version,
MinorVersion: mv, MinorVersion: mv,
Key: key, Key: key,
Data: data, Data: data,
fmode: mode, fmode: mode,
dirty: true, dirty: true,
@ -197,8 +197,8 @@ func OpenFileStore(configRoot string) (*fsStore, error) {
stor := os.DirFS(storeRoot) stor := os.DirFS(storeRoot)
return &fsStore{ return &fsStore{
FS: stor, FS: stor,
storeRoot: storeRoot, storeRoot: storeRoot,
s: make(map[string]*item), s: make(map[string]*item),
}, nil }, nil
} }