From 00cbdd18335d90402dcc4cd10c06c8454a78a254 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sun, 16 Apr 2017 13:29:57 +0100 Subject: [PATCH] try to get the user in another way --- filemanager.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/filemanager.go b/filemanager.go index e4325c97..01949d99 100644 --- a/filemanager.go +++ b/filemanager.go @@ -51,8 +51,8 @@ func (f FileManager) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, err return http.StatusForbidden, nil } - // Obtains the user - username, _, _ := r.BasicAuth() + // Obtains the user. See https://github.com/mholt/caddy/blob/master/caddyhttp/basicauth/basicauth.go#L66 + username, _ := r.Context().Value(httpserver.RemoteUserCtxKey).(string) if _, ok := c.Users[username]; ok { user = c.Users[username] } else {