0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2025-02-03 23:09:57 -05:00

Add default "Restricted" realm to HTTP Basic auth (#1007)

* Add default "Restricted" realm to HTTP Basic auth

* Add tests for the Basic auth realm
This commit is contained in:
Stavros Korokithakis 2016-08-07 16:50:36 +03:00 committed by Matt Holt
parent e5a8927635
commit 681c95a749
2 changed files with 2 additions and 2 deletions

View file

@ -61,7 +61,7 @@ func (a BasicAuth) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error
if hasAuth {
if !isAuthenticated {
w.Header().Set("WWW-Authenticate", "Basic")
w.Header().Set("WWW-Authenticate", "Basic realm=\"Restricted\"")
return http.StatusUnauthorized, nil
}
// "It's an older code, sir, but it checks out. I was about to clear them."

View file

@ -52,7 +52,7 @@ func TestBasicAuth(t *testing.T) {
if result == http.StatusUnauthorized {
headers := rec.Header()
if val, ok := headers["Www-Authenticate"]; ok {
if val[0] != "Basic" {
if val[0] != "Basic realm=\"Restricted\"" {
t.Errorf("Test %d, Www-Authenticate should be %s provided %s", i, "Basic", val[0])
}
} else {