feat: logging unauthenticated requests
This commit is contained in:
@@ -34,6 +34,7 @@ func main() {
|
|||||||
u, p, ok := r.BasicAuth()
|
u, p, ok := r.BasicAuth()
|
||||||
if !ok || subtle.ConstantTimeCompare([]byte(u), []byte(username)) != 1 ||
|
if !ok || subtle.ConstantTimeCompare([]byte(u), []byte(username)) != 1 ||
|
||||||
subtle.ConstantTimeCompare([]byte(p), []byte(password)) != 1 {
|
subtle.ConstantTimeCompare([]byte(p), []byte(password)) != 1 {
|
||||||
|
log.Printf("unauthorized request from %s", r.RemoteAddr)
|
||||||
w.Header().Set("WWW-Authenticate", `Basic realm="pz8-relay"`)
|
w.Header().Set("WWW-Authenticate", `Basic realm="pz8-relay"`)
|
||||||
http.Error(w, "unauthorized", http.StatusUnauthorized)
|
http.Error(w, "unauthorized", http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user