Skip to content

Commit

Permalink
validate jwt audience in backend auth middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
TimCsaky committed May 21, 2024
1 parent d5b7bff commit 7c83d37
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/src/middleware/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ export const currentUser = async (req: Request, res: Response, next: NextFunctio
if (config.has('server.oidc.authority') && config.has('server.oidc.publicKey')) {
const publicKey: string = config.get('server.oidc.publicKey');
const pemKey = publicKey.startsWith('-----BEGIN') ? publicKey : _spkiWrapper(publicKey);
isValid = jwt.verify(bearerToken, pemKey, { issuer: config.get('server.oidc.authority') });
isValid = jwt.verify(bearerToken, pemKey, {
issuer: config.get('server.oidc.authority'),
audience: config.get('frontend.oidc.clientId')
});
} else {
throw new Error(
'OIDC environment variables `SERVER_OIDC_AUTHORITY` and `SERVER_OIDC_PUBLICKEY` must be defined'
Expand Down

0 comments on commit 7c83d37

Please sign in to comment.