2019-01-05 22:44:33 +00:00
|
|
|
package bolt
|
|
|
|
|
|
|
|
import (
|
2022-05-03 20:48:45 +00:00
|
|
|
"github.com/asdine/storm/v3"
|
2020-05-31 23:12:36 +00:00
|
|
|
|
2019-01-05 22:44:33 +00:00
|
|
|
"github.com/filebrowser/filebrowser/v2/auth"
|
|
|
|
"github.com/filebrowser/filebrowser/v2/errors"
|
|
|
|
"github.com/filebrowser/filebrowser/v2/settings"
|
|
|
|
)
|
|
|
|
|
|
|
|
type authBackend struct {
|
|
|
|
db *storm.DB
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s authBackend) Get(t settings.AuthMethod) (auth.Auther, error) {
|
|
|
|
var auther auth.Auther
|
|
|
|
|
|
|
|
switch t {
|
|
|
|
case auth.MethodJSONAuth:
|
|
|
|
auther = &auth.JSONAuth{}
|
|
|
|
case auth.MethodProxyAuth:
|
|
|
|
auther = &auth.ProxyAuth{}
|
2021-09-13 13:47:06 +00:00
|
|
|
case auth.MethodHookAuth:
|
|
|
|
auther = &auth.HookAuth{}
|
2019-01-05 22:44:33 +00:00
|
|
|
case auth.MethodNoAuth:
|
|
|
|
auther = &auth.NoAuth{}
|
|
|
|
default:
|
|
|
|
return nil, errors.ErrInvalidAuthMethod
|
|
|
|
}
|
|
|
|
|
|
|
|
return auther, get(s.db, "auther", auther)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s authBackend) Save(a auth.Auther) error {
|
|
|
|
return save(s.db, "auther", a)
|
|
|
|
}
|