filebrowser/backend/storage/bolt/auth.go

33 lines
658 B
Go
Raw Normal View History

package bolt
import (
2023-09-01 22:35:54 +00:00
"github.com/asdine/storm/v3"
2024-12-17 00:01:55 +00:00
"github.com/gtsteffaniak/filebrowser/backend/auth"
"github.com/gtsteffaniak/filebrowser/backend/errors"
)
type authBackend struct {
db *storm.DB
}
2023-08-05 12:32:43 +00:00
func (s authBackend) Get(t string) (auth.Auther, error) {
var auther auth.Auther
switch t {
2023-09-01 22:35:54 +00:00
case "password":
auther = &auth.JSONAuth{}
2023-09-01 22:35:54 +00:00
case "proxy":
auther = &auth.ProxyAuth{}
2023-09-01 22:35:54 +00:00
case "hook":
2021-09-13 13:47:06 +00:00
auther = &auth.HookAuth{}
2023-09-01 22:35:54 +00:00
case "noauth":
auther = &auth.NoAuth{}
default:
return nil, errors.ErrInvalidAuthMethod
}
return auther, get(s.db, "auther", auther)
}
func (s authBackend) Save(a auth.Auther) error {
2024-10-07 22:44:53 +00:00
return Save(s.db, "auther", a)
}