forked from mirrors/misskey
fix(backend): fix tests
This commit is contained in:
parent
1eac4ccf51
commit
9d949618ba
1 changed files with 5 additions and 1 deletions
|
|
@ -6,6 +6,7 @@
|
|||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import * as Redis from 'ioredis';
|
||||
import * as OTPAuth from 'otpauth';
|
||||
import { createHash } from 'node:crypto';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import type { MiUserProfile, UserProfilesRepository, UsersRepository } from '@/models/_.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
|
|
@ -58,8 +59,11 @@ export class UserAuthService {
|
|||
// 4. totp.counter() を用い、同じタイムスタンプから基準ステップを取得
|
||||
const currentStep = totp.counter({ timestamp: now });
|
||||
const step = currentStep + delta;
|
||||
const secretFingerprint = createHash('sha256')
|
||||
.update(profile.twoFactorSecret ?? '')
|
||||
.digest('base64url');
|
||||
|
||||
const usedTokenRedisKey = `2fa:used:${profile.userId}:${step}`;
|
||||
const usedTokenRedisKey = `2fa:used:${profile.userId}:${secretFingerprint}:${step}`;
|
||||
|
||||
// 5. TTL(有効期限)の設定
|
||||
const ttl = timeStep * (validationWindow * 2 + 1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue