Skip to content

Commit

Permalink
fix(backend): use atomic command to improve security
Browse files Browse the repository at this point in the history
Co-Authored-By: Acid Chicken <[email protected]>
  • Loading branch information
syuilo and acid-chicken committed Nov 21, 2024
1 parent 090e939 commit 9fdabe3
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions packages/backend/src/core/WebAuthnService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,12 @@ export class WebAuthnService {

@bindThis
public async verifyAuthentication(userId: MiUser['id'], response: AuthenticationResponseJSON): Promise<boolean> {
const challenge = await this.redisClient.get(`webauthn:challenge:${userId}`);
const challenge = await this.redisClient.getdel(`webauthn:challenge:${userId}`);

if (!challenge) {
throw new IdentifiableError('2d16e51c-007b-4edd-afd2-f7dd02c947f6', 'challenge not found');
}

await this.redisClient.del(`webauthn:challenge:${userId}`);

const key = await this.userSecurityKeysRepository.findOneBy({
id: response.id,
userId: userId,
Expand Down

0 comments on commit 9fdabe3

Please sign in to comment.