fix: Upgrade jsonwebtoken to address CVE-2022-23540 (#5116)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-01-13 18:24:59 +01:00
committed by GitHub
parent 0a5ab560b1
commit 97969fc815
5 changed files with 31 additions and 51 deletions

View File

@@ -27,6 +27,7 @@ export function issueJWT(user: User): JwtToken {
const signedToken = jwt.sign(payload, config.getEnv('userManagement.jwtSecret'), {
expiresIn: expiresIn / 1000 /* in seconds */,
algorithm: 'HS256',
});
return {
@@ -57,7 +58,9 @@ export async function resolveJwtContent(jwtPayload: JwtPayload): Promise<User> {
}
export async function resolveJwt(token: string): Promise<User> {
const jwtPayload = jwt.verify(token, config.getEnv('userManagement.jwtSecret')) as JwtPayload;
const jwtPayload = jwt.verify(token, config.getEnv('userManagement.jwtSecret'), {
algorithms: ['HS256'],
}) as JwtPayload;
return resolveJwtContent(jwtPayload);
}