mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
fix web dav URL
This commit is contained in:
parent
41e7894425
commit
eeeb1ce0fd
@ -113,7 +113,7 @@
|
||||
|
||||
<!-- SCRIPTS -->
|
||||
<!-- User Data and Permissions; WebDavURL -->
|
||||
<script>var user = JSON.parse('{{ Marshal .User }}'), webdavURL = "{{.Config.WebDavURL}}", baseURL = "{{.Config.BaseURL}}";</script>
|
||||
<script>var user = JSON.parse('{{ Marshal .User }}'), webdavURL = "{{.Config.FullWebDavURL}}", baseURL = "{{.Config.AbsoluteURL}}";</script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.3/ace.js"></script>
|
||||
<script src="{{ .Config.AbsoluteURL }}/_filemanagerinternal/js/form2js.js"></script>
|
||||
<script src="{{ .Config.AbsoluteURL }}/_filemanagerinternal/js/application.js"></script>
|
||||
|
@ -26,6 +26,10 @@ type Config struct {
|
||||
CurrentUser *User
|
||||
}
|
||||
|
||||
func (c Config) FullWebDavURL() string {
|
||||
return c.AbsoluteURL + c.WebDavURL
|
||||
}
|
||||
|
||||
// Rule is a dissalow/allow rule
|
||||
type Rule struct {
|
||||
Regex bool
|
||||
@ -82,7 +86,7 @@ func Parse(c *caddy.Controller) ([]Config, error) {
|
||||
cfg.BaseURL = strings.TrimPrefix(cfg.BaseURL, "/")
|
||||
cfg.BaseURL = strings.TrimSuffix(cfg.BaseURL, "/")
|
||||
cfg.BaseURL = "/" + cfg.BaseURL
|
||||
cfg.WebDavURL = cfg.BaseURL + "webdav"
|
||||
cfg.WebDavURL = "webdav"
|
||||
|
||||
if cfg.BaseURL == "/" {
|
||||
cfg.BaseURL = ""
|
||||
@ -230,17 +234,18 @@ func Parse(c *caddy.Controller) ([]Config, error) {
|
||||
}
|
||||
}
|
||||
|
||||
caddyConf := httpserver.GetConfig(c)
|
||||
cfg.AbsoluteURL = strings.TrimSuffix(caddyConf.Addr.Path, "/") + "/" + cfg.BaseURL
|
||||
cfg.AbsoluteURL = strings.Replace(cfg.AbsoluteURL, "//", "/", -1)
|
||||
cfg.AbsoluteURL = strings.TrimSuffix(cfg.AbsoluteURL, "/")
|
||||
cfg.AddrPath = strings.TrimSuffix(caddyConf.Addr.Path, "/")
|
||||
cfg.WebDavURL = "/" + strings.TrimPrefix(cfg.WebDavURL, "/")
|
||||
cfg.Handler = &webdav.Handler{
|
||||
Prefix: cfg.WebDavURL,
|
||||
FileSystem: cfg.FileSystem,
|
||||
LockSystem: webdav.NewMemLS(),
|
||||
}
|
||||
|
||||
caddyConf := httpserver.GetConfig(c)
|
||||
cfg.AbsoluteURL = strings.TrimSuffix(caddyConf.Addr.Path, "/") + "/" + cfg.BaseURL
|
||||
cfg.AbsoluteURL = strings.Replace(cfg.AbsoluteURL, "//", "/", -1)
|
||||
cfg.AbsoluteURL = strings.TrimSuffix(cfg.AbsoluteURL, "/")
|
||||
cfg.AddrPath = strings.TrimSuffix(caddyConf.Addr.Path, "/")
|
||||
if err := appendConfig(cfg); err != nil {
|
||||
return configs, err
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ func (f FileManager) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, err
|
||||
}
|
||||
|
||||
// Checks if the request URL is for the WebDav server
|
||||
if strings.HasPrefix(r.URL.Path, c.WebDavURL) {
|
||||
if httpserver.Path(r.URL.Path).Matches(c.WebDavURL) {
|
||||
// Checks for user permissions relatively to this PATH
|
||||
if !user.Allowed(strings.TrimPrefix(r.URL.Path, c.WebDavURL)) {
|
||||
return http.StatusForbidden, nil
|
||||
|
Loading…
Reference in New Issue
Block a user