From db997f78ff45bb3630b37bd65e27b511943527f9 Mon Sep 17 00:00:00 2001 From: Eric Doughty-Papassideris Date: Tue, 17 Dec 2024 22:06:20 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8A=20back:=20log=20http=20headers=20a?= =?UTF-8?q?t=20login=20to=20get=20trace=20of=20IP=20and=20user=20agent=20a?= =?UTF-8?q?s=20relates=20(#762)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../node/src/services/console/web/controller.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tdrive/backend/node/src/services/console/web/controller.ts b/tdrive/backend/node/src/services/console/web/controller.ts index 35a3217f..703149f2 100644 --- a/tdrive/backend/node/src/services/console/web/controller.ts +++ b/tdrive/backend/node/src/services/console/web/controller.ts @@ -37,6 +37,20 @@ export class ConsoleController { } async auth(request: FastifyRequest<{ Body: AuthRequest }>): Promise { + const censoredHeadersLC = { + authorization: true, + cookie: true, + }; + logger.info( + { + http_headers: Object.fromEntries( + Object.entries(request.headers) + .map(([k, v]) => (censoredHeadersLC[k.toLowerCase()] ? null : [k, v])) + .filter(x => !!x), + ), + }, + "auth_attempt", + ); if (request.body.oidc_id_token) { return { access_token: await this.authByToken(request.body.oidc_id_token) }; } else if (request.body.email && request.body.password) {