filebrowser/backend/storage/bolt/auth.go

37 lines
678 B
Go
Raw Normal View History

package bolt
import (
2023-09-01 22:35:54 +00:00
"fmt"
2020-05-31 23:12:36 +00:00
2023-09-01 22:35:54 +00:00
"github.com/asdine/storm/v3"
2023-06-15 01:08:09 +00:00
"github.com/gtsteffaniak/filebrowser/auth"
"github.com/gtsteffaniak/filebrowser/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
}
2023-09-01 23:30:51 +00:00
fmt.Println("auth.go", t)
return auther, get(s.db, "auther", auther)
}
func (s authBackend) Save(a auth.Auther) error {
return save(s.db, "auther", a)
}