Skip to content

[server] improve logging on logins #17096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions components/server/src/auth/generic-auth-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down