aboutsummaryrefslogtreecommitdiff
path: root/internal/httputil
diff options
context:
space:
mode:
authorkegsay <kegan@matrix.org>2022-01-28 11:14:20 +0000
committerGitHub <noreply@github.com>2022-01-28 11:14:20 +0000
commit2ea5fd41623e22cd2a00c59e7954950037bfa8bb (patch)
treee45b374a97c82607c70070632c433133bd0ce5fd /internal/httputil
parentf0340988777fa13727d458a56480f2c3f70d8660 (diff)
Add debug logging for incoming CSAPI calls on authentication failure (#2116)
* Add debug logging for incoming CSAPI calls on authentication failure Will help to debug Complement failures, and just generally useful. * Update httpapi.go Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
Diffstat (limited to 'internal/httputil')
-rw-r--r--internal/httputil/httpapi.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/internal/httputil/httpapi.go b/internal/httputil/httpapi.go
index 1fbd77da..1a37a1ee 100644
--- a/internal/httputil/httpapi.go
+++ b/internal/httputil/httpapi.go
@@ -53,12 +53,13 @@ func MakeAuthAPI(
f func(*http.Request, *userapi.Device) util.JSONResponse,
) http.Handler {
h := func(req *http.Request) util.JSONResponse {
+ logger := util.GetLogger(req.Context())
device, err := auth.VerifyUserFromRequest(req, userAPI)
if err != nil {
+ logger.Debugf("VerifyUserFromRequest %s -> HTTP %d", req.RemoteAddr, err.Code)
return *err
}
// add the user ID to the logger
- logger := util.GetLogger((req.Context()))
logger = logger.WithField("user_id", device.UserID)
req = req.WithContext(util.ContextWithLogger(req.Context(), logger))
// add the user to Sentry, if enabled