mirror of
https://github.com/hacdias/webdav.git
synced 2026-09-23 19:51:53 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac0e137b1d | ||
|
|
65fa394f98 |
+8
-2
@@ -19,7 +19,14 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
config string
|
config string
|
||||||
defaultConfigs = []string{"config.json", "config.yaml", "config.yml"}
|
defaultConfigs = []string{
|
||||||
|
"config.json",
|
||||||
|
"config.yaml",
|
||||||
|
"config.yml",
|
||||||
|
"/etc/webdav/config.json",
|
||||||
|
"/etc/webdav/config.yaml",
|
||||||
|
"/etc/webdav/config.yml",
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -161,7 +168,6 @@ func parseConfig() *cfg {
|
|||||||
port: data.Port,
|
port: data.Port,
|
||||||
auth: map[string]string{},
|
auth: map[string]string{},
|
||||||
webdav: &webdav.Config{
|
webdav: &webdav.Config{
|
||||||
BaseURL: "",
|
|
||||||
User: &webdav.User{
|
User: &webdav.User{
|
||||||
Scope: data.Scope,
|
Scope: data.Scope,
|
||||||
Modify: data.Modify,
|
Modify: data.Modify,
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ import (
|
|||||||
// Config is the configuration of a WebDAV instance.
|
// Config is the configuration of a WebDAV instance.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
*User
|
*User
|
||||||
BaseURL string
|
Users map[string]*User
|
||||||
Users map[string]*User
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServeHTTP determines if the request is for this plugin, and if all prerequisites are met.
|
// ServeHTTP determines if the request is for this plugin, and if all prerequisites are met.
|
||||||
@@ -28,9 +27,6 @@ func (c *Config) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the BaseURL from the url path.
|
|
||||||
r.URL.Path = strings.TrimPrefix(r.URL.Path, c.BaseURL)
|
|
||||||
|
|
||||||
// Checks for user permissions relatively to this PATH.
|
// Checks for user permissions relatively to this PATH.
|
||||||
if !u.Allowed(r.URL.Path) {
|
if !u.Allowed(r.URL.Path) {
|
||||||
w.WriteHeader(http.StatusForbidden)
|
w.WriteHeader(http.StatusForbidden)
|
||||||
|
|||||||
Reference in New Issue
Block a user