From 0ee54117defdcd5908efcb620340ecf65cc60cd3 Mon Sep 17 00:00:00 2001 From: Ark2307 Date: Thu, 2 Jan 2025 21:55:09 +0530 Subject: [PATCH] Fixed check for all accounts --- .../java/com/akto/utils/sso/SsoUtils.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/apps/dashboard/src/main/java/com/akto/utils/sso/SsoUtils.java b/apps/dashboard/src/main/java/com/akto/utils/sso/SsoUtils.java index 7a9940a554..986e11ba89 100644 --- a/apps/dashboard/src/main/java/com/akto/utils/sso/SsoUtils.java +++ b/apps/dashboard/src/main/java/com/akto/utils/sso/SsoUtils.java @@ -11,9 +11,12 @@ import com.akto.dao.ConfigsDao; import com.akto.dao.SSOConfigsDao; +import com.akto.dao.context.Context; import com.akto.dto.Config.ConfigType; +import com.akto.dto.Config.OktaConfig; import com.akto.dto.sso.SAMLConfig; import com.akto.util.Constants; +import com.akto.util.DashboardMode; import com.akto.utils.CustomHttpsWrapper; import com.mongodb.client.model.Filters; @@ -32,9 +35,21 @@ public static boolean isAnySsoActive(int accountId){ } public static boolean isAnySsoActive(){ - List ssoList = Arrays.asList("OKTA-ankush", "GITHUB-ankush", "AZURE-ankush"); - Bson filter = Filters.in("_id", ssoList); - return ConfigsDao.instance.count(filter) > 0; + if(DashboardMode.isMetered() && !DashboardMode.isOnPremDeployment()){ + int accountId = Context.accountId.get(); + if(!isAnySsoActive(accountId)){ + return ConfigsDao.instance.count(Filters.and( + Filters.eq(Constants.ID, "OKTA-ankush"), + Filters.eq(OktaConfig.ACCOUNT_ID, accountId) + )) > 0; + }else{ + return true; + } + }else{ + List ssoList = Arrays.asList("OKTA-ankush", "GITHUB-ankush", "AZURE-ankush"); + Bson filter = Filters.in("_id", ssoList); + return ConfigsDao.instance.count(filter) > 0; + } } public static HttpServletRequest getWrappedRequest(HttpServletRequest servletRequest, ConfigType configType, int accountId){