2019-01-05 22:44:33 +00:00
|
|
|
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"
|
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
|
|
|
|
}
|
2023-09-01 23:30:51 +00:00
|
|
|
fmt.Println("auth.go", t)
|
2019-01-05 22:44:33 +00:00
|
|
|
|
|
|
|
return auther, get(s.db, "auther", auther)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s authBackend) Save(a auth.Auther) error {
|
|
|
|
return save(s.db, "auther", a)
|
|
|
|
}
|