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
|
- [x] Write ESP8266 client
|
||||||
- [ ] Make port configurable
|
- [ ] Make port configurable
|
||||||
- [ ] Transfer using JSON
|
- [ ] 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) {
|
http.HandleFunc("/departures", func(w http.ResponseWriter, r *http.Request) {
|
||||||
user, pass, ok := r.BasicAuth()
|
user, pass, ok := r.BasicAuth()
|
||||||
if !(ok && user == "admin" && pass == password) {
|
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)
|
http.Error(w, "You shall not pass", http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user