Skip to content

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

Check token source before throwing an error for auth enforced scenarios

Carlos Monastyrskie04e11f597b9
diff --git a/backend/src/services/auth/auth-login-service.ts b/backend/src/services/auth/auth-login-service.ts
index e3afb754a3..e2d628c998 100644
--- a/backend/src/services/auth/auth-login-service.ts
+++ b/backend/src/services/auth/auth-login-service.ts
@@ -453,8 +453,13 @@ export const authLoginServiceFactory = ({
const selectedOrg = await orgDAL.findById(organizationId);
- // Check if authEnforced is true, if that's the case, throw an error
- if (selectedOrg.authEnforced) {
+ // Check if authEnforced is true and the current auth method is not an enforced method
+ if (
+ selectedOrg.authEnforced &&
+ !isAuthMethodSaml(decodedToken.authMethod) &&
+ decodedToken.authMethod !== AuthMethod.OIDC &&
+ decodedToken.authMethod !== AuthMethod.GOOGLE
+ ) {
throw new BadRequestError({
message: "Authentication is required by your organization before you can log in."
});