Skip to content

Commit 7c83d37

Browse files
committed
validate jwt audience in backend auth middleware
1 parent d5b7bff commit 7c83d37

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

app/src/middleware/authentication.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ export const currentUser = async (req: Request, res: Response, next: NextFunctio
3838
if (config.has('server.oidc.authority') && config.has('server.oidc.publicKey')) {
3939
const publicKey: string = config.get('server.oidc.publicKey');
4040
const pemKey = publicKey.startsWith('-----BEGIN') ? publicKey : _spkiWrapper(publicKey);
41-
isValid = jwt.verify(bearerToken, pemKey, { issuer: config.get('server.oidc.authority') });
41+
isValid = jwt.verify(bearerToken, pemKey, {
42+
issuer: config.get('server.oidc.authority'),
43+
audience: config.get('frontend.oidc.clientId')
44+
});
4245
} else {
4346
throw new Error(
4447
'OIDC environment variables `SERVER_OIDC_AUTHORITY` and `SERVER_OIDC_PUBLICKEY` must be defined'

0 commit comments

Comments
 (0)