Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix(sso): this PR corrects where plan identity limits are checked during sso login to prevent throwing limit error on users that already have a membership for email login

Scott Wilsona677191e473e
diff --git a/backend/src/ee/services/ldap-config/ldap-config-service.ts b/backend/src/ee/services/ldap-config/ldap-config-service.ts
index 4592cf0032..3b18274802 100644
--- a/backend/src/ee/services/ldap-config/ldap-config-service.ts
+++ b/backend/src/ee/services/ldap-config/ldap-config-service.ts
@@ -417,14 +417,6 @@ export const ldapConfigServiceFactory = ({
}
});
} else {
- const plan = await licenseService.getPlan(orgId);
- if (plan?.slug !== "enterprise" && plan?.identityLimit && plan.identitiesUsed >= plan.identityLimit) {
- // limit imposed on number of identities allowed / number of identities used exceeds the number of identities allowed
- throw new BadRequestError({
- message: "Failed to create new member via LDAP due to member limit reached. Upgrade plan to add more members."
- });
- }
-
userAlias = await userDAL.transaction(async (tx) => {
let newUser: TUsers | undefined;
newUser = await userDAL.findOne(
@@ -473,6 +465,15 @@ export const ldapConfigServiceFactory = ({
);
if (!orgMembership) {
+ const plan = await licenseService.getPlan(orgId);
+ if (plan?.slug !== "enterprise" && plan?.identityLimit && plan.identitiesUsed >= plan.identityLimit) {
+ // limit imposed on number of identities allowed / number of identities used exceeds the number of identities allowed
+ throw new BadRequestError({
+ message:
+ "Failed to create new member via LDAP due to member limit reached. Upgrade plan to add more members."
+ });
+ }
+
const { role, roleId } = await getDefaultOrgMembershipRole(organization.defaultMembershipRole);
await orgMembershipDAL.create(
diff --git a/backend/src/ee/services/oidc/oidc-config-service.ts b/backend/src/ee/services/oidc/oidc-config-service.ts
index fb1e70a853..11d9f27241 100644
--- a/backend/src/ee/services/oidc/oidc-config-service.ts
+++ b/backend/src/ee/services/oidc/oidc-config-service.ts
@@ -294,6 +294,15 @@ export const oidcConfigServiceFactory = ({
);
if (!orgMembership) {
+ const plan = await licenseService.getPlan(orgId);
+ if (plan?.slug !== "enterprise" && plan?.identityLimit && plan.identitiesUsed >= plan.identityLimit) {
+ // limit imposed on number of identities allowed / number of identities used exceeds the number of identities allowed
+ throw new BadRequestError({
+ message:
+ "Failed to create new member via OIDC due to member limit reached. Upgrade plan to add more members."
+ });
+ }
+
const { role, roleId } = await getDefaultOrgMembershipRole(organization.defaultMembershipRole);
await orgMembershipDAL.create(
diff --git a/backend/src/ee/services/saml-config/saml-config-service.ts b/backend/src/ee/services/saml-config/saml-config-service.ts
index 1cbe6a9308..5a307f4f22 100644
--- a/backend/src/ee/services/saml-config/saml-config-service.ts
+++ b/backend/src/ee/services/saml-config/saml-config-service.ts
@@ -336,14 +336,6 @@ export const samlConfigServiceFactory = ({
return foundUser;
});
} else {
- const plan = await licenseService.getPlan(orgId);
- if (plan?.slug !== "enterprise" && plan?.identityLimit && plan.identitiesUsed >= plan.identityLimit) {
- // limit imposed on number of identities allowed / number of identities used exceeds the number of identities allowed
- throw new BadRequestError({
- message: "Failed to create new member via SAML due to member limit reached. Upgrade plan to add more members."
- });
- }
-
user = await userDAL.transaction(async (tx) => {
let newUser: TUsers | undefined;
newUser = await userDAL.findOne(
@@ -391,6 +383,15 @@ export const samlConfigServiceFactory = ({
);
if (!orgMembership) {
+ const plan = await licenseService.getPlan(orgId);
+ if (plan?.slug !== "enterprise" && plan?.identityLimit && plan.identitiesUsed >= plan.identityLimit) {
+ // limit imposed on number of identities allowed / number of identities used exceeds the number of identities allowed
+ throw new BadRequestError({
+ message:
+ "Failed to create new member via SAML due to member limit reached. Upgrade plan to add more members."
+ });
+ }
+
const { role, roleId } = await getDefaultOrgMembershipRole(organization.defaultMembershipRole);
await orgMembershipDAL.create(