diff --git a/caddy/filemanager/filemanager.go b/caddy/filemanager/filemanager.go index 948de73d..75cbb128 100644 --- a/caddy/filemanager/filemanager.go +++ b/caddy/filemanager/filemanager.go @@ -10,6 +10,7 @@ import ( "net/http" "os" "path/filepath" + "strconv" "strings" . "github.com/hacdias/filemanager" @@ -73,6 +74,7 @@ func parse(c *caddy.Controller) ([]*config, error) { baseURL := "/" baseScope := "." database := "" + noAuth := false // Get the baseURL and baseScope args := c.RemainingArgs() @@ -93,6 +95,17 @@ func parse(c *caddy.Controller) ([]*config, error) { } database = c.Val() + case "no_auth": + if !c.NextArg() { + noAuth = true + continue + } + + var err error + noAuth, err = strconv.ParseBool(c.Val()) + if err != nil { + return nil, err + } } } @@ -143,6 +156,7 @@ func parse(c *caddy.Controller) ([]*config, error) { return nil, err } + fm.NoAuth = noAuth m := &config{FileManager: fm} m.SetBaseURL(baseURL) m.SetPrefixURL(strings.TrimSuffix(caddyConf.Addr.Path, "/")) diff --git a/caddy/hugo/hugo.go b/caddy/hugo/hugo.go index 7da39d58..871d0fb0 100644 --- a/caddy/hugo/hugo.go +++ b/caddy/hugo/hugo.go @@ -7,6 +7,7 @@ import ( "net/http" "os" "path/filepath" + "strconv" "strings" "github.com/hacdias/filemanager" @@ -42,6 +43,7 @@ func parse(c *caddy.Controller) ([]*filemanager.FileManager, error) { directory := "." admin := "/admin" database := "" + noAuth := false // Get the baseURL and baseScope args := c.RemainingArgs() @@ -62,6 +64,17 @@ func parse(c *caddy.Controller) ([]*filemanager.FileManager, error) { } database = c.Val() + case "no_auth": + if !c.NextArg() { + noAuth = true + continue + } + + var err error + noAuth, err = strconv.ParseBool(c.Val()) + if err != nil { + return nil, err + } } } @@ -132,6 +145,7 @@ func parse(c *caddy.Controller) ([]*filemanager.FileManager, error) { return nil, err } + m.NoAuth = noAuth m.SetBaseURL(admin) m.SetPrefixURL(strings.TrimSuffix(caddyConf.Addr.Path, "/")) configs = append(configs, m)