mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-24 09:13:11 +01:00
improvement (security): only allow preconfigured methods on preconfigured servers
This commit is contained in:
parent
d0b44bb388
commit
c649dc4854
1 changed files with 17 additions and 0 deletions
|
|
@ -7,6 +7,23 @@ import (
|
|||
)
|
||||
|
||||
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"] {
|
||||
case "webdav":
|
||||
return backend.NewWebDav(conn, ctx)
|
||||
|
|
|
|||
Loading…
Reference in a new issue