From 21ddfb9b00605d68fa3b958693a79e59dc9f15d9 Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Fri, 6 Dec 2024 20:31:04 +0000 Subject: [PATCH] Log authentication attempts --- auth.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/auth.go b/auth.go index ce21de3..630f6da 100644 --- a/auth.go +++ b/auth.go @@ -28,9 +28,13 @@ func authenticate(username, password string) bool { func handleAuthenticate(w http.ResponseWriter, req *http.Request) { status := http.StatusForbidden - username, password, ok := req.BasicAuth() - if ok && authenticate(username, password) { - status = http.StatusOK + if username, password, ok := req.BasicAuth(); ok { + if authenticate(username, password) { + status = http.StatusOK + log.Printf("auth(%s) -> ok", username) + } else { + log.Printf("auth(%s) -> ERROR", username) + } } w.WriteHeader(status) -- GitLab