Skip to content

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

Merge remote-tracking branch 'origin/main' into fix/samlDuplicateAccounts

Carlos Monastyrski34a83016176a
diff --cc backend/src/services/auth/auth-login-service.ts
index 1f986bb728,6ef40b3c5a..e3afb754a3
--- a/backend/src/services/auth/auth-login-service.ts
+++ b/backend/src/services/auth/auth-login-service.ts
@@@ -448,17 -448,12 +448,19 @@@ export const authLoginServiceFactory =
// Check if the user actually has access to the specified organization.
const userOrgs = await orgDAL.findAllOrgsByUserId(user.id);
- const hasOrganizationMembership = userOrgs.some((org) => org.id === organizationId && org.userStatus !== "invited");
+
+ const selectedOrgMembership = userOrgs.find((org) => org.id === organizationId && org.userStatus !== "invited");
+
const selectedOrg = await orgDAL.findById(organizationId);
+ // Check if authEnforced is true, if that's the case, throw an error
+ if (selectedOrg.authEnforced) {
+ throw new BadRequestError({
+ message: "Authentication is required by your organization before you can log in."
+ });
+ }
+
- if (!hasOrganizationMembership) {
+ if (!selectedOrgMembership) {
throw new ForbiddenRequestError({
message: `User does not have access to the organization named ${selectedOrg?.name}`
});