feat(middleware): log more informations on authentification errors
Cadoles/go-http-peering/pipeline/head There was a failure building this commit
Details
Cadoles/go-http-peering/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
e8e484a7ff
commit
052c690509
|
@ -51,7 +51,7 @@ func Authenticate(store peering.Store, key *rsa.PublicKey, funcs ...OptionFunc)
|
||||||
|
|
||||||
serverClaims, err := assertServerToken(key, serverToken)
|
serverClaims, err := assertServerToken(key, serverToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Printf("[ERROR] %s", err)
|
logger.Printf("[ERROR] %+v", err)
|
||||||
sendError(w, http.StatusUnauthorized)
|
sendError(w, http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -64,13 +64,13 @@ func Authenticate(store peering.Store, key *rsa.PublicKey, funcs ...OptionFunc)
|
||||||
options.IgnoredClientTokenErrors...,
|
options.IgnoredClientTokenErrors...,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Printf("[ERROR] %s", err)
|
logger.Printf("[ERROR] %+v", err)
|
||||||
switch err {
|
switch err {
|
||||||
case peering.ErrPeerNotFound:
|
case peering.ErrPeerNotFound:
|
||||||
sendError(w, http.StatusUnauthorized)
|
sendError(w, http.StatusUnauthorized)
|
||||||
case ErrNotPeered:
|
case ErrNotPeered:
|
||||||
if err := store.UpdateLastContact(serverClaims.PeerID, r.RemoteAddr, time.Now()); err != nil {
|
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)
|
sendError(w, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ func Authenticate(store peering.Store, key *rsa.PublicKey, funcs ...OptionFunc)
|
||||||
return
|
return
|
||||||
case ErrPeerRejected:
|
case ErrPeerRejected:
|
||||||
if err := store.UpdateLastContact(serverClaims.PeerID, r.RemoteAddr, time.Now()); err != nil {
|
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)
|
sendError(w, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -92,19 +92,19 @@ func Authenticate(store peering.Store, key *rsa.PublicKey, funcs ...OptionFunc)
|
||||||
|
|
||||||
match, body, err := assertBodySum(r.Body, clientClaims.BodySum)
|
match, body, err := assertBodySum(r.Body, clientClaims.BodySum)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Printf("[ERROR] %s", err)
|
logger.Printf("[ERROR] %+v", err)
|
||||||
sendError(w, http.StatusInternalServerError)
|
sendError(w, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !match {
|
if !match {
|
||||||
logger.Printf("[ERROR] %s", ErrInvalidChecksum)
|
logger.Printf("[ERROR] %+v", ErrInvalidChecksum)
|
||||||
sendError(w, http.StatusBadRequest)
|
sendError(w, http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := store.UpdateLastContact(serverClaims.PeerID, r.RemoteAddr, time.Now()); err != nil {
|
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)
|
sendError(w, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue