Log user agent and remote addr on auth errors
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
Enhancement: Log user agent and remote addr on auth errors
|
||||||
|
|
||||||
|
The proxy will now log `user_agent`, `client.address`, `network.peer.address` and `network.peer.port` to help operations debug authentication errors. The latter three follow the [Semantic Conventions 1.26.0 / General / Attributes](https://opentelemetry.io/docs/specs/semconv/general/attributes/) naming to better integrate with log aggregation tools.
|
||||||
|
|
||||||
|
https://github.com/owncloud/ocis/pull/9475
|
||||||
@@ -3,6 +3,7 @@ package middleware
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -181,10 +182,15 @@ func (m *OIDCAuthenticator) Authenticate(r *http.Request) (*http.Request, bool)
|
|||||||
|
|
||||||
claims, err := m.getClaims(token, r)
|
claims, err := m.getClaims(token, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
host, port, _ := net.SplitHostPort(r.RemoteAddr)
|
||||||
m.Logger.Error().
|
m.Logger.Error().
|
||||||
Err(err).
|
Err(err).
|
||||||
Str("authenticator", "oidc").
|
Str("authenticator", "oidc").
|
||||||
Str("path", r.URL.Path).
|
Str("path", r.URL.Path).
|
||||||
|
Str("user_agent", r.UserAgent()).
|
||||||
|
Str("client.address", r.Header.Get("X-Forwarded-For")).
|
||||||
|
Str("network.peer.address", host).
|
||||||
|
Str("network.peer.port", port).
|
||||||
Msg("failed to authenticate the request")
|
Msg("failed to authenticate the request")
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user