2019-01-05 22:44:33 +00:00
|
|
|
package auth
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/filebrowser/filebrowser/v2/settings"
|
|
|
|
"github.com/filebrowser/filebrowser/v2/users"
|
|
|
|
)
|
|
|
|
|
|
|
|
// StorageBackend is a storage backend for auth storage.
|
|
|
|
type StorageBackend interface {
|
|
|
|
Get(settings.AuthMethod) (Auther, error)
|
|
|
|
Save(Auther) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// Storage is a auth storage.
|
|
|
|
type Storage struct {
|
|
|
|
back StorageBackend
|
|
|
|
users *users.Storage
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewStorage creates a auth storage from a backend.
|
2020-05-31 23:12:36 +00:00
|
|
|
func NewStorage(back StorageBackend, userStore *users.Storage) *Storage {
|
|
|
|
return &Storage{back: back, users: userStore}
|
2019-01-05 22:44:33 +00:00
|
|
|
}
|
|
|
|
|
2019-01-06 13:01:42 +00:00
|
|
|
// Get wraps a StorageBackend.Get.
|
2019-01-05 22:44:33 +00:00
|
|
|
func (s *Storage) Get(t settings.AuthMethod) (Auther, error) {
|
2019-01-06 13:01:42 +00:00
|
|
|
return s.back.Get(t)
|
2019-01-05 22:44:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Save wraps a StorageBackend.Save.
|
|
|
|
func (s *Storage) Save(a Auther) error {
|
|
|
|
return s.back.Save(a)
|
|
|
|
}
|