diff --git a/components/org.wso2.carbon.identity.captcha/pom.xml b/components/org.wso2.carbon.identity.captcha/pom.xml index 4c2cebfc8f..a99bec497c 100644 --- a/components/org.wso2.carbon.identity.captcha/pom.xml +++ b/components/org.wso2.carbon.identity.captcha/pom.xml @@ -197,6 +197,8 @@ version="${carbon.identity.account.lock.handler.imp.pkg.version.range}", org.wso2.securevault.*; version="${org.wso2.securevault.import.version.range}", org.wso2.carbon.context; version="${carbon.kernel.package.import.version.range}", + org.wso2.carbon.identity.multi.attribute.login.mgt.*; + version="${carbon.identity.framework.imp.pkg.version.range}", diff --git a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/connector/recaptcha/SSOLoginReCaptchaConfig.java b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/connector/recaptcha/SSOLoginReCaptchaConfig.java index 1b1832ea73..7be47a67a9 100644 --- a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/connector/recaptcha/SSOLoginReCaptchaConfig.java +++ b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/connector/recaptcha/SSOLoginReCaptchaConfig.java @@ -38,6 +38,8 @@ import org.wso2.carbon.identity.governance.IdentityGovernanceException; import org.wso2.carbon.identity.governance.IdentityGovernanceService; import org.wso2.carbon.identity.governance.common.IdentityConnectorConfig; +import org.wso2.carbon.identity.multi.attribute.login.mgt.ResolvedUserResult; +import org.wso2.carbon.user.core.util.UserCoreUtil; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import java.util.HashMap; @@ -121,6 +123,15 @@ public CaptchaPreValidationResponse preValidate(ServletRequest servletRequest, S AuthenticationContext context = FrameworkUtils.getAuthenticationContextFromCache(sessionDataKey); String tenantDomain = getTenant(context, username); + // Resolve the username from the multi attribute login service when the multi attribute login is enabled. + ResolvedUserResult resolvedUserResult = FrameworkUtils.processMultiAttributeLoginIdentification( + MultitenantUtils.getTenantAwareUsername(username), tenantDomain); + if (resolvedUserResult != null && ResolvedUserResult.UserResolvedStatus.SUCCESS. + equals(resolvedUserResult.getResolvedStatus())) { + username = UserCoreUtil.addTenantDomainToEntry(resolvedUserResult.getUser().getUsername(), + tenantDomain); + } + // Verify whether recaptcha is enforced always for basic authentication. Property[] connectorConfigs = null; try {