diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2022-08-27 04:03:18 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2022-08-27 04:03:18 +0200 |
commit | 2a559166bb976ce48cd21c7d8dddbd5193e2b39a (patch) | |
tree | 93eb0e2a8dc3cbb0e21254b94cdebcbe6fc03a69 /src/util | |
parent | Merge remote-tracking branch 'Maddy/fix/sendMemberInProfile' into staging (diff) | |
parent | Configurable backup code length (diff) | |
download | server-2a559166bb976ce48cd21c7d8dddbd5193e2b39a.tar.xz |
Merge remote-tracking branch 'upstream/dev/staging_2' into staging
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/config/types/SecurityConfiguration.ts | 2 | ||||
-rw-r--r-- | src/util/util/MFA.ts | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/util/config/types/SecurityConfiguration.ts b/src/util/config/types/SecurityConfiguration.ts index 98c04c99..a2cebbd3 100644 --- a/src/util/config/types/SecurityConfiguration.ts +++ b/src/util/config/types/SecurityConfiguration.ts @@ -14,4 +14,6 @@ export class SecurityConfiguration { // CF-Connecting-IP for cloudflare forwadedFor: string | null = null; ipdataApiKey: string | null = "eca677b284b3bac29eb72f5e496aa9047f26543605efe99ff2ce35c9"; + mfaBackupCodeCount: number = 10; + mfaBackupCodeBytes: number = 4; } diff --git a/src/util/util/MFA.ts b/src/util/util/MFA.ts index a2afcad6..b9af6d23 100644 --- a/src/util/util/MFA.ts +++ b/src/util/util/MFA.ts @@ -1,12 +1,13 @@ import crypto from "crypto"; +import { Config } from "."; import { BackupCode } from "../entities/BackupCodes"; export function generateMfaBackupCodes(user_id: string) { let backup_codes: BackupCode[] = []; - for (let i = 0; i < 10; i++) { + for (let i = 0; i < Config.get().security.mfaBackupCodeCount; i++) { const code = BackupCode.create({ user: { id: user_id }, - code: crypto.randomBytes(4).toString("hex"), // 8 characters + code: crypto.randomBytes(Config.get().security.mfaBackupCodeBytes).toString("hex"), // 8 characters consumed: false, expired: false }); |