From e5bdf6055e8c0d15b2a858b3082d9af2ac518fa9 Mon Sep 17 00:00:00 2001 From: Alex Tugarev Date: Thu, 30 Mar 2023 14:55:22 +0000 Subject: [PATCH] [server] improve logging on logins --- .../server/src/auth/generic-auth-provider.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/components/server/src/auth/generic-auth-provider.ts b/components/server/src/auth/generic-auth-provider.ts index 0ded856254501b..64232b7825fc11 100644 --- a/components/server/src/auth/generic-auth-provider.ts +++ b/components/server/src/auth/generic-auth-provider.ts @@ -445,16 +445,18 @@ export class GenericAuthProvider implements AuthProvider { } if (flowContext) { + const logPayload = { + withIdentity: TosFlow.WithIdentity.is(flowContext) ? flowContext.candidate : undefined, + withUser: TosFlow.WithUser.is(flowContext) ? User.censor(flowContext.user) : undefined, + ...defaultLogPayload, + }; if ( TosFlow.WithIdentity.is(flowContext) || (TosFlow.WithUser.is(flowContext) && flowContext.termsAcceptanceRequired) ) { // This is the regular path on sign up. We just went through the OAuth2 flow but didn't create a Gitpod // account yet, as we require to accept the terms first. - log.info(context, `(${strategyName}) Redirect to /api/tos`, { - info: flowContext, - ...defaultLogPayload, - }); + log.info(context, `(${strategyName}) Redirect to /api/tos`, logPayload); // attach the sign up info to the session, in order to proceed after acceptance of terms await TosFlow.attach(request.session!, flowContext); @@ -463,10 +465,7 @@ export class GenericAuthProvider implements AuthProvider { return; } else { const { user, elevateScopes } = flowContext as TosFlow.WithUser; - log.info(context, `(${strategyName}) Directly log in and proceed.`, { - info: flowContext, - ...defaultLogPayload, - }); + log.info(context, `(${strategyName}) Directly log in and proceed.`, logPayload); // Complete login const { host, returnTo } = authFlow;