From e289b3ede3e9659be31e4f111f7ebb6be0ec1f41 Mon Sep 17 00:00:00 2001 From: Jay Malhotra <5047192+SapiensAnatis@users.noreply.github.com> Date: Wed, 16 Oct 2024 20:12:42 +0000 Subject: [PATCH] More JWT logging (#1118) --- Website/playwright.config.ts | 7 ++++++- Website/src/lib/auth/jwt.ts | 4 +++- Website/src/lib/server/logger.ts | 2 +- Website/src/routes/(main)/oauth/+page.server.ts | 9 +++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Website/playwright.config.ts b/Website/playwright.config.ts index d434ead2e..b0061f824 100644 --- a/Website/playwright.config.ts +++ b/Website/playwright.config.ts @@ -28,7 +28,12 @@ const config: PlaywrightTestConfig = { use: { ...devices['Desktop Chrome'], storageState: 'playwright/.auth/user.json' }, dependencies: ['setup'] } - ] + ], + expect: { + toHaveScreenshot: { + maxDiffPixelRatio: 0.02 + } + } }; export default config; diff --git a/Website/src/lib/auth/jwt.ts b/Website/src/lib/auth/jwt.ts index c6dd1f92c..a131e398b 100644 --- a/Website/src/lib/auth/jwt.ts +++ b/Website/src/lib/auth/jwt.ts @@ -3,6 +3,7 @@ export type JwtMetadata = | { valid: true; expiryTimestampMs: number; + originalPayload: Record; }; const getJwtMetadata = (jwt: string): JwtMetadata => { @@ -37,7 +38,8 @@ const getJwtMetadata = (jwt: string): JwtMetadata => { return { valid: true, - expiryTimestampMs: exp * 1000 + expiryTimestampMs: exp * 1000, + originalPayload: payloadObject }; }; diff --git a/Website/src/lib/server/logger.ts b/Website/src/lib/server/logger.ts index b8e6dc8e5..0df326175 100644 --- a/Website/src/lib/server/logger.ts +++ b/Website/src/lib/server/logger.ts @@ -6,7 +6,7 @@ import { env } from '$env/dynamic/private'; const loggingStreams: Stream[] = [ { stream: process.stdout, - level: 'error' + level: 'debug' }, ...(env.SEQ_URL ? [ diff --git a/Website/src/routes/(main)/oauth/+page.server.ts b/Website/src/routes/(main)/oauth/+page.server.ts index 293023a20..0f7eb0361 100644 --- a/Website/src/routes/(main)/oauth/+page.server.ts +++ b/Website/src/routes/(main)/oauth/+page.server.ts @@ -71,12 +71,21 @@ const getBaasToken = async ( throw new Error('Failed to get challenge string'); } + logger.debug({ challengeString }, 'Retrieved challenge string: {challengeString}'); + const sessionTokenCode = url.searchParams.get('session_token_code'); if (!sessionTokenCode) { throw new Error('Failed to get session token code'); } + logger.debug( + { stcMetadata: getJwtMetadata(sessionTokenCode) }, + 'Retrieved session token code with metadata {stcMetadata}' + ); + + logger.debug({ currentTimestamp: Date.now() }, 'Current timestamp: {currentTimestamp}'); + const sessionTokenCodeParams = new URLSearchParams({ client_id: PUBLIC_BAAS_CLIENT_ID, session_token_code: sessionTokenCode,