mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-11-02 11:57:04 +08:00
improvement (security): only allow preconfigured methods on preconfigured servers
This commit is contained in:
@ -7,6 +7,23 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func NewBackend(ctx *App, conn map[string]string) (IBackend, error) {
|
func NewBackend(ctx *App, conn map[string]string) (IBackend, error) {
|
||||||
|
isAllowed := false
|
||||||
|
for i := range ctx.Config.Connections {
|
||||||
|
if ctx.Config.Connections[i].Type == conn["type"] {
|
||||||
|
if ctx.Config.Connections[i].Hostname == nil {
|
||||||
|
isAllowed = true
|
||||||
|
break;
|
||||||
|
}else if *ctx.Config.Connections[i].Hostname == conn["hostname"] {
|
||||||
|
isAllowed = true
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if isAllowed == false {
|
||||||
|
return backend.NewNothing(conn, ctx)
|
||||||
|
}
|
||||||
|
|
||||||
switch conn["type"] {
|
switch conn["type"] {
|
||||||
case "webdav":
|
case "webdav":
|
||||||
return backend.NewWebDav(conn, ctx)
|
return backend.NewWebDav(conn, ctx)
|
||||||
|
|||||||
Reference in New Issue
Block a user