From adb286676ec3d029721c4b34b591cf48e0a8e1e0 Mon Sep 17 00:00:00 2001 From: Alexey Zinoviev Date: Fri, 21 Jun 2024 06:13:31 +0400 Subject: [PATCH] uberf-7350: add more oauth logs (#5879) --- pods/authProviders/src/github.ts | 2 +- pods/authProviders/src/google.ts | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pods/authProviders/src/github.ts b/pods/authProviders/src/github.ts index bcae180a25..a077a2a027 100644 --- a/pods/authProviders/src/github.ts +++ b/pods/authProviders/src/github.ts @@ -38,7 +38,7 @@ export function registerGithub ( router.get('/auth/github', async (ctx, next) => { measureCtx.info('try auth via', { provider: 'github' }) const host = getHost(ctx.request.headers) - const branding = host !== undefined ? brandings[host]?.key ?? '' : '' + const branding = host !== undefined ? brandings[host]?.key ?? undefined : undefined const state = encodeURIComponent( JSON.stringify({ inviteId: ctx.query?.inviteId, diff --git a/pods/authProviders/src/google.ts b/pods/authProviders/src/google.ts index 505f9b0cfd..f39b223f35 100644 --- a/pods/authProviders/src/google.ts +++ b/pods/authProviders/src/google.ts @@ -38,7 +38,7 @@ export function registerGoogle ( router.get('/auth/google', async (ctx, next) => { measureCtx.info('try auth via', { provider: 'google' }) const host = getHost(ctx.request.headers) - const branding = host !== undefined ? brandings[host]?.key ?? '' : '' + const branding = host !== undefined ? brandings[host]?.key ?? undefined : undefined const state = encodeURIComponent( JSON.stringify({ inviteId: ctx.query?.inviteId, @@ -53,14 +53,19 @@ export function registerGoogle ( redirectURL, async (ctx, next) => { const state = safeParseAuthState(ctx.query?.state) + measureCtx.info('Auth state', { state }) const branding = getBranding(brandings, state?.branding) + measureCtx.info('With branding', { branding }) + const failureRedirect = concatLink(branding?.front ?? frontUrl, '/login') + measureCtx.info('With failure redirect', { failureRedirect }) passport.authenticate('google', { - failureRedirect: concatLink(branding?.front ?? frontUrl, '/login'), + failureRedirect, session: true })(ctx, next) }, async (ctx, next) => { + measureCtx.info('Provider auth success', { type: 'google', user: ctx.state?.user }) const email = ctx.state.user.emails?.[0]?.value const first = ctx.state.user.name.givenName const last = ctx.state.user.name.familyName