Skip to content

Commit

Permalink
feat: changes jwt validation to only check app id in audience using t…
Browse files Browse the repository at this point in the history
…he jwt libs validation options
  • Loading branch information
ctran88 committed Dec 23, 2024
1 parent 175827e commit b0b28ce
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/classes/Auth/Auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,11 @@ export class Auth extends PassageBase {
}

const {
payload: { sub: userId, aud },
} = await jwtVerify(jwt, this.jwks);
payload: { sub: userId },
} = await jwtVerify(jwt, this.jwks, { audience: [this.config.appId] });

if (!userId) {
throw new Error('Could not validate auth token. You must catch this error.');
}

if (Array.isArray(aud)) {
if (!aud.includes(this.config.appId)) {
throw new Error('Incorrect app ID claim in token. You must catch this error.');
}
throw new Error('sub missing in jwt claims.');
}

return userId;
Expand Down

0 comments on commit b0b28ce

Please sign in to comment.