From 7a3d4fb58cfbd59602dd275663dd20daba147589 Mon Sep 17 00:00:00 2001 From: wangsijie Date: Mon, 18 Sep 2023 10:00:26 +0800 Subject: [PATCH] fix(core): quota guard for mfa feature (#4529) --- packages/core/package.json | 2 +- packages/core/src/libraries/quota.ts | 3 ++- packages/core/src/routes/sign-in-experience/index.ts | 4 ++++ pnpm-lock.yaml | 4 ++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index 808bc98d6..6cb341acf 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -82,7 +82,7 @@ "zod": "^3.20.2" }, "devDependencies": { - "@logto/cloud": "0.2.5-a3e852f", + "@logto/cloud": "0.2.5-444ed49", "@silverhand/eslint-config": "4.0.1", "@silverhand/ts-config": "4.0.0", "@types/debug": "^4.1.7", diff --git a/packages/core/src/libraries/quota.ts b/packages/core/src/libraries/quota.ts index b58a6d81e..9a4417bc5 100644 --- a/packages/core/src/libraries/quota.ts +++ b/packages/core/src/libraries/quota.ts @@ -69,6 +69,7 @@ export const createQuotaLibrary = ( return { count }; }, customDomainEnabled: notNumber, + mfaEnabled: notNumber, omniSignInEnabled: notNumber, // No limit for now builtInEmailConnectorEnabled: notNumber, // No limit for now }; @@ -81,7 +82,7 @@ export const createQuotaLibrary = ( }; const guardKey = async (key: keyof FeatureQuota, queryKey?: string) => { - const { isCloud, isIntegrationTest, isProduction } = EnvSet.values; + const { isCloud, isIntegrationTest } = EnvSet.values; // Cloud only feature, skip in non-cloud environments if (!isCloud) { diff --git a/packages/core/src/routes/sign-in-experience/index.ts b/packages/core/src/routes/sign-in-experience/index.ts index e2e056c33..d328479fd 100644 --- a/packages/core/src/routes/sign-in-experience/index.ts +++ b/packages/core/src/routes/sign-in-experience/index.ts @@ -15,6 +15,7 @@ export default function signInExperiencesRoutes( const { deleteConnectorById } = queries.connectors; const { signInExperiences: { validateLanguageInfo }, + quota: { guardKey }, } = libraries; const { getLogtoConnectors } = connectors; @@ -84,6 +85,9 @@ export default function signInExperiencesRoutes( } if (mfa) { + if (mfa.factors.length > 0) { + await guardKey('mfaEnabled'); + } validateMfa(mfa); } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index eaf33939f..10a928769 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3282,8 +3282,8 @@ importers: version: 3.20.2 devDependencies: '@logto/cloud': - specifier: 0.2.5-a3e852f - version: 0.2.5-a3e852f(zod@3.20.2) + specifier: 0.2.5-444ed49 + version: 0.2.5-444ed49(zod@3.20.2) '@silverhand/eslint-config': specifier: 4.0.1 version: 4.0.1(eslint@8.44.0)(prettier@3.0.0)(typescript@5.0.2)