Send WWW-Authenticate along with 401 for RFC 7235 conformity

This commit is contained in:
2024-07-18 21:56:51 +02:00
parent 38a487a6e1
commit 2d25a53949
2 changed files with 2 additions and 1 deletions
+1
View File
@@ -148,6 +148,7 @@ func main() {
http.HandleFunc("/departures", func(w http.ResponseWriter, r *http.Request) {
user, pass, ok := r.BasicAuth()
if !(ok && user == "admin" && pass == password) {
w.Header().Set("WWW-Authenticate", "Basic realm=\"Access to departure API\"")
http.Error(w, "You shall not pass", http.StatusUnauthorized)
return
}