Skip to content

Commit

Permalink
Fixing npe
Browse files Browse the repository at this point in the history
  • Loading branch information
Ark2307 committed Jan 3, 2025
1 parent 66c867d commit b321ba6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2930,13 +2930,14 @@ private static void moveOktaOidcSSO(BackwardCompatibility backwardCompatibility)
Config.OktaConfig oktaConfig = (Config.OktaConfig) ConfigsDao.instance.findOne(
Filters.eq(Constants.ID, saltId)
);
int accountId = Context.accountId.get();
oktaConfig.setId(OktaConfig.getOktaId(accountId));
ConfigsDao.instance.deleteAll(
Filters.eq(Constants.ID, saltId)
);

ConfigsDao.instance.insertOne(oktaConfig);
if(oktaConfig != null){
int accountId = Context.accountId.get();
oktaConfig.setId(OktaConfig.getOktaId(accountId));
ConfigsDao.instance.insertOne(oktaConfig);
ConfigsDao.instance.deleteAll(
Filters.eq(Constants.ID, saltId)
);
}
BackwardCompatibilityDao.instance.updateOne(
Filters.eq("_id", backwardCompatibility.getId()),
Updates.set(BackwardCompatibility.MOVE_OKTA_OIDC_SSO, Context.now())
Expand Down
3 changes: 2 additions & 1 deletion apps/dashboard/src/main/java/com/akto/utils/OktaLogin.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.akto.dao.context.Context;
import com.akto.dto.Config;
import com.akto.dto.Config.OktaConfig;
import com.akto.util.Constants;
import com.akto.utils.sso.SsoUtils;

public class OktaLogin {
Expand All @@ -23,7 +24,7 @@ public static OktaLogin getInstance() {
}

if (shouldProbeAgain) {
OktaConfig oktaConfig = (Config.OktaConfig) ConfigsDao.instance.findOne("_id", "OKTA-ankush");
OktaConfig oktaConfig = (Config.OktaConfig) ConfigsDao.instance.findOne(Constants.ID, OktaConfig.getOktaId(Context.accountId.get()));
if (instance == null) {
instance = new OktaLogin();
}
Expand Down
4 changes: 2 additions & 2 deletions apps/dashboard/src/main/java/com/akto/utils/sso/SsoUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ public static boolean isAnySsoActive(int accountId){

public static boolean isAnySsoActive(){
int accountId = Context.accountId.get();
String oktaIdString = OktaConfig.getOktaId(accountId);
if(DashboardMode.isMetered() && !DashboardMode.isOnPremDeployment()){
if(!isAnySsoActive(accountId)){
return ConfigsDao.instance.count(Filters.and(
Filters.eq(Constants.ID, "OKTA-ankush"),
Filters.eq(Constants.ID, oktaIdString),
Filters.eq(OktaConfig.ACCOUNT_ID, accountId)
)) > 0;
}else{
return true;
}
}else{
String oktaIdString = OktaConfig.getOktaId(accountId);
List<String> ssoList = Arrays.asList(oktaIdString, "GITHUB-ankush", "AZURE-ankush");
Bson filter = Filters.in("_id", ssoList);
return ConfigsDao.instance.count(filter) > 0;
Expand Down

0 comments on commit b321ba6

Please sign in to comment.