Send WWW-Authenticate along with 401 for RFC 7235 conformity
This commit is contained in:
parent
38a487a6e1
commit
2d25a53949
@ -9,4 +9,4 @@
|
||||
- [x] Write ESP8266 client
|
||||
- [ ] Make port configurable
|
||||
- [ ] Transfer using JSON
|
||||
- [ ] Correctly implement basic auth
|
||||
- [x] Correctly implement basic auth
|
||||
|
1
main.go
1
main.go
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user