Skip to content

Commit

Permalink
More JWT logging (#1118)
Browse files Browse the repository at this point in the history
  • Loading branch information
SapiensAnatis authored Oct 16, 2024
1 parent d54bbd1 commit e289b3e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
7 changes: 6 additions & 1 deletion Website/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
4 changes: 3 additions & 1 deletion Website/src/lib/auth/jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export type JwtMetadata =
| {
valid: true;
expiryTimestampMs: number;
originalPayload: Record<string, unknown>;
};

const getJwtMetadata = (jwt: string): JwtMetadata => {
Expand Down Expand Up @@ -37,7 +38,8 @@ const getJwtMetadata = (jwt: string): JwtMetadata => {

return {
valid: true,
expiryTimestampMs: exp * 1000
expiryTimestampMs: exp * 1000,
originalPayload: payloadObject
};
};

Expand Down
2 changes: 1 addition & 1 deletion Website/src/lib/server/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { env } from '$env/dynamic/private';
const loggingStreams: Stream[] = [
{
stream: process.stdout,
level: 'error'
level: 'debug'
},
...(env.SEQ_URL
? [
Expand Down
9 changes: 9 additions & 0 deletions Website/src/routes/(main)/oauth/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e289b3e

Please sign in to comment.