2019-01-05 22:44:33 +00:00
|
|
|
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"
|
2019-01-05 22:44:33 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type authBackend struct {
|
|
|
|
db *storm.DB
|
|
|
|
}
|
|
|
|
|
2023-08-05 12:32:43 +00:00
|
|
|
func (s authBackend) Get(t string) (auth.Auther, error) {
|
2019-01-05 22:44:33 +00:00
|
|
|
var auther auth.Auther
|
|
|
|
switch t {
|
2023-09-01 22:35:54 +00:00
|
|
|
case "password":
|
2019-01-05 22:44:33 +00:00
|
|
|
auther = &auth.JSONAuth{}
|
2023-09-01 22:35:54 +00:00
|
|
|
case "proxy":
|
2019-01-05 22:44:33 +00:00
|
|
|
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":
|
2019-01-05 22:44:33 +00:00
|
|
|
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)
|
2019-01-05 22:44:33 +00:00
|
|
|
}
|