From 3fea7c39becf8ee81c48e4b3870c7207b3451096 Mon Sep 17 00:00:00 2001 From: ofen <614942+ofen@users.noreply.github.com> Date: Sun, 9 Aug 2020 09:38:41 +0300 Subject: [PATCH] 401 Unauthorize HTTP error added (#681) 401 Unauthorize HTTP error added to trigger browser credentials pop-up promt [RFC 7235 https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication] --- app/vmauth/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/vmauth/main.go b/app/vmauth/main.go index e7b43ef6a1..d1645a5667 100644 --- a/app/vmauth/main.go +++ b/app/vmauth/main.go @@ -49,7 +49,8 @@ func main() { func requestHandler(w http.ResponseWriter, r *http.Request) bool { username, password, ok := r.BasicAuth() if !ok { - httpserver.Errorf(w, r, "missing `Authorization: Basic *` header") + w.Header().Set("WWW-Authenticate", `Basic realm="Restricted"`) + http.Error(w, "missing `Authorization: Basic *` header", http.StatusUnauthorized) return true } ac := authConfig.Load().(map[string]*UserInfo)