Skip to content

Commit

Permalink
Merge pull request #1898 from akto-api-security/hotfix/fix_sso_checks
Browse files Browse the repository at this point in the history
Fixed check for all accounts
  • Loading branch information
notshivansh authored Jan 2, 2025
2 parents 9ec09e8 + 0ee5411 commit 0874637
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions apps/dashboard/src/main/java/com/akto/utils/sso/SsoUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -32,9 +35,21 @@ public static boolean isAnySsoActive(int accountId){
}

public static boolean isAnySsoActive(){
List<String> 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<String> 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){
Expand Down

0 comments on commit 0874637

Please sign in to comment.