Skip to content

Commit

Permalink
fix(server): validate oauth profile has a sub (#15967)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasm91 authored Feb 8, 2025
1 parent fb21950 commit 758bcd1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server/src/repositories/oauth.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ export class OAuthRepository {
const params = client.callbackParams(url);
try {
const tokens = await client.callback(redirectUrl, params, { state: params.state });
return await client.userinfo<OAuthProfile>(tokens.access_token || '');
const profile = await client.userinfo<OAuthProfile>(tokens.access_token || '');
if (!profile.sub) {
throw new Error('Unexpected profile response, no `sub`');
}

return profile;
} catch (error: Error | any) {
if (error.message.includes('unexpected JWT alg received')) {
this.logger.warn(
Expand Down

0 comments on commit 758bcd1

Please sign in to comment.