From e04e11f597b97b3e141358985e8544def5a13c53 Mon Sep 17 00:00:00 2001 From: Carlos Monastyrski Date: Sun, 31 Aug 2025 13:24:08 -0300 Subject: [PATCH] Check token source before throwing an error for auth enforced scenarios --- backend/src/services/auth/auth-login-service.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/src/services/auth/auth-login-service.ts b/backend/src/services/auth/auth-login-service.ts index e3afb754a..e2d628c99 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." });