summary refs log tree commit diff
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-24 03:16:53 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-27 03:40:42 +0200
commit57583d049aaf77a267976f7cdf0e553a3599929c (patch)
tree99634b50e54b072554b2c8b1aa70a9c857d2855f
parentMerge pull request #799 from MaddyUnderStars/feat/captchaVerify (diff)
downloadserver-57583d049aaf77a267976f7cdf0e553a3599929c.tar.xz
Configurable MFA backup token length
-rw-r--r--src/util/config/types/SecurityConfiguration.ts1
-rw-r--r--src/util/util/MFA.ts3
2 files changed, 3 insertions, 1 deletions
diff --git a/src/util/config/types/SecurityConfiguration.ts b/src/util/config/types/SecurityConfiguration.ts
index 98c04c99..868f5f0a 100644
--- a/src/util/config/types/SecurityConfiguration.ts
+++ b/src/util/config/types/SecurityConfiguration.ts
@@ -14,4 +14,5 @@ export class SecurityConfiguration {
 	// CF-Connecting-IP for cloudflare
 	forwadedFor: string | null = null;
 	ipdataApiKey: string | null = "eca677b284b3bac29eb72f5e496aa9047f26543605efe99ff2ce35c9";
+	mfaBackupCodeCount: number = 10;
 }
diff --git a/src/util/util/MFA.ts b/src/util/util/MFA.ts
index a2afcad6..d0a5722a 100644
--- a/src/util/util/MFA.ts
+++ b/src/util/util/MFA.ts
@@ -1,9 +1,10 @@
 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