From 8c66f0c585fc26fb043b01da165b66b5684c4094 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sun, 12 May 2019 20:25:36 +0100 Subject: [PATCH] feat: check basic auth user anyways License: MIT Signed-off-by: Henrique Dias --- webdav/webdav.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/webdav/webdav.go b/webdav/webdav.go index a01a6f7..84455ef 100644 --- a/webdav/webdav.go +++ b/webdav/webdav.go @@ -40,6 +40,16 @@ func (c *Config) ServeHTTP(w http.ResponseWriter, r *http.Request) { } u = user + } else { + // Even if Auth is disabled, we might want to get + // the user from the Basic Auth header. Useful for Caddy + // plugin implementation. + username, _, ok := r.BasicAuth() + if ok { + if user, ok := c.Users[username]; ok { + u = user + } + } } // Checks for user permissions relatively to this PATH.