diff --git a/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/connector/RecoveryConfigImpl.java b/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/connector/RecoveryConfigImpl.java index e5df69d756..32435975b0 100644 --- a/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/connector/RecoveryConfigImpl.java +++ b/components/org.wso2.carbon.identity.recovery/src/main/java/org/wso2/carbon/identity/recovery/connector/RecoveryConfigImpl.java @@ -17,6 +17,8 @@ import org.apache.commons.lang.StringUtils; import org.wso2.carbon.identity.application.common.model.Property; +import org.wso2.carbon.identity.core.ServiceURLBuilder; +import org.wso2.carbon.identity.core.URLBuilderException; import org.wso2.carbon.identity.core.util.IdentityUtil; import org.wso2.carbon.identity.governance.IdentityGovernanceException; import org.wso2.carbon.identity.governance.IdentityMgtConstants; @@ -233,6 +235,8 @@ public Properties getDefaultPropertyValues(String tenantDomain) throws IdentityG String enableAdminPasswordResetAutoLoginProperty = "false"; String recoveryMaxFailedAttempts = "3"; String recoveryMaxResendAttempts = "5"; + int httpsProxyPort = 443; + String secureHttpProtocol = "https"; String notificationBasedPasswordRecovery = IdentityUtil.getProperty( IdentityRecoveryConstants.ConnectorConfig.NOTIFICATION_BASED_PW_RECOVERY); @@ -358,6 +362,17 @@ public Properties getDefaultPropertyValues(String tenantDomain) throws IdentityG enableUsernameRecoveryReCaptcha = userNameRecoveryReCaptcha; } if (StringUtils.isNotEmpty(recoveryCallbackRegexProperty)) { + try { + int proxyPort = ServiceURLBuilder.create().build().getPort(); + if (proxyPort == httpsProxyPort && recoveryCallbackRegexProperty.contains(secureHttpProtocol) + && recoveryCallbackRegexProperty.contains(":" + httpsProxyPort + "\\")) { + // remove 443 if added to the regex since it's the proxy port. + recoveryCallbackRegexProperty = recoveryCallbackRegexProperty + "|" + + recoveryCallbackRegexProperty.replace(":" + httpsProxyPort + "\\", "\\"); + } + } catch (URLBuilderException e) { + throw new IdentityGovernanceException(e); + } recoveryCallbackRegex = recoveryCallbackRegexProperty; } if (StringUtils.isNotEmpty(adminPasswordResetAutoLoginProperty)) {