Commit 681c95a7 authored by Stavros Korokithakis's avatar Stavros Korokithakis Committed by Matt Holt

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

* Add default "Restricted" realm to HTTP Basic auth

* Add tests for the Basic auth realm
parent e5a89276
......@@ -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."
......
......@@ -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 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment