|
@@ -14,7 +14,11 @@ import (
|
|
|
if RequireBasicAuth is set to true
|
|
|
*/
|
|
|
|
|
|
-func handleBasicAuthRouting(w http.ResponseWriter, r *http.Request, pe *ProxyEndpoint) error {
|
|
|
+func (h *ProxyHandler) handleBasicAuthRouting(w http.ResponseWriter, r *http.Request, pe *ProxyEndpoint) error {
|
|
|
+ proxyType := "vdir-auth"
|
|
|
+ if pe.ProxyType == ProxyType_Subdomain {
|
|
|
+ proxyType = "subd-auth"
|
|
|
+ }
|
|
|
u, p, ok := r.BasicAuth()
|
|
|
if !ok {
|
|
|
w.Header().Set("WWW-Authenticate", `Basic realm="Restricted"`)
|
|
@@ -33,9 +37,11 @@ func handleBasicAuthRouting(w http.ResponseWriter, r *http.Request, pe *ProxyEnd
|
|
|
}
|
|
|
|
|
|
if !matchingFound {
|
|
|
+ h.logRequest(r, false, 401, proxyType, pe.Domain)
|
|
|
w.Header().Set("WWW-Authenticate", `Basic realm="Restricted"`)
|
|
|
w.WriteHeader(401)
|
|
|
return errors.New("unauthorized")
|
|
|
}
|
|
|
+
|
|
|
return nil
|
|
|
}
|