|
|
|
@ -167,9 +167,20 @@ public class DefaultTwoFaConfigManager implements TwoFaConfigManager { |
|
|
|
for (TwoFaProviderConfig providerConfig : twoFactorAuthSettings.getProviders()) { |
|
|
|
twoFactorAuthService.checkProvider(tenantId, providerConfig.getProviderType()); |
|
|
|
} |
|
|
|
if (tenantId.isSysTenantId() && twoFactorAuthSettings.isEnforceTwoFa() && twoFactorAuthSettings.getProviders().isEmpty()) { |
|
|
|
throw new DataValidationException("At least one 2FA provider is required if enforcing is enabled"); |
|
|
|
if (tenantId.isSysTenantId()) { |
|
|
|
if (twoFactorAuthSettings.isEnforceTwoFa()) { |
|
|
|
if (twoFactorAuthSettings.getProviders().isEmpty()) { |
|
|
|
throw new DataValidationException("At least one 2FA provider is required if enforcing is enabled"); |
|
|
|
} |
|
|
|
if (twoFactorAuthSettings.getEnforcedUsersFilter() == null) { |
|
|
|
throw new DataValidationException("Users filter to enforce 2FA for is required"); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
twoFactorAuthSettings.setEnforceTwoFa(false); |
|
|
|
twoFactorAuthSettings.setEnforcedUsersFilter(null); |
|
|
|
} |
|
|
|
|
|
|
|
AdminSettings settings = Optional.ofNullable(adminSettingsService.findAdminSettingsByKey(tenantId, TWO_FACTOR_AUTH_SETTINGS_KEY)) |
|
|
|
.orElseGet(() -> { |
|
|
|
AdminSettings newSettings = new AdminSettings(); |
|
|
|
|