From 052c6905095f5f2fe424b9b78495fb5b449b1426 Mon Sep 17 00:00:00 2001 From: William Petit Date: Thu, 4 Jan 2024 16:22:13 +0100 Subject: [PATCH] feat(middleware): log more informations on authentification errors --- server/middleware.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server/middleware.go b/server/middleware.go index c9f7918..3433447 100644 --- a/server/middleware.go +++ b/server/middleware.go @@ -51,7 +51,7 @@ func Authenticate(store peering.Store, key *rsa.PublicKey, funcs ...OptionFunc) serverClaims, err := assertServerToken(key, serverToken) if err != nil { - logger.Printf("[ERROR] %s", err) + logger.Printf("[ERROR] %+v", err) sendError(w, http.StatusUnauthorized) return } @@ -64,13 +64,13 @@ func Authenticate(store peering.Store, key *rsa.PublicKey, funcs ...OptionFunc) options.IgnoredClientTokenErrors..., ) if err != nil { - logger.Printf("[ERROR] %s", err) + logger.Printf("[ERROR] %+v", err) switch err { case peering.ErrPeerNotFound: sendError(w, http.StatusUnauthorized) case ErrNotPeered: if err := store.UpdateLastContact(serverClaims.PeerID, r.RemoteAddr, time.Now()); err != nil { - logger.Printf("[ERROR] %s", err) + logger.Printf("[ERROR] %+v", err) sendError(w, http.StatusInternalServerError) return } @@ -78,7 +78,7 @@ func Authenticate(store peering.Store, key *rsa.PublicKey, funcs ...OptionFunc) return case ErrPeerRejected: if err := store.UpdateLastContact(serverClaims.PeerID, r.RemoteAddr, time.Now()); err != nil { - logger.Printf("[ERROR] %s", err) + logger.Printf("[ERROR] %+v", err) sendError(w, http.StatusInternalServerError) return } @@ -92,19 +92,19 @@ func Authenticate(store peering.Store, key *rsa.PublicKey, funcs ...OptionFunc) match, body, err := assertBodySum(r.Body, clientClaims.BodySum) if err != nil { - logger.Printf("[ERROR] %s", err) + logger.Printf("[ERROR] %+v", err) sendError(w, http.StatusInternalServerError) return } if !match { - logger.Printf("[ERROR] %s", ErrInvalidChecksum) + logger.Printf("[ERROR] %+v", ErrInvalidChecksum) sendError(w, http.StatusBadRequest) return } if err := store.UpdateLastContact(serverClaims.PeerID, r.RemoteAddr, time.Now()); err != nil { - logger.Printf("[ERROR] %s", err) + logger.Printf("[ERROR] %+v", err) sendError(w, http.StatusInternalServerError) return }