From 18b1658747520cb400f6dd084eee58ba31534a73 Mon Sep 17 00:00:00 2001 From: Thumimku Date: Fri, 4 Aug 2023 13:30:45 +0530 Subject: [PATCH 01/15] disable password policy validation handler --- .../constants/PasswordPolicyConstants.java | 1 + .../IdentityPasswordPolicyServiceComponent.java | 14 ++++++++++---- .../IdentityPasswordPolicyServiceDataHolder.java | 16 ++++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/components/org.wso2.carbon.identity.password.policy/src/main/java/org/wso2/carbon/identity/password/policy/constants/PasswordPolicyConstants.java b/components/org.wso2.carbon.identity.password.policy/src/main/java/org/wso2/carbon/identity/password/policy/constants/PasswordPolicyConstants.java index 7bfbe740fc..25ce59e216 100644 --- a/components/org.wso2.carbon.identity.password.policy/src/main/java/org/wso2/carbon/identity/password/policy/constants/PasswordPolicyConstants.java +++ b/components/org.wso2.carbon.identity.password.policy/src/main/java/org/wso2/carbon/identity/password/policy/constants/PasswordPolicyConstants.java @@ -26,6 +26,7 @@ public class PasswordPolicyConstants { public static final String PW_POLICY_LENGTH_CLASS = "passwordPolicy.class.PasswordLengthPolicy"; public static final String PW_POLICY_NAME_CLASS = "passwordPolicy.class.PasswordNamePolicy"; public static final String PW_POLICY_PATTERN_CLASS = "passwordPolicy.class.PasswordPatternPolicy"; + public static final String PW_POLICY_HANDLER_ENABLED = "PasswordPolicy.PasswordPolicyValidationHandler.Enable"; public enum ErrorMessages { diff --git a/components/org.wso2.carbon.identity.password.policy/src/main/java/org/wso2/carbon/identity/password/policy/internal/IdentityPasswordPolicyServiceComponent.java b/components/org.wso2.carbon.identity.password.policy/src/main/java/org/wso2/carbon/identity/password/policy/internal/IdentityPasswordPolicyServiceComponent.java index abacfe7821..6edaba1956 100644 --- a/components/org.wso2.carbon.identity.password.policy/src/main/java/org/wso2/carbon/identity/password/policy/internal/IdentityPasswordPolicyServiceComponent.java +++ b/components/org.wso2.carbon.identity.password.policy/src/main/java/org/wso2/carbon/identity/password/policy/internal/IdentityPasswordPolicyServiceComponent.java @@ -43,10 +43,16 @@ protected void activate(ComponentContext context) { if (log.isDebugEnabled()) { log.debug("Password Policy Service component is enabled"); } - BundleContext bundleContext = context.getBundleContext(); - IdentityPasswordPolicyServiceDataHolder.getInstance().setBundleContext(bundleContext); - PasswordPolicyValidationHandler handler = new PasswordPolicyValidationHandler(); - context.getBundleContext().registerService(AbstractEventHandler.class.getName(), handler, null); + if (IdentityPasswordPolicyServiceDataHolder.getInstance().isPasswordPolicyHandlerEnabled()) { + BundleContext bundleContext = context.getBundleContext(); + IdentityPasswordPolicyServiceDataHolder.getInstance().setBundleContext(bundleContext); + PasswordPolicyValidationHandler handler = new PasswordPolicyValidationHandler(); + context.getBundleContext().registerService(AbstractEventHandler.class.getName(), handler, null); + } else { + if (log.isDebugEnabled()) { + log.debug("Password Policy Validation Handler is disabled."); + } + } } catch (Exception e) { log.error("Error while activating password policy component.", e); } diff --git a/components/org.wso2.carbon.identity.password.policy/src/main/java/org/wso2/carbon/identity/password/policy/internal/IdentityPasswordPolicyServiceDataHolder.java b/components/org.wso2.carbon.identity.password.policy/src/main/java/org/wso2/carbon/identity/password/policy/internal/IdentityPasswordPolicyServiceDataHolder.java index db9b22894a..79780c7cc0 100644 --- a/components/org.wso2.carbon.identity.password.policy/src/main/java/org/wso2/carbon/identity/password/policy/internal/IdentityPasswordPolicyServiceDataHolder.java +++ b/components/org.wso2.carbon.identity.password.policy/src/main/java/org/wso2/carbon/identity/password/policy/internal/IdentityPasswordPolicyServiceDataHolder.java @@ -16,8 +16,11 @@ package org.wso2.carbon.identity.password.policy.internal; +import org.apache.commons.lang.StringUtils; import org.osgi.framework.BundleContext; +import org.wso2.carbon.identity.core.util.IdentityUtil; import org.wso2.carbon.identity.governance.IdentityGovernanceService; +import org.wso2.carbon.identity.password.policy.constants.PasswordPolicyConstants; public class IdentityPasswordPolicyServiceDataHolder { @@ -33,6 +36,19 @@ public static IdentityPasswordPolicyServiceDataHolder getInstance() { return instance; } + public boolean isPasswordPolicyHandlerEnabled() { + + String passwordPolicyHandlerEnabled = + IdentityUtil.getProperty(PasswordPolicyConstants.PW_POLICY_HANDLER_ENABLED); + if (StringUtils.isBlank(passwordPolicyHandlerEnabled)) { + /* + This indicates config not in the identity.xml. In that case, we need to maintain default behaviour. + */ + return false; + } + return Boolean.parseBoolean(passwordPolicyHandlerEnabled); + } + public IdentityGovernanceService getIdentityGovernanceService() { return identityGovernanceService; } From 1868674538bdecff4377e720436a8ee37dceac42 Mon Sep 17 00:00:00 2001 From: AwesomeNipun Date: Mon, 10 Apr 2023 09:25:03 +0530 Subject: [PATCH 02/15] add recaptcha-enterprise support --- .../endpoint/dto/ReCaptchaPropertiesDTO.java | 28 ++++++-- .../recovery/endpoint/Utils/RecoveryUtil.java | 64 +++++++++++++++---- .../endpoint/impl/CaptchaApiServiceImpl.java | 44 ++++++++++--- .../main/resources/api.identity.recovery.yaml | 2 + .../captcha/internal/CaptchaDataHolder.java | 36 +++++++++++ .../captcha/util/CaptchaConstants.java | 6 ++ 6 files changed, 155 insertions(+), 25 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/gen/java/org/wso2/carbon/identity/recovery/endpoint/dto/ReCaptchaPropertiesDTO.java b/components/org.wso2.carbon.identity.api.user.recovery/src/gen/java/org/wso2/carbon/identity/recovery/endpoint/dto/ReCaptchaPropertiesDTO.java index 1e3ca858cd..36c9599445 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/gen/java/org/wso2/carbon/identity/recovery/endpoint/dto/ReCaptchaPropertiesDTO.java +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/gen/java/org/wso2/carbon/identity/recovery/endpoint/dto/ReCaptchaPropertiesDTO.java @@ -14,8 +14,11 @@ public class ReCaptchaPropertiesDTO { private Boolean reCaptchaEnabled = null; - - + + + private Boolean reCaptchaEnterpriseEnabled = null; + + private String reCaptchaKey = null; @@ -33,7 +36,19 @@ public void setReCaptchaEnabled(Boolean reCaptchaEnabled) { this.reCaptchaEnabled = reCaptchaEnabled; } - + + /** + **/ + @ApiModelProperty(value = "") + @JsonProperty("reCaptchaEnterpriseEnabled") + public Boolean getReCaptchaEnterpriseEnabled() { + return reCaptchaEnterpriseEnabled; + } + public void setReCaptchaEnterpriseEnabled(Boolean reCaptchaEnterpriseEnabled) { + this.reCaptchaEnterpriseEnabled = reCaptchaEnterpriseEnabled; + } + + /** **/ @ApiModelProperty(value = "") @@ -45,7 +60,7 @@ public void setReCaptchaKey(String reCaptchaKey) { this.reCaptchaKey = reCaptchaKey; } - + /** **/ @ApiModelProperty(value = "") @@ -57,14 +72,15 @@ public void setReCaptchaAPI(String reCaptchaAPI) { this.reCaptchaAPI = reCaptchaAPI; } - + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ReCaptchaPropertiesDTO {\n"); - + sb.append(" reCaptchaEnabled: ").append(reCaptchaEnabled).append("\n"); + sb.append(" reCaptchaEnterpriseEnabled: ").append(reCaptchaEnterpriseEnabled).append("\n"); sb.append(" reCaptchaKey: ").append(reCaptchaKey).append("\n"); sb.append(" reCaptchaAPI: ").append(reCaptchaAPI).append("\n"); sb.append("}\n"); diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java index fd90f2821d..1b0b23ebcf 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java @@ -6,6 +6,7 @@ import org.apache.http.HttpResponse; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.message.BasicNameValuePair; @@ -453,6 +454,9 @@ private static Properties validateCaptchaConfigs(Properties properties) { boolean reCaptchaEnabled = Boolean.valueOf(properties.getProperty(CaptchaConstants.RE_CAPTCHA_ENABLED)); + boolean reCaptchaEnterpriseEnabled = Boolean.valueOf(properties.getProperty(CaptchaConstants + .RE_CAPTCHA_ENTERPRISE_ENABLED)); + if (reCaptchaEnabled && StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_SITE_KEY))) { RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants.RE_CAPTCHA_SITE_KEY), Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); @@ -461,7 +465,8 @@ private static Properties validateCaptchaConfigs(Properties properties) { RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants.RE_CAPTCHA_API_URL), Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); } - if (reCaptchaEnabled && StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_SECRET_KEY))) { + if (reCaptchaEnabled && !reCaptchaEnterpriseEnabled && + StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_SECRET_KEY))) { RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants.RE_CAPTCHA_SECRET_KEY), Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); } @@ -469,6 +474,17 @@ private static Properties validateCaptchaConfigs(Properties properties) { RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants.RE_CAPTCHA_VERIFY_URL), Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); } + + if (reCaptchaEnabled && reCaptchaEnterpriseEnabled && + StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_API_KEY))) { + RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants + .RE_CAPTCHA_API_KEY), Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + } + if (reCaptchaEnabled && reCaptchaEnterpriseEnabled && + StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_PROJECT_ID))) { + RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants + .RE_CAPTCHA_PROJECT_ID), Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + } return properties; } @@ -483,19 +499,45 @@ public static HttpResponse makeCaptchaVerificationHttpRequest(ReCaptchaResponseT Properties properties) { HttpResponse response = null; - String reCaptchaSecretKey = properties.getProperty(CaptchaConstants.RE_CAPTCHA_SECRET_KEY); String reCaptchaVerifyUrl = properties.getProperty(CaptchaConstants.RE_CAPTCHA_VERIFY_URL); + boolean reCaptchaEnterpriseEnabled = + Boolean.valueOf(properties.getProperty(CaptchaConstants.RE_CAPTCHA_ENTERPRISE_ENABLED)); CloseableHttpClient httpclient = HttpClientBuilder.create().useSystemProperties().build(); - HttpPost httppost = new HttpPost(reCaptchaVerifyUrl); - List params = Arrays.asList(new BasicNameValuePair("secret", reCaptchaSecretKey), - new BasicNameValuePair("response", reCaptchaResponse.getToken())); - httppost.setEntity(new UrlEncodedFormEntity(params, StandardCharsets.UTF_8)); + HttpPost httppost; - try { - response = httpclient.execute(httppost); - } catch (IOException e) { - RecoveryUtil.handleBadRequest(String.format("Unable to get the verification response : %s", e.getMessage()), - Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + if (!reCaptchaEnterpriseEnabled){ // for Recaptcha V2 and V3 + String reCaptchaSecretKey = properties.getProperty(CaptchaConstants.RE_CAPTCHA_SECRET_KEY); + + httppost = new HttpPost(reCaptchaVerifyUrl); + List params = Arrays.asList(new BasicNameValuePair("secret", reCaptchaSecretKey), + new BasicNameValuePair("response", reCaptchaResponse.getToken())); + httppost.setEntity(new UrlEncodedFormEntity(params, StandardCharsets.UTF_8)); + + try { + response = httpclient.execute(httppost); + } catch (IOException e) { + RecoveryUtil.handleBadRequest(String.format("Unable to get the verification response : %s", + e.getMessage()), Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + } + + } else{ // for Recaptcha Enterprise + String projectID = properties.getProperty(CaptchaConstants.RE_CAPTCHA_PROJECT_ID); + String APIKey = properties.getProperty(CaptchaConstants.RE_CAPTCHA_API_KEY); + String siteKey = properties.getProperty(CaptchaConstants.RE_CAPTCHA_SITE_KEY); + String verifyUrl = reCaptchaVerifyUrl + "/v1/projects/" + projectID + "/assessments?key=" + APIKey; + httppost = new HttpPost(verifyUrl); + httppost.setHeader("Content-Type", "application/json"); + String json = String.format("{ \"event\": { \"token\": \"%s\", \"siteKey\": \"%s\" } }", reCaptchaResponse, + siteKey); + StringEntity entity = new StringEntity(json, StandardCharsets.UTF_8); + httppost.setEntity(entity); + + try { + response = httpclient.execute(httppost); + } catch (IOException e) { + RecoveryUtil.handleBadRequest(String.format("Unable to get the verification response : %s", + e.getMessage()), Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + } } return response; } diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImpl.java b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImpl.java index 3171ccb798..0e3afef249 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImpl.java @@ -43,6 +43,7 @@ public class CaptchaApiServiceImpl extends CaptchaApiService { private static final String SUCCESS = "success"; + private static final String VALID = "valid"; private static final Log log = LogFactory.getLog(CaptchaApiServiceImpl.class); private final String RECAPTCHA = "ReCaptcha"; @@ -55,6 +56,8 @@ public Response getCaptcha(String captchaType, String recoveryType, String tenan Properties properties = RecoveryUtil.getValidatedCaptchaConfigs(); boolean reCaptchaEnabled = Boolean.valueOf(properties.getProperty(CaptchaConstants.RE_CAPTCHA_ENABLED)); + boolean reCaptchaEnterpriseEnabled = + Boolean.valueOf(properties.getProperty(CaptchaConstants.RE_CAPTCHA_ENTERPRISE_ENABLED)); boolean forcefullyEnabledRecaptchaForAllTenants = Boolean.valueOf(properties.getProperty(CaptchaConstants.FORCEFULLY_ENABLED_RECAPTCHA_FOR_ALL_TENANTS)); ReCaptchaPropertiesDTO reCaptchaPropertiesDTO = new ReCaptchaPropertiesDTO(); @@ -64,6 +67,7 @@ public Response getCaptcha(String captchaType, String recoveryType, String tenan reCaptchaPropertiesDTO.setReCaptchaEnabled(true); reCaptchaPropertiesDTO.setReCaptchaKey(properties.getProperty(CaptchaConstants.RE_CAPTCHA_SITE_KEY)); reCaptchaPropertiesDTO.setReCaptchaAPI(properties.getProperty(CaptchaConstants.RE_CAPTCHA_API_URL)); + reCaptchaPropertiesDTO.setReCaptchaEnterpriseEnabled(reCaptchaEnterpriseEnabled); return Response.ok(reCaptchaPropertiesDTO).build(); } else { reCaptchaPropertiesDTO.setReCaptchaEnabled(false); @@ -80,6 +84,8 @@ public Response verifyCaptcha(ReCaptchaResponseTokenDTO reCaptchaResponse, Strin Properties properties = RecoveryUtil.getValidatedCaptchaConfigs(); boolean reCaptchaEnabled = Boolean.valueOf(properties.getProperty(CaptchaConstants.RE_CAPTCHA_ENABLED)); + boolean reCaptchaEnterpriseEnabled = + Boolean.valueOf(properties.getProperty(CaptchaConstants.RE_CAPTCHA_ENTERPRISE_ENABLED)); if (!reCaptchaEnabled) { RecoveryUtil.handleBadRequest("ReCaptcha is disabled", Constants.INVALID); @@ -89,20 +95,42 @@ public Response verifyCaptcha(ReCaptchaResponseTokenDTO reCaptchaResponse, Strin HttpEntity entity = response.getEntity(); ReCaptchaVerificationResponseDTO reCaptchaVerificationResponseDTO = new ReCaptchaVerificationResponseDTO(); - try { + if (!reCaptchaEnterpriseEnabled) { + + try { + if (entity == null) { + RecoveryUtil.handleBadRequest("ReCaptcha verification response is not received.", + Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + } else { + try (InputStream in = entity.getContent()) { + JsonObject verificationResponse = new JsonParser().parse(IOUtils.toString(in)).getAsJsonObject(); + reCaptchaVerificationResponseDTO.setSuccess(verificationResponse.get(SUCCESS).getAsBoolean()); + } + } + } catch (IOException e) { + log.error("Unable to read the verification response.", e); + RecoveryUtil.handleBadRequest("Unable to read the verification response.", + Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + } + } else { + if (entity == null) { - RecoveryUtil.handleBadRequest("ReCaptcha verification response is not received.", + RecoveryUtil.handleBadRequest("ReCaptcha Enterprise verification response is not received.", Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); - } else { + } + + try { try (InputStream in = entity.getContent()) { JsonObject verificationResponse = new JsonParser().parse(IOUtils.toString(in)).getAsJsonObject(); - reCaptchaVerificationResponseDTO.setSuccess(verificationResponse.get(SUCCESS).getAsBoolean()); + JsonObject tokenProperties = verificationResponse.get("tokenProperties").getAsJsonObject(); + boolean success = tokenProperties.get(VALID).getAsBoolean(); + reCaptchaVerificationResponseDTO.setSuccess(success); } + } catch (IOException e) { + log.error("Unable to read the verification response.", e); + RecoveryUtil.handleBadRequest("Unable to read the verification response.", + Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); } - } catch (IOException e) { - log.error("Unable to read the verification response.", e); - RecoveryUtil.handleBadRequest("Unable to read the verification response.", - Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); } return Response.ok(reCaptchaVerificationResponseDTO).build(); } diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/main/resources/api.identity.recovery.yaml b/components/org.wso2.carbon.identity.api.user.recovery/src/main/resources/api.identity.recovery.yaml index f32bf762e4..1713ce4466 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/main/resources/api.identity.recovery.yaml +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/main/resources/api.identity.recovery.yaml @@ -790,6 +790,8 @@ definitions: properties: reCaptchaEnabled: type: boolean + reCaptchaEnterpriseEnabled: + type: boolean reCaptchaKey: type: string reCaptchaAPI: diff --git a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/internal/CaptchaDataHolder.java b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/internal/CaptchaDataHolder.java index 0ddf99ea64..57a6198930 100644 --- a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/internal/CaptchaDataHolder.java +++ b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/internal/CaptchaDataHolder.java @@ -37,6 +37,8 @@ public class CaptchaDataHolder { private boolean reCaptchaEnabled; + private boolean reCaptchaEnterpriseEnabled; + private String reCaptchaAPIUrl; private String reCaptchaVerifyUrl; @@ -45,6 +47,10 @@ public class CaptchaDataHolder { private String reCaptchaSecretKey; + private String reCaptchaAPIKey; + + private String reCaptchaProjectID; + private String reCaptchaErrorRedirectUrls; private String reCaptchaRequestWrapUrls; @@ -84,6 +90,36 @@ public void setReCaptchaEnabled(boolean reCaptchaEnabled) { this.reCaptchaEnabled = reCaptchaEnabled; } + public boolean isReCaptchaEnterpriseEnabled() { + + return reCaptchaEnterpriseEnabled; + } + + public void setReCaptchaEnterpriseEnabled(boolean reCaptchaEnterpriseEnabled) { + + this.reCaptchaEnterpriseEnabled = reCaptchaEnterpriseEnabled; + } + + public String getReCaptchaAPIKey() { + + return reCaptchaAPIKey; + } + + public void setReCaptchaAPIKey(String reCaptchaAPIKey) { + + this.reCaptchaAPIKey = reCaptchaAPIKey; + } + + public String getReCaptchaProjectID() { + + return reCaptchaProjectID; + } + + public void setReCaptchaProjectID(String reCaptchaProjectID) { + + this.reCaptchaProjectID = reCaptchaProjectID; + } + public String getReCaptchaAPIUrl() { return reCaptchaAPIUrl; } diff --git a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaConstants.java b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaConstants.java index 985ef64f7e..5becc00610 100644 --- a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaConstants.java +++ b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaConstants.java @@ -34,6 +34,8 @@ public class CaptchaConstants { public static final String RE_CAPTCHA_ENABLED = "recaptcha.enabled"; + public static final String RE_CAPTCHA_ENTERPRISE_ENABLED = "recaptcha.enterprise.enabled"; + public static final String FORCEFULLY_ENABLED_RECAPTCHA_FOR_ALL_TENANTS = "recaptcha" + ".forcefullyEnabledForAllTenants"; @@ -43,6 +45,10 @@ public class CaptchaConstants { public static final String RE_CAPTCHA_SITE_KEY = "recaptcha.site.key"; + public static final String RE_CAPTCHA_API_KEY = "recaptcha.api.key"; + + public static final String RE_CAPTCHA_PROJECT_ID = "recaptcha.project.id"; + public static final String RE_CAPTCHA_SECRET_KEY = "recaptcha.secret.key"; public static final String RE_CAPTCHA_REQUEST_WRAP_URLS = "recaptcha.request.wrap.urls"; From 14584576744f1b314639b1f7e231a641ae8858f7 Mon Sep 17 00:00:00 2001 From: AwesomeNipun Date: Tue, 25 Apr 2023 02:58:27 +0530 Subject: [PATCH 03/15] Refactor code --- .../recovery/endpoint/Utils/RecoveryUtil.java | 92 +++++++++---------- .../endpoint/impl/CaptchaApiServiceImpl.java | 43 +++++---- .../captcha/internal/CaptchaDataHolder.java | 12 --- .../captcha/util/CaptchaConstants.java | 4 +- .../conf/captcha-config.properties.j2 | 6 ++ 5 files changed, 73 insertions(+), 84 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java index 1b0b23ebcf..9796e0a597 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java @@ -457,33 +457,28 @@ private static Properties validateCaptchaConfigs(Properties properties) { boolean reCaptchaEnterpriseEnabled = Boolean.valueOf(properties.getProperty(CaptchaConstants .RE_CAPTCHA_ENTERPRISE_ENABLED)); - if (reCaptchaEnabled && StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_SITE_KEY))) { - RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants.RE_CAPTCHA_SITE_KEY), - Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); - } - if (StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_API_URL))) { - RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants.RE_CAPTCHA_API_URL), - Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); - } - if (reCaptchaEnabled && !reCaptchaEnterpriseEnabled && - StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_SECRET_KEY))) { - RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants.RE_CAPTCHA_SECRET_KEY), - Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); - } - if (StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_VERIFY_URL))) { - RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants.RE_CAPTCHA_VERIFY_URL), - Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); - } - - if (reCaptchaEnabled && reCaptchaEnterpriseEnabled && - StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_API_KEY))) { - RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants - .RE_CAPTCHA_API_KEY), Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); - } - if (reCaptchaEnabled && reCaptchaEnterpriseEnabled && - StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_PROJECT_ID))) { - RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants - .RE_CAPTCHA_PROJECT_ID), Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + if (reCaptchaEnabled || reCaptchaEnterpriseEnabled) { + if (StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_SITE_KEY))) { + RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants.RE_CAPTCHA_SITE_KEY), + Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + } + if (StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_API_URL))) { + RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants.RE_CAPTCHA_API_URL), + Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + } + if (StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_SECRET_KEY))) { + RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants.RE_CAPTCHA_SECRET_KEY), + Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + } + if (StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_VERIFY_URL))) { + RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants.RE_CAPTCHA_VERIFY_URL), + Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + } + if (reCaptchaEnterpriseEnabled && + StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_PROJECT_ID))) { + RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants + .RE_CAPTCHA_PROJECT_ID), Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + } } return properties; } @@ -503,37 +498,38 @@ public static HttpResponse makeCaptchaVerificationHttpRequest(ReCaptchaResponseT boolean reCaptchaEnterpriseEnabled = Boolean.valueOf(properties.getProperty(CaptchaConstants.RE_CAPTCHA_ENTERPRISE_ENABLED)); CloseableHttpClient httpclient = HttpClientBuilder.create().useSystemProperties().build(); - HttpPost httppost; + HttpPost httpPost; - if (!reCaptchaEnterpriseEnabled){ // for Recaptcha V2 and V3 - String reCaptchaSecretKey = properties.getProperty(CaptchaConstants.RE_CAPTCHA_SECRET_KEY); - - httppost = new HttpPost(reCaptchaVerifyUrl); - List params = Arrays.asList(new BasicNameValuePair("secret", reCaptchaSecretKey), - new BasicNameValuePair("response", reCaptchaResponse.getToken())); - httppost.setEntity(new UrlEncodedFormEntity(params, StandardCharsets.UTF_8)); + if (reCaptchaEnterpriseEnabled) { + // For ReCaptcha Enterprise. + String projectID = properties.getProperty(CaptchaConstants.RE_CAPTCHA_PROJECT_ID); + String secretKey = properties.getProperty(CaptchaConstants.RE_CAPTCHA_SECRET_KEY); + String siteKey = properties.getProperty(CaptchaConstants.RE_CAPTCHA_SITE_KEY); + String verifyUrl = reCaptchaVerifyUrl + "/v1/projects/" + projectID + "/assessments?key=" + secretKey; + httpPost = new HttpPost(verifyUrl); + httpPost.setHeader(Constants.HEADER_CONTENT_TYPE, Constants.APPLICATION_JSON); + String json = String.format("{ \"event\": { \"token\": \"%s\", \"siteKey\": \"%s\" } }", reCaptchaResponse, + siteKey); + StringEntity entity = new StringEntity(json, StandardCharsets.UTF_8); + httpPost.setEntity(entity); try { - response = httpclient.execute(httppost); + response = httpclient.execute(httpPost); } catch (IOException e) { RecoveryUtil.handleBadRequest(String.format("Unable to get the verification response : %s", e.getMessage()), Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); } + } else { + // For ReCaptcha v2 and v3. + String reCaptchaSecretKey = properties.getProperty(CaptchaConstants.RE_CAPTCHA_SECRET_KEY); - } else{ // for Recaptcha Enterprise - String projectID = properties.getProperty(CaptchaConstants.RE_CAPTCHA_PROJECT_ID); - String APIKey = properties.getProperty(CaptchaConstants.RE_CAPTCHA_API_KEY); - String siteKey = properties.getProperty(CaptchaConstants.RE_CAPTCHA_SITE_KEY); - String verifyUrl = reCaptchaVerifyUrl + "/v1/projects/" + projectID + "/assessments?key=" + APIKey; - httppost = new HttpPost(verifyUrl); - httppost.setHeader("Content-Type", "application/json"); - String json = String.format("{ \"event\": { \"token\": \"%s\", \"siteKey\": \"%s\" } }", reCaptchaResponse, - siteKey); - StringEntity entity = new StringEntity(json, StandardCharsets.UTF_8); - httppost.setEntity(entity); + httpPost = new HttpPost(reCaptchaVerifyUrl); + List params = Arrays.asList(new BasicNameValuePair("secret", reCaptchaSecretKey), + new BasicNameValuePair("response", reCaptchaResponse.getToken())); + httpPost.setEntity(new UrlEncodedFormEntity(params, StandardCharsets.UTF_8)); try { - response = httpclient.execute(httppost); + response = httpclient.execute(httpPost); } catch (IOException e) { RecoveryUtil.handleBadRequest(String.format("Unable to get the verification response : %s", e.getMessage()), Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImpl.java b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImpl.java index 0e3afef249..f95c3e46ae 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImpl.java @@ -62,15 +62,16 @@ public Response getCaptcha(String captchaType, String recoveryType, String tenan Boolean.valueOf(properties.getProperty(CaptchaConstants.FORCEFULLY_ENABLED_RECAPTCHA_FOR_ALL_TENANTS)); ReCaptchaPropertiesDTO reCaptchaPropertiesDTO = new ReCaptchaPropertiesDTO(); - if (reCaptchaEnabled && (forcefullyEnabledRecaptchaForAllTenants || + if ((reCaptchaEnabled || reCaptchaEnterpriseEnabled) && (forcefullyEnabledRecaptchaForAllTenants || RecoveryUtil.checkCaptchaEnabledResidentIdpConfiguration(tenantDomain, recoveryType))) { - reCaptchaPropertiesDTO.setReCaptchaEnabled(true); + reCaptchaPropertiesDTO.setReCaptchaEnabled(reCaptchaEnabled); reCaptchaPropertiesDTO.setReCaptchaKey(properties.getProperty(CaptchaConstants.RE_CAPTCHA_SITE_KEY)); reCaptchaPropertiesDTO.setReCaptchaAPI(properties.getProperty(CaptchaConstants.RE_CAPTCHA_API_URL)); reCaptchaPropertiesDTO.setReCaptchaEnterpriseEnabled(reCaptchaEnterpriseEnabled); return Response.ok(reCaptchaPropertiesDTO).build(); } else { reCaptchaPropertiesDTO.setReCaptchaEnabled(false); + reCaptchaPropertiesDTO.setReCaptchaEnterpriseEnabled(false); return Response.ok(reCaptchaPropertiesDTO).build(); } } @@ -87,7 +88,7 @@ public Response verifyCaptcha(ReCaptchaResponseTokenDTO reCaptchaResponse, Strin boolean reCaptchaEnterpriseEnabled = Boolean.valueOf(properties.getProperty(CaptchaConstants.RE_CAPTCHA_ENTERPRISE_ENABLED)); - if (!reCaptchaEnabled) { + if (!reCaptchaEnabled && !reCaptchaEnterpriseEnabled) { RecoveryUtil.handleBadRequest("ReCaptcha is disabled", Constants.INVALID); } @@ -95,17 +96,18 @@ public Response verifyCaptcha(ReCaptchaResponseTokenDTO reCaptchaResponse, Strin HttpEntity entity = response.getEntity(); ReCaptchaVerificationResponseDTO reCaptchaVerificationResponseDTO = new ReCaptchaVerificationResponseDTO(); - if (!reCaptchaEnterpriseEnabled) { - + if (reCaptchaEnterpriseEnabled) { + // For ReCaptcha Enterprise. + if (entity == null) { + RecoveryUtil.handleBadRequest("ReCaptcha Enterprise verification response is not received.", + Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + } try { - if (entity == null) { - RecoveryUtil.handleBadRequest("ReCaptcha verification response is not received.", - Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); - } else { - try (InputStream in = entity.getContent()) { - JsonObject verificationResponse = new JsonParser().parse(IOUtils.toString(in)).getAsJsonObject(); - reCaptchaVerificationResponseDTO.setSuccess(verificationResponse.get(SUCCESS).getAsBoolean()); - } + try (InputStream in = entity.getContent()) { + JsonObject verificationResponse = new JsonParser().parse(IOUtils.toString(in)).getAsJsonObject(); + JsonObject tokenProperties = verificationResponse.get("tokenProperties").getAsJsonObject(); + boolean success = tokenProperties.get(VALID).getAsBoolean(); + reCaptchaVerificationResponseDTO.setSuccess(success); } } catch (IOException e) { log.error("Unable to read the verification response.", e); @@ -113,18 +115,15 @@ public Response verifyCaptcha(ReCaptchaResponseTokenDTO reCaptchaResponse, Strin Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); } } else { - - if (entity == null) { - RecoveryUtil.handleBadRequest("ReCaptcha Enterprise verification response is not received.", - Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); - } - + // For ReCaptcha v2 and v3. try { + if (entity == null) { + RecoveryUtil.handleBadRequest("ReCaptcha verification response is not received.", + Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + } try (InputStream in = entity.getContent()) { JsonObject verificationResponse = new JsonParser().parse(IOUtils.toString(in)).getAsJsonObject(); - JsonObject tokenProperties = verificationResponse.get("tokenProperties").getAsJsonObject(); - boolean success = tokenProperties.get(VALID).getAsBoolean(); - reCaptchaVerificationResponseDTO.setSuccess(success); + reCaptchaVerificationResponseDTO.setSuccess(verificationResponse.get(SUCCESS).getAsBoolean()); } } catch (IOException e) { log.error("Unable to read the verification response.", e); diff --git a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/internal/CaptchaDataHolder.java b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/internal/CaptchaDataHolder.java index 57a6198930..f55f563301 100644 --- a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/internal/CaptchaDataHolder.java +++ b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/internal/CaptchaDataHolder.java @@ -47,8 +47,6 @@ public class CaptchaDataHolder { private String reCaptchaSecretKey; - private String reCaptchaAPIKey; - private String reCaptchaProjectID; private String reCaptchaErrorRedirectUrls; @@ -100,16 +98,6 @@ public void setReCaptchaEnterpriseEnabled(boolean reCaptchaEnterpriseEnabled) { this.reCaptchaEnterpriseEnabled = reCaptchaEnterpriseEnabled; } - public String getReCaptchaAPIKey() { - - return reCaptchaAPIKey; - } - - public void setReCaptchaAPIKey(String reCaptchaAPIKey) { - - this.reCaptchaAPIKey = reCaptchaAPIKey; - } - public String getReCaptchaProjectID() { return reCaptchaProjectID; diff --git a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaConstants.java b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaConstants.java index 5becc00610..2e1a2fbaa9 100644 --- a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaConstants.java +++ b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaConstants.java @@ -45,8 +45,6 @@ public class CaptchaConstants { public static final String RE_CAPTCHA_SITE_KEY = "recaptcha.site.key"; - public static final String RE_CAPTCHA_API_KEY = "recaptcha.api.key"; - public static final String RE_CAPTCHA_PROJECT_ID = "recaptcha.project.id"; public static final String RE_CAPTCHA_SECRET_KEY = "recaptcha.secret.key"; @@ -73,6 +71,8 @@ public class CaptchaConstants { public static final String RECAPTCHA_FAIL_MSG_KEY = "recaptcha.fail.message"; public static final String TRUE = "true"; + public static final String CAPTCHA_VALID = "valid"; + // Default value for threshold for score in reCAPTCHA v3. public static final double CAPTCHA_V3_DEFAULT_THRESHOLD = 0.5; diff --git a/features/org.wso2.carbon.identity.captcha.server.feature/resources/conf/captcha-config.properties.j2 b/features/org.wso2.carbon.identity.captcha.server.feature/resources/conf/captcha-config.properties.j2 index 45078ab9ef..88ec472a13 100644 --- a/features/org.wso2.carbon.identity.captcha.server.feature/resources/conf/captcha-config.properties.j2 +++ b/features/org.wso2.carbon.identity.captcha.server.feature/resources/conf/captcha-config.properties.j2 @@ -21,6 +21,9 @@ # Enable Google reCAPTCHA recaptcha.enabled={{recaptcha.enabled}} +# Enable Google reCAPTCHA Enterprise +recaptcha.enterprise.enabled={{recaptcha.enterprise_enabled}} + # Forcefully enable Google reCAPTCHA for all tenants recaptcha.forcefullyEnabledForAllTenants={{recaptcha.forcefully_enabled_for_all_tenants}} @@ -36,6 +39,9 @@ recaptcha.site.key={{recaptcha.site_key}} # reCaptcha secret key recaptcha.secret.key={{recaptcha.secret_key}} +# reCaptcha Enterprise project id +recaptcha.project.id={{recaptcha.project_id}} + # login.do URL paths {% if recaptcha.redirect_urls is defined %} recaptcha.failed.redirect.urls={{recaptcha.redirect_urls}} From 38f5ecdf4ee6d35166c62561784054aae9f661c6 Mon Sep 17 00:00:00 2001 From: AwesomeNipun Date: Mon, 29 May 2023 09:48:32 +0530 Subject: [PATCH 04/15] Refactor code --- .../identity/recovery/endpoint/Utils/RecoveryUtil.java | 9 ++++----- .../recovery/endpoint/impl/CaptchaApiServiceImpl.java | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java index 9796e0a597..a6f34da27d 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java @@ -457,7 +457,7 @@ private static Properties validateCaptchaConfigs(Properties properties) { boolean reCaptchaEnterpriseEnabled = Boolean.valueOf(properties.getProperty(CaptchaConstants .RE_CAPTCHA_ENTERPRISE_ENABLED)); - if (reCaptchaEnabled || reCaptchaEnterpriseEnabled) { + if (reCaptchaEnabled) { if (StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_SITE_KEY))) { RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants.RE_CAPTCHA_SITE_KEY), Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); @@ -495,6 +495,7 @@ public static HttpResponse makeCaptchaVerificationHttpRequest(ReCaptchaResponseT HttpResponse response = null; String reCaptchaVerifyUrl = properties.getProperty(CaptchaConstants.RE_CAPTCHA_VERIFY_URL); + String reCaptchaSecretKey = properties.getProperty(CaptchaConstants.RE_CAPTCHA_SECRET_KEY); boolean reCaptchaEnterpriseEnabled = Boolean.valueOf(properties.getProperty(CaptchaConstants.RE_CAPTCHA_ENTERPRISE_ENABLED)); CloseableHttpClient httpclient = HttpClientBuilder.create().useSystemProperties().build(); @@ -503,9 +504,9 @@ public static HttpResponse makeCaptchaVerificationHttpRequest(ReCaptchaResponseT if (reCaptchaEnterpriseEnabled) { // For ReCaptcha Enterprise. String projectID = properties.getProperty(CaptchaConstants.RE_CAPTCHA_PROJECT_ID); - String secretKey = properties.getProperty(CaptchaConstants.RE_CAPTCHA_SECRET_KEY); String siteKey = properties.getProperty(CaptchaConstants.RE_CAPTCHA_SITE_KEY); - String verifyUrl = reCaptchaVerifyUrl + "/v1/projects/" + projectID + "/assessments?key=" + secretKey; + String verifyUrl = reCaptchaVerifyUrl + "/v1/projects/" + projectID + + "/assessments?key=" + reCaptchaSecretKey; httpPost = new HttpPost(verifyUrl); httpPost.setHeader(Constants.HEADER_CONTENT_TYPE, Constants.APPLICATION_JSON); String json = String.format("{ \"event\": { \"token\": \"%s\", \"siteKey\": \"%s\" } }", reCaptchaResponse, @@ -521,8 +522,6 @@ public static HttpResponse makeCaptchaVerificationHttpRequest(ReCaptchaResponseT } } else { // For ReCaptcha v2 and v3. - String reCaptchaSecretKey = properties.getProperty(CaptchaConstants.RE_CAPTCHA_SECRET_KEY); - httpPost = new HttpPost(reCaptchaVerifyUrl); List params = Arrays.asList(new BasicNameValuePair("secret", reCaptchaSecretKey), new BasicNameValuePair("response", reCaptchaResponse.getToken())); diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImpl.java b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImpl.java index f95c3e46ae..d04b087d8a 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImpl.java @@ -62,7 +62,7 @@ public Response getCaptcha(String captchaType, String recoveryType, String tenan Boolean.valueOf(properties.getProperty(CaptchaConstants.FORCEFULLY_ENABLED_RECAPTCHA_FOR_ALL_TENANTS)); ReCaptchaPropertiesDTO reCaptchaPropertiesDTO = new ReCaptchaPropertiesDTO(); - if ((reCaptchaEnabled || reCaptchaEnterpriseEnabled) && (forcefullyEnabledRecaptchaForAllTenants || + if (reCaptchaEnabled && (forcefullyEnabledRecaptchaForAllTenants || RecoveryUtil.checkCaptchaEnabledResidentIdpConfiguration(tenantDomain, recoveryType))) { reCaptchaPropertiesDTO.setReCaptchaEnabled(reCaptchaEnabled); reCaptchaPropertiesDTO.setReCaptchaKey(properties.getProperty(CaptchaConstants.RE_CAPTCHA_SITE_KEY)); @@ -88,7 +88,7 @@ public Response verifyCaptcha(ReCaptchaResponseTokenDTO reCaptchaResponse, Strin boolean reCaptchaEnterpriseEnabled = Boolean.valueOf(properties.getProperty(CaptchaConstants.RE_CAPTCHA_ENTERPRISE_ENABLED)); - if (!reCaptchaEnabled && !reCaptchaEnterpriseEnabled) { + if (!reCaptchaEnabled) { RecoveryUtil.handleBadRequest("ReCaptcha is disabled", Constants.INVALID); } From afdbd30c4f597c3ef8dc3be176b4b197b892ab27 Mon Sep 17 00:00:00 2001 From: AwesomeNipun Date: Mon, 5 Jun 2023 10:10:41 +0530 Subject: [PATCH 05/15] Change code logic using reCaptcha type --- .../endpoint/dto/ReCaptchaPropertiesDTO.java | 26 ++--- .../recovery/endpoint/Utils/RecoveryUtil.java | 95 +++++++------------ .../endpoint/impl/CaptchaApiServiceImpl.java | 51 +++++----- .../main/resources/api.identity.recovery.yaml | 4 +- .../conf/identity/captcha-config.properties | 3 + .../captcha/internal/CaptchaDataHolder.java | 10 +- .../captcha/util/CaptchaConstants.java | 8 +- .../conf/captcha-config.properties.j2 | 4 +- 8 files changed, 89 insertions(+), 112 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/gen/java/org/wso2/carbon/identity/recovery/endpoint/dto/ReCaptchaPropertiesDTO.java b/components/org.wso2.carbon.identity.api.user.recovery/src/gen/java/org/wso2/carbon/identity/recovery/endpoint/dto/ReCaptchaPropertiesDTO.java index 36c9599445..40543abfe5 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/gen/java/org/wso2/carbon/identity/recovery/endpoint/dto/ReCaptchaPropertiesDTO.java +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/gen/java/org/wso2/carbon/identity/recovery/endpoint/dto/ReCaptchaPropertiesDTO.java @@ -10,21 +10,21 @@ @ApiModel(description = "") public class ReCaptchaPropertiesDTO { - - - + + + private Boolean reCaptchaEnabled = null; - private Boolean reCaptchaEnterpriseEnabled = null; + private String reCaptchaType = null; private String reCaptchaKey = null; - - + + private String reCaptchaAPI = null; - + /** **/ @ApiModelProperty(value = "") @@ -40,12 +40,12 @@ public void setReCaptchaEnabled(Boolean reCaptchaEnabled) { /** **/ @ApiModelProperty(value = "") - @JsonProperty("reCaptchaEnterpriseEnabled") - public Boolean getReCaptchaEnterpriseEnabled() { - return reCaptchaEnterpriseEnabled; + @JsonProperty("reCaptchaType") + public String getReCaptchaType() { + return reCaptchaType; } - public void setReCaptchaEnterpriseEnabled(Boolean reCaptchaEnterpriseEnabled) { - this.reCaptchaEnterpriseEnabled = reCaptchaEnterpriseEnabled; + public void setReCaptchaType(String reCaptchaType) { + this.reCaptchaType = reCaptchaType; } @@ -80,7 +80,7 @@ public String toString() { sb.append("class ReCaptchaPropertiesDTO {\n"); sb.append(" reCaptchaEnabled: ").append(reCaptchaEnabled).append("\n"); - sb.append(" reCaptchaEnterpriseEnabled: ").append(reCaptchaEnterpriseEnabled).append("\n"); + sb.append(" reCaptchaEnterpriseEnabled: ").append(reCaptchaType).append("\n"); sb.append(" reCaptchaKey: ").append(reCaptchaKey).append("\n"); sb.append(" reCaptchaAPI: ").append(reCaptchaAPI).append("\n"); sb.append("}\n"); diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java index a6f34da27d..dc20efe75c 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java @@ -6,7 +6,6 @@ import org.apache.http.HttpResponse; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.message.BasicNameValuePair; @@ -453,32 +452,28 @@ public static Properties getValidatedCaptchaConfigs() { private static Properties validateCaptchaConfigs(Properties properties) { boolean reCaptchaEnabled = Boolean.valueOf(properties.getProperty(CaptchaConstants.RE_CAPTCHA_ENABLED)); + String reCaptchaType = properties.getProperty(CaptchaConstants.RE_CAPTCHA_TYPE); - boolean reCaptchaEnterpriseEnabled = Boolean.valueOf(properties.getProperty(CaptchaConstants - .RE_CAPTCHA_ENTERPRISE_ENABLED)); - - if (reCaptchaEnabled) { - if (StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_SITE_KEY))) { - RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants.RE_CAPTCHA_SITE_KEY), - Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); - } - if (StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_API_URL))) { - RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants.RE_CAPTCHA_API_URL), - Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); - } - if (StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_SECRET_KEY))) { - RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants.RE_CAPTCHA_SECRET_KEY), - Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); - } - if (StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_VERIFY_URL))) { - RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants.RE_CAPTCHA_VERIFY_URL), - Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); - } - if (reCaptchaEnterpriseEnabled && - StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_PROJECT_ID))) { - RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants - .RE_CAPTCHA_PROJECT_ID), Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); - } + if (reCaptchaEnabled && StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_SITE_KEY))) { + RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants.RE_CAPTCHA_SITE_KEY), + Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + } + if (StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_API_URL))) { + RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants.RE_CAPTCHA_API_URL), + Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + } + if (reCaptchaEnabled && StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_SECRET_KEY))) { + RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants.RE_CAPTCHA_SECRET_KEY), + Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + } + if (StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_VERIFY_URL))) { + RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants.RE_CAPTCHA_VERIFY_URL), + Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + } + if (!StringUtils.isBlank(reCaptchaType) && reCaptchaType.equals(CaptchaConstants.RE_CAPTCHA_TYPE_ENTERPRISE) && + StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_PROJECT_ID))) { + RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants + .RE_CAPTCHA_PROJECT_ID), Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); } return properties; } @@ -494,45 +489,19 @@ public static HttpResponse makeCaptchaVerificationHttpRequest(ReCaptchaResponseT Properties properties) { HttpResponse response = null; - String reCaptchaVerifyUrl = properties.getProperty(CaptchaConstants.RE_CAPTCHA_VERIFY_URL); String reCaptchaSecretKey = properties.getProperty(CaptchaConstants.RE_CAPTCHA_SECRET_KEY); - boolean reCaptchaEnterpriseEnabled = - Boolean.valueOf(properties.getProperty(CaptchaConstants.RE_CAPTCHA_ENTERPRISE_ENABLED)); + String reCaptchaVerifyUrl = properties.getProperty(CaptchaConstants.RE_CAPTCHA_VERIFY_URL); CloseableHttpClient httpclient = HttpClientBuilder.create().useSystemProperties().build(); - HttpPost httpPost; - - if (reCaptchaEnterpriseEnabled) { - // For ReCaptcha Enterprise. - String projectID = properties.getProperty(CaptchaConstants.RE_CAPTCHA_PROJECT_ID); - String siteKey = properties.getProperty(CaptchaConstants.RE_CAPTCHA_SITE_KEY); - String verifyUrl = reCaptchaVerifyUrl + "/v1/projects/" + projectID + - "/assessments?key=" + reCaptchaSecretKey; - httpPost = new HttpPost(verifyUrl); - httpPost.setHeader(Constants.HEADER_CONTENT_TYPE, Constants.APPLICATION_JSON); - String json = String.format("{ \"event\": { \"token\": \"%s\", \"siteKey\": \"%s\" } }", reCaptchaResponse, - siteKey); - StringEntity entity = new StringEntity(json, StandardCharsets.UTF_8); - httpPost.setEntity(entity); - - try { - response = httpclient.execute(httpPost); - } catch (IOException e) { - RecoveryUtil.handleBadRequest(String.format("Unable to get the verification response : %s", - e.getMessage()), Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); - } - } else { - // For ReCaptcha v2 and v3. - httpPost = new HttpPost(reCaptchaVerifyUrl); - List params = Arrays.asList(new BasicNameValuePair("secret", reCaptchaSecretKey), - new BasicNameValuePair("response", reCaptchaResponse.getToken())); - httpPost.setEntity(new UrlEncodedFormEntity(params, StandardCharsets.UTF_8)); - - try { - response = httpclient.execute(httpPost); - } catch (IOException e) { - RecoveryUtil.handleBadRequest(String.format("Unable to get the verification response : %s", - e.getMessage()), Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); - } + HttpPost httppost = new HttpPost(reCaptchaVerifyUrl); + List params = Arrays.asList(new BasicNameValuePair("secret", reCaptchaSecretKey), + new BasicNameValuePair("response", reCaptchaResponse.getToken())); + httppost.setEntity(new UrlEncodedFormEntity(params, StandardCharsets.UTF_8)); + + try { + response = httpclient.execute(httppost); + } catch (IOException e) { + RecoveryUtil.handleBadRequest(String.format("Unable to get the verification response : %s", e.getMessage()), + Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); } return response; } diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImpl.java b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImpl.java index d04b087d8a..52337bb508 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImpl.java @@ -20,6 +20,7 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpEntity; @@ -42,8 +43,6 @@ */ public class CaptchaApiServiceImpl extends CaptchaApiService { - private static final String SUCCESS = "success"; - private static final String VALID = "valid"; private static final Log log = LogFactory.getLog(CaptchaApiServiceImpl.class); private final String RECAPTCHA = "ReCaptcha"; @@ -56,22 +55,22 @@ public Response getCaptcha(String captchaType, String recoveryType, String tenan Properties properties = RecoveryUtil.getValidatedCaptchaConfigs(); boolean reCaptchaEnabled = Boolean.valueOf(properties.getProperty(CaptchaConstants.RE_CAPTCHA_ENABLED)); - boolean reCaptchaEnterpriseEnabled = - Boolean.valueOf(properties.getProperty(CaptchaConstants.RE_CAPTCHA_ENTERPRISE_ENABLED)); + String reCaptchaType = properties.getProperty(CaptchaConstants.RE_CAPTCHA_TYPE); boolean forcefullyEnabledRecaptchaForAllTenants = Boolean.valueOf(properties.getProperty(CaptchaConstants.FORCEFULLY_ENABLED_RECAPTCHA_FOR_ALL_TENANTS)); ReCaptchaPropertiesDTO reCaptchaPropertiesDTO = new ReCaptchaPropertiesDTO(); if (reCaptchaEnabled && (forcefullyEnabledRecaptchaForAllTenants || RecoveryUtil.checkCaptchaEnabledResidentIdpConfiguration(tenantDomain, recoveryType))) { - reCaptchaPropertiesDTO.setReCaptchaEnabled(reCaptchaEnabled); + reCaptchaPropertiesDTO.setReCaptchaEnabled(true); reCaptchaPropertiesDTO.setReCaptchaKey(properties.getProperty(CaptchaConstants.RE_CAPTCHA_SITE_KEY)); reCaptchaPropertiesDTO.setReCaptchaAPI(properties.getProperty(CaptchaConstants.RE_CAPTCHA_API_URL)); - reCaptchaPropertiesDTO.setReCaptchaEnterpriseEnabled(reCaptchaEnterpriseEnabled); + if (!StringUtils.isBlank(reCaptchaType)) { + reCaptchaPropertiesDTO.setReCaptchaType(reCaptchaType); + } return Response.ok(reCaptchaPropertiesDTO).build(); } else { reCaptchaPropertiesDTO.setReCaptchaEnabled(false); - reCaptchaPropertiesDTO.setReCaptchaEnterpriseEnabled(false); return Response.ok(reCaptchaPropertiesDTO).build(); } } @@ -85,8 +84,7 @@ public Response verifyCaptcha(ReCaptchaResponseTokenDTO reCaptchaResponse, Strin Properties properties = RecoveryUtil.getValidatedCaptchaConfigs(); boolean reCaptchaEnabled = Boolean.valueOf(properties.getProperty(CaptchaConstants.RE_CAPTCHA_ENABLED)); - boolean reCaptchaEnterpriseEnabled = - Boolean.valueOf(properties.getProperty(CaptchaConstants.RE_CAPTCHA_ENTERPRISE_ENABLED)); + String reCaptchaType = properties.getProperty(CaptchaConstants.RE_CAPTCHA_TYPE); if (!reCaptchaEnabled) { RecoveryUtil.handleBadRequest("ReCaptcha is disabled", Constants.INVALID); @@ -96,34 +94,37 @@ public Response verifyCaptcha(ReCaptchaResponseTokenDTO reCaptchaResponse, Strin HttpEntity entity = response.getEntity(); ReCaptchaVerificationResponseDTO reCaptchaVerificationResponseDTO = new ReCaptchaVerificationResponseDTO(); - if (reCaptchaEnterpriseEnabled) { - // For ReCaptcha Enterprise. - if (entity == null) { - RecoveryUtil.handleBadRequest("ReCaptcha Enterprise verification response is not received.", - Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); - } + if (StringUtils.isBlank(reCaptchaType) || reCaptchaType.equals(CaptchaConstants. + RE_CAPTCHA_TYPE_DEFAULT)){ + // For ReCaptcha v2 and v3. try { + if (entity == null) { + RecoveryUtil.handleBadRequest("ReCaptcha verification response is not received.", + Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + } try (InputStream in = entity.getContent()) { JsonObject verificationResponse = new JsonParser().parse(IOUtils.toString(in)).getAsJsonObject(); - JsonObject tokenProperties = verificationResponse.get("tokenProperties").getAsJsonObject(); - boolean success = tokenProperties.get(VALID).getAsBoolean(); - reCaptchaVerificationResponseDTO.setSuccess(success); + reCaptchaVerificationResponseDTO.setSuccess(verificationResponse.get( + CaptchaConstants.CAPTCHA_SUCCESS).getAsBoolean()); } } catch (IOException e) { log.error("Unable to read the verification response.", e); RecoveryUtil.handleBadRequest("Unable to read the verification response.", Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); } - } else { - // For ReCaptcha v2 and v3. + } else if (reCaptchaType.equals(CaptchaConstants.RE_CAPTCHA_TYPE_ENTERPRISE)) { + // For ReCaptcha Enterprise. + if (entity == null) { + RecoveryUtil.handleBadRequest("ReCaptcha Enterprise verification response is not received.", + Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + } try { - if (entity == null) { - RecoveryUtil.handleBadRequest("ReCaptcha verification response is not received.", - Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); - } try (InputStream in = entity.getContent()) { JsonObject verificationResponse = new JsonParser().parse(IOUtils.toString(in)).getAsJsonObject(); - reCaptchaVerificationResponseDTO.setSuccess(verificationResponse.get(SUCCESS).getAsBoolean()); + JsonObject tokenProperties = verificationResponse.get(CaptchaConstants.CAPTCHA_TOKEN_PROPERTIES) + .getAsJsonObject(); + boolean success = tokenProperties.get(CaptchaConstants.CAPTCHA_VALID).getAsBoolean(); + reCaptchaVerificationResponseDTO.setSuccess(success); } } catch (IOException e) { log.error("Unable to read the verification response.", e); diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/main/resources/api.identity.recovery.yaml b/components/org.wso2.carbon.identity.api.user.recovery/src/main/resources/api.identity.recovery.yaml index 1713ce4466..770c4c24d8 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/main/resources/api.identity.recovery.yaml +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/main/resources/api.identity.recovery.yaml @@ -790,8 +790,8 @@ definitions: properties: reCaptchaEnabled: type: boolean - reCaptchaEnterpriseEnabled: - type: boolean + reCaptchaType: + type: string reCaptchaKey: type: string reCaptchaAPI: diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/test/resources/repository/conf/identity/captcha-config.properties b/components/org.wso2.carbon.identity.api.user.recovery/src/test/resources/repository/conf/identity/captcha-config.properties index 7980a19a37..b920c175db 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/test/resources/repository/conf/identity/captcha-config.properties +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/test/resources/repository/conf/identity/captcha-config.properties @@ -21,6 +21,9 @@ # Enable Google reCAPTCHA recaptcha.enabled=true +# Google reCAPTCHA type +recaptcha.type=default + # reCaptcha API URL recaptcha.api.url=https://www.google.com/recaptcha/api.js diff --git a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/internal/CaptchaDataHolder.java b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/internal/CaptchaDataHolder.java index f55f563301..260bb81417 100644 --- a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/internal/CaptchaDataHolder.java +++ b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/internal/CaptchaDataHolder.java @@ -37,7 +37,7 @@ public class CaptchaDataHolder { private boolean reCaptchaEnabled; - private boolean reCaptchaEnterpriseEnabled; + private String reCaptchaType; private String reCaptchaAPIUrl; @@ -88,14 +88,14 @@ public void setReCaptchaEnabled(boolean reCaptchaEnabled) { this.reCaptchaEnabled = reCaptchaEnabled; } - public boolean isReCaptchaEnterpriseEnabled() { + public String getReCaptchaType() { - return reCaptchaEnterpriseEnabled; + return reCaptchaType; } - public void setReCaptchaEnterpriseEnabled(boolean reCaptchaEnterpriseEnabled) { + public void setReCaptchaType(String reCaptchaType) { - this.reCaptchaEnterpriseEnabled = reCaptchaEnterpriseEnabled; + this.reCaptchaType = reCaptchaType; } public String getReCaptchaProjectID() { diff --git a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaConstants.java b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaConstants.java index 2e1a2fbaa9..50848fdddc 100644 --- a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaConstants.java +++ b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaConstants.java @@ -34,7 +34,7 @@ public class CaptchaConstants { public static final String RE_CAPTCHA_ENABLED = "recaptcha.enabled"; - public static final String RE_CAPTCHA_ENTERPRISE_ENABLED = "recaptcha.enterprise.enabled"; + public static final String RE_CAPTCHA_TYPE = "recaptcha.type"; public static final String FORCEFULLY_ENABLED_RECAPTCHA_FOR_ALL_TENANTS = "recaptcha" + ".forcefullyEnabledForAllTenants"; @@ -70,8 +70,12 @@ public class CaptchaConstants { public static final String AUTH_FAILURE_MSG = "authFailureMsg"; public static final String RECAPTCHA_FAIL_MSG_KEY = "recaptcha.fail.message"; public static final String TRUE = "true"; - public static final String CAPTCHA_VALID = "valid"; + public static final String CAPTCHA_TOKEN_PROPERTIES = "tokenProperties"; + public static final String CAPTCHA_RISK_ANALYSIS = "riskAnalysis"; + // Captcha Types. + public static final String RE_CAPTCHA_TYPE_DEFAULT = "default"; + public static final String RE_CAPTCHA_TYPE_ENTERPRISE = "enterprise"; // Default value for threshold for score in reCAPTCHA v3. public static final double CAPTCHA_V3_DEFAULT_THRESHOLD = 0.5; diff --git a/features/org.wso2.carbon.identity.captcha.server.feature/resources/conf/captcha-config.properties.j2 b/features/org.wso2.carbon.identity.captcha.server.feature/resources/conf/captcha-config.properties.j2 index 88ec472a13..bd014187fa 100644 --- a/features/org.wso2.carbon.identity.captcha.server.feature/resources/conf/captcha-config.properties.j2 +++ b/features/org.wso2.carbon.identity.captcha.server.feature/resources/conf/captcha-config.properties.j2 @@ -21,8 +21,8 @@ # Enable Google reCAPTCHA recaptcha.enabled={{recaptcha.enabled}} -# Enable Google reCAPTCHA Enterprise -recaptcha.enterprise.enabled={{recaptcha.enterprise_enabled}} +# captcha type +recaptcha.type={{recaptcha.type}} # Forcefully enable Google reCAPTCHA for all tenants recaptcha.forcefullyEnabledForAllTenants={{recaptcha.forcefully_enabled_for_all_tenants}} From bc5357ef7f55900c64d04cb7daaf610e324a22ad Mon Sep 17 00:00:00 2001 From: AwesomeNipun Date: Thu, 29 Jun 2023 11:47:43 +0530 Subject: [PATCH 06/15] Add unit tests for CaptchaUtil and CaptchaApiServiceImpl --- .../impl/CaptchaApiServiceImplTest.java | 60 ++++- .../org.wso2.carbon.identity.captcha/pom.xml | 26 ++ .../captcha/util/CaptchaUtilTest.java | 226 ++++++++++++++++++ .../src/test/resources/testng.xml | 26 ++ 4 files changed, 328 insertions(+), 10 deletions(-) create mode 100644 components/org.wso2.carbon.identity.captcha/src/test/java/org/wso2/carbon/identity/captcha/util/CaptchaUtilTest.java create mode 100644 components/org.wso2.carbon.identity.captcha/src/test/resources/testng.xml diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/test/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImplTest.java b/components/org.wso2.carbon.identity.api.user.recovery/src/test/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImplTest.java index 70088128a9..7f0f0e9a0d 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/test/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImplTest.java +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/test/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImplTest.java @@ -17,16 +17,18 @@ package org.wso2.carbon.identity.recovery.endpoint.impl; +import org.apache.commons.lang.StringUtils; import org.mockito.InjectMocks; import org.mockito.MockedStatic; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import org.wso2.carbon.identity.captcha.util.CaptchaConstants; import org.wso2.carbon.identity.recovery.endpoint.Utils.RecoveryUtil; - +import org.wso2.carbon.identity.recovery.endpoint.dto.ReCaptchaPropertiesDTO; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; @@ -35,8 +37,9 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.Properties; - +import javax.ws.rs.core.Response; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNull; /** * Unit tests for CaptchaApiServiceImpl.java @@ -61,9 +64,51 @@ public void tearDown() { mockedRecoveryUtil.close(); } - @Test(description = "This method test, getReCaptcha method for username recovery") - public void testGetCaptcha() throws IOException { + @DataProvider(name = "captchaTestDataProvider") + public static Object[][] getCaptchaTestDataProvider() { + + String reCaptchaEnterprise = CaptchaConstants.RE_CAPTCHA_TYPE_ENTERPRISE; + + return new Object[][]{ + {false, "", ""}, + {true, "", "https://www.google.com/recaptcha/api.js"}, + {true, reCaptchaEnterprise, "https://www.google.com/recaptcha/enterprise.js"} + }; + } + + @Test(description = "This method test, getReCaptcha method for username recovery", + dataProvider = "captchaTestDataProvider") + public void testGetCaptcha(boolean reCaptchaEnabled, String reCaptchaType, + String reCaptchaAPI) throws IOException { + Properties sampleProperties = getSampleConfigFile(); + + sampleProperties.setProperty(CaptchaConstants.RE_CAPTCHA_ENABLED, String.valueOf(reCaptchaEnabled)); + sampleProperties.setProperty(CaptchaConstants.RE_CAPTCHA_TYPE, reCaptchaType); + sampleProperties.setProperty(CaptchaConstants.RE_CAPTCHA_API_URL, reCaptchaAPI); + + mockedRecoveryUtil.when(RecoveryUtil::getValidatedCaptchaConfigs).thenReturn(sampleProperties); + mockedRecoveryUtil.when(() -> RecoveryUtil.checkCaptchaEnabledResidentIdpConfiguration(Mockito.anyString(), + Mockito.anyString())).thenReturn(true); + Response response = captchaApiService.getCaptcha("ReCaptcha", "username-recovery", + "test.org"); + + ReCaptchaPropertiesDTO reCaptchaPropertiesDTO = response.readEntity(ReCaptchaPropertiesDTO.class); + + assertEquals(reCaptchaPropertiesDTO.getReCaptchaEnabled().booleanValue(), reCaptchaEnabled); + if (StringUtils.isBlank(reCaptchaType)) { + assertNull(reCaptchaPropertiesDTO.getReCaptchaType()); + } else { + assertEquals(reCaptchaPropertiesDTO.getReCaptchaType(), reCaptchaType); + } + if (StringUtils.isBlank(reCaptchaAPI)) { + assertNull(reCaptchaPropertiesDTO.getReCaptchaAPI()); + } else { + assertEquals(reCaptchaPropertiesDTO.getReCaptchaAPI(), reCaptchaAPI); + } + } + + public Properties getSampleConfigFile() throws IOException { Path path = Paths.get("src/test/resources", "repository", "conf", "identity", CaptchaConstants.CAPTCHA_CONFIG_FILE_NAME); Properties sampleProperties = new Properties(); @@ -74,11 +119,6 @@ public void testGetCaptcha() throws IOException { throw new IOException("Unable to read the captcha configuration file.", e); } } - - mockedRecoveryUtil.when(RecoveryUtil::getValidatedCaptchaConfigs).thenReturn(sampleProperties); - mockedRecoveryUtil.when(() -> RecoveryUtil.checkCaptchaEnabledResidentIdpConfiguration(Mockito.anyString(), - Mockito.anyString())).thenReturn(true); - assertEquals(captchaApiService.getCaptcha("ReCaptcha", "username-recovery", - null).getStatus(), 200); + return sampleProperties; } } diff --git a/components/org.wso2.carbon.identity.captcha/pom.xml b/components/org.wso2.carbon.identity.captcha/pom.xml index 4d725bbcfe..07abc9a301 100644 --- a/components/org.wso2.carbon.identity.captcha/pom.xml +++ b/components/org.wso2.carbon.identity.captcha/pom.xml @@ -114,6 +114,22 @@ org.wso2.securevault org.wso2.securevault + + org.testng + testng + test + + + org.jacoco + org.jacoco.agent + runtime + test + + + org.mockito + mockito-inline + test + @@ -185,6 +201,16 @@ + + org.apache.maven.plugins + maven-surefire-plugin + ${maven.surefire.plugin.version} + + + src/test/resources/testng.xml + + + com.github.spotbugs spotbugs-maven-plugin diff --git a/components/org.wso2.carbon.identity.captcha/src/test/java/org/wso2/carbon/identity/captcha/util/CaptchaUtilTest.java b/components/org.wso2.carbon.identity.captcha/src/test/java/org/wso2/carbon/identity/captcha/util/CaptchaUtilTest.java new file mode 100644 index 0000000000..37cbdc497e --- /dev/null +++ b/components/org.wso2.carbon.identity.captcha/src/test/java/org/wso2/carbon/identity/captcha/util/CaptchaUtilTest.java @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2023, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.wso2.carbon.identity.captcha.util; + +import com.google.gson.JsonObject; +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.HttpPost; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.testng.Assert; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import org.wso2.carbon.identity.captcha.internal.CaptchaDataHolder; + +import java.io.ByteArrayInputStream; +import java.io.IOException; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import static org.testng.Assert.*; + +/** + * Unit tests for CaptchaUtil.java + */ +public class CaptchaUtilTest { + + private final String RECAPTCHA_API_URL = "https://www.google.com/recaptcha/api/siteverify"; + + @BeforeMethod + public void setUp() { + + MockitoAnnotations.openMocks(this); + } + + private Method getCreateReCaptchaEnterpriseVerificationHttpPostMethod() throws NoSuchMethodException { + + Method method = CaptchaUtil.class.getDeclaredMethod("createReCaptchaEnterpriseVerificationHttpPost", + String.class); + method.setAccessible(true); + return method; + } + + private Method getCreateReCaptchaVerificationHttpPostMethod() throws NoSuchMethodException { + + Method method = CaptchaUtil.class.getDeclaredMethod("createReCaptchaVerificationHttpPost", + String.class); + method.setAccessible(true); + return method; + } + + private Method getVerifyReCaptchaEnterpriseResponseMethod() throws NoSuchMethodException { + + Method method = CaptchaUtil.class.getDeclaredMethod("verifyReCaptchaEnterpriseResponse", + HttpEntity.class); + method.setAccessible(true); + return method; + } + + private Method getVerifyReCaptchaResponseMethod() throws NoSuchMethodException { + + Method method = CaptchaUtil.class.getDeclaredMethod("verifyReCaptchaResponse", + HttpEntity.class); + method.setAccessible(true); + return method; + } + + private JsonObject getReCaptchaEnterpriseJsonObject(boolean valid, double score) { + + JsonObject verificationResponse = new JsonObject(); + JsonObject tokenProperties = new JsonObject(); + tokenProperties.addProperty(CaptchaConstants.CAPTCHA_VALID, valid); + verificationResponse.add(CaptchaConstants.CAPTCHA_TOKEN_PROPERTIES, tokenProperties); + JsonObject riskAnalysis = new JsonObject(); + riskAnalysis.addProperty(CaptchaConstants.CAPTCHA_SCORE, score); + verificationResponse.add(CaptchaConstants.CAPTCHA_RISK_ANALYSIS, riskAnalysis); + return verificationResponse; + } + + private JsonObject getReCaptchaJsonObject(boolean valid, double score) { + + JsonObject verificationResponse = new JsonObject(); + verificationResponse.addProperty(CaptchaConstants.CAPTCHA_SUCCESS, valid); + verificationResponse.addProperty(CaptchaConstants.CAPTCHA_SCORE, score); + return verificationResponse; + } + + @Test (description = "This method is used to test the createReCaptchaEnterpriseVerificationHttpPost method") + public void testCreateReCaptchaEnterpriseVerificationHttpPost() throws NoSuchMethodException, + InvocationTargetException, IllegalAccessException { + + CaptchaDataHolder.getInstance().setReCaptchaVerifyUrl(RECAPTCHA_API_URL); + CaptchaDataHolder.getInstance().setReCaptchaSecretKey("dummyKey"); + CaptchaDataHolder.getInstance().setReCaptchaSiteKey("dummySiteKey"); + CaptchaDataHolder.getInstance().setReCaptchaProjectID("dummyProjectId"); + + + + Method method = getCreateReCaptchaEnterpriseVerificationHttpPostMethod(); + HttpPost httpPost = (HttpPost) method.invoke(null, "reCaptchaEnterpriseResponse"); + String expectedURI = RECAPTCHA_API_URL+ "/v1/projects/dummyProjectId/assessments?key=dummyKey"; + Assert.assertEquals(httpPost.getURI().toString(), expectedURI); + + } + + @Test (description = "This method is used to test the createReCaptchaEnterpriseVerificationHttpPost method") + public void testCreateReCaptchaVerificationHttpPost() throws NoSuchMethodException, + InvocationTargetException, IllegalAccessException { + + CaptchaDataHolder.getInstance().setReCaptchaVerifyUrl(RECAPTCHA_API_URL); + CaptchaDataHolder.getInstance().setReCaptchaSecretKey("dummyKey"); + CaptchaDataHolder.getInstance().setReCaptchaSiteKey("dummySiteKey"); + CaptchaDataHolder.getInstance().setReCaptchaProjectID("dummyProjectId"); + + Method method = getCreateReCaptchaVerificationHttpPostMethod(); + HttpPost httpPost = (HttpPost) method.invoke(null, "reCaptchaEnterpriseResponse"); + Assert.assertEquals(httpPost.getURI().toString(), RECAPTCHA_API_URL); + } + + + @Test (description = "This method is used to test the verifyReCaptchaEnterpriseResponse method, " + + "with high captcha score") + public void testVerifyReCaptchaEnterpriseResponseWithHighScore() throws IOException, NoSuchMethodException, + InvocationTargetException, IllegalAccessException { + + CaptchaDataHolder.getInstance().setReCaptchaScoreThreshold(CaptchaConstants.CAPTCHA_V3_DEFAULT_THRESHOLD); + + JsonObject verificationResponse = getReCaptchaEnterpriseJsonObject(true, 0.7); + Method method = getVerifyReCaptchaEnterpriseResponseMethod(); + HttpEntity httpEntity = Mockito.mock(HttpEntity.class); + Mockito.when(httpEntity.getContent()).thenReturn(new ByteArrayInputStream( + verificationResponse.toString().getBytes())); + // verify no exception is thrown for high score + method.invoke(null, httpEntity); + } + + @Test (description = "This method is used to test the verifyReCaptchaEnterpriseResponse method, " + + "with low captcha score") + public void testVerifyReCaptchaEnterpriseResponseWithLowScore() throws IOException, NoSuchMethodException { + + CaptchaDataHolder.getInstance().setReCaptchaScoreThreshold(CaptchaConstants.CAPTCHA_V3_DEFAULT_THRESHOLD); + + JsonObject verificationResponse = getReCaptchaEnterpriseJsonObject(true, 0.4); + Method method = getVerifyReCaptchaEnterpriseResponseMethod(); + HttpEntity httpEntity = Mockito.mock(HttpEntity.class); + Mockito.when(httpEntity.getContent()).thenReturn(new ByteArrayInputStream(verificationResponse.toString(). + getBytes())); + // verify an exception is thrown for low score + assertThrows(InvocationTargetException.class, () -> method.invoke(null, httpEntity)); + } + + @Test (description = "This method is used to test the verifyReCaptchaEnterpriseResponse method, " + + "with invalid response") + public void testVerifyReCaptchaEnterpriseResponseWithInvalidResponse() throws IOException, NoSuchMethodException { + + CaptchaDataHolder.getInstance().setReCaptchaScoreThreshold(CaptchaConstants.CAPTCHA_V3_DEFAULT_THRESHOLD); + + JsonObject verificationResponse = getReCaptchaEnterpriseJsonObject(false, 0.7); + Method method = getVerifyReCaptchaEnterpriseResponseMethod(); + HttpEntity httpEntity = Mockito.mock(HttpEntity.class); + Mockito.when(httpEntity.getContent()).thenReturn(new ByteArrayInputStream(verificationResponse. + toString().getBytes())); + // verify an exception is thrown for invalid response + assertThrows(InvocationTargetException.class, () -> method.invoke(null, httpEntity)); + } + + @Test (description = "This method is used to test the verifyReCaptchaResponse method, " + + "with high captcha score") + public void testVerifyReCaptchaResponseWithHighScore() throws IOException, NoSuchMethodException, + InvocationTargetException, IllegalAccessException { + + CaptchaDataHolder.getInstance().setReCaptchaScoreThreshold(CaptchaConstants.CAPTCHA_V3_DEFAULT_THRESHOLD); + + JsonObject verificationResponse = getReCaptchaJsonObject(true, 0.7); + Method method = getVerifyReCaptchaResponseMethod(); + HttpEntity httpEntity = Mockito.mock(HttpEntity.class); + Mockito.when(httpEntity.getContent()).thenReturn(new ByteArrayInputStream(verificationResponse.toString(). + getBytes())); + // verify no exception is thrown for high score + method.invoke(null, httpEntity); + } + + @Test (description = "This method is used to test the verifyReCaptchaResponse method, " + + "with low captcha score") + public void testVerifyReCaptchaResponseWithLowScore() throws IOException, NoSuchMethodException { + + CaptchaDataHolder.getInstance().setReCaptchaScoreThreshold(CaptchaConstants.CAPTCHA_V3_DEFAULT_THRESHOLD); + + JsonObject verificationResponse = getReCaptchaJsonObject(true, 0.4); + Method method = getVerifyReCaptchaResponseMethod(); + HttpEntity httpEntity = Mockito.mock(HttpEntity.class); + Mockito.when(httpEntity.getContent()).thenReturn(new ByteArrayInputStream(verificationResponse.toString(). + getBytes())); + // verify no exception is thrown for low score + assertThrows(InvocationTargetException.class, () -> method.invoke(null, httpEntity)); + } + + @Test (description = "This method is used to test the verifyReCaptchaResponse method, " + + "with invalid response") + public void testVerifyReCaptchaResponseWithInvalidResponse() throws IOException, NoSuchMethodException { + + CaptchaDataHolder.getInstance().setReCaptchaScoreThreshold(CaptchaConstants.CAPTCHA_V3_DEFAULT_THRESHOLD); + + JsonObject verificationResponse = getReCaptchaJsonObject(false, 0.7); + Method method = getVerifyReCaptchaResponseMethod(); + HttpEntity httpEntity = Mockito.mock(HttpEntity.class); + Mockito.when(httpEntity.getContent()).thenReturn(new ByteArrayInputStream(verificationResponse.toString(). + getBytes())); + // verify no exception is thrown for invalid response + assertThrows(InvocationTargetException.class, () -> method.invoke(null, httpEntity)); + } +} diff --git a/components/org.wso2.carbon.identity.captcha/src/test/resources/testng.xml b/components/org.wso2.carbon.identity.captcha/src/test/resources/testng.xml new file mode 100644 index 0000000000..9dbe5a2ae6 --- /dev/null +++ b/components/org.wso2.carbon.identity.captcha/src/test/resources/testng.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + \ No newline at end of file From b5c5b44eed53d8aa508814c85dac14ceb0ffa4fb Mon Sep 17 00:00:00 2001 From: AwesomeNipun Date: Thu, 29 Jun 2023 11:59:24 +0530 Subject: [PATCH 07/15] Remove default recaptcha type --- .../endpoint/dto/ReCaptchaPropertiesDTO.java | 2 +- .../recovery/endpoint/Utils/RecoveryUtil.java | 2 +- .../endpoint/impl/CaptchaApiServiceImpl.java | 46 +++++++++---------- .../captcha/util/CaptchaConstants.java | 1 - 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/gen/java/org/wso2/carbon/identity/recovery/endpoint/dto/ReCaptchaPropertiesDTO.java b/components/org.wso2.carbon.identity.api.user.recovery/src/gen/java/org/wso2/carbon/identity/recovery/endpoint/dto/ReCaptchaPropertiesDTO.java index 40543abfe5..7172a0ab70 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/gen/java/org/wso2/carbon/identity/recovery/endpoint/dto/ReCaptchaPropertiesDTO.java +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/gen/java/org/wso2/carbon/identity/recovery/endpoint/dto/ReCaptchaPropertiesDTO.java @@ -80,7 +80,7 @@ public String toString() { sb.append("class ReCaptchaPropertiesDTO {\n"); sb.append(" reCaptchaEnabled: ").append(reCaptchaEnabled).append("\n"); - sb.append(" reCaptchaEnterpriseEnabled: ").append(reCaptchaType).append("\n"); + sb.append(" reCaptchaType: ").append(reCaptchaType).append("\n"); sb.append(" reCaptchaKey: ").append(reCaptchaKey).append("\n"); sb.append(" reCaptchaAPI: ").append(reCaptchaAPI).append("\n"); sb.append("}\n"); diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java index dc20efe75c..2b3569a29a 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java @@ -470,7 +470,7 @@ private static Properties validateCaptchaConfigs(Properties properties) { RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants.RE_CAPTCHA_VERIFY_URL), Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); } - if (!StringUtils.isBlank(reCaptchaType) && reCaptchaType.equals(CaptchaConstants.RE_CAPTCHA_TYPE_ENTERPRISE) && + if (CaptchaConstants.RE_CAPTCHA_TYPE_ENTERPRISE.equals(reCaptchaType) && StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_PROJECT_ID))) { RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants .RE_CAPTCHA_PROJECT_ID), Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImpl.java b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImpl.java index 52337bb508..50d928c8ba 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImpl.java @@ -55,7 +55,6 @@ public Response getCaptcha(String captchaType, String recoveryType, String tenan Properties properties = RecoveryUtil.getValidatedCaptchaConfigs(); boolean reCaptchaEnabled = Boolean.valueOf(properties.getProperty(CaptchaConstants.RE_CAPTCHA_ENABLED)); - String reCaptchaType = properties.getProperty(CaptchaConstants.RE_CAPTCHA_TYPE); boolean forcefullyEnabledRecaptchaForAllTenants = Boolean.valueOf(properties.getProperty(CaptchaConstants.FORCEFULLY_ENABLED_RECAPTCHA_FOR_ALL_TENANTS)); ReCaptchaPropertiesDTO reCaptchaPropertiesDTO = new ReCaptchaPropertiesDTO(); @@ -65,14 +64,11 @@ public Response getCaptcha(String captchaType, String recoveryType, String tenan reCaptchaPropertiesDTO.setReCaptchaEnabled(true); reCaptchaPropertiesDTO.setReCaptchaKey(properties.getProperty(CaptchaConstants.RE_CAPTCHA_SITE_KEY)); reCaptchaPropertiesDTO.setReCaptchaAPI(properties.getProperty(CaptchaConstants.RE_CAPTCHA_API_URL)); - if (!StringUtils.isBlank(reCaptchaType)) { - reCaptchaPropertiesDTO.setReCaptchaType(reCaptchaType); - } - return Response.ok(reCaptchaPropertiesDTO).build(); + reCaptchaPropertiesDTO.setReCaptchaType(properties.getProperty(CaptchaConstants.RE_CAPTCHA_TYPE)); } else { reCaptchaPropertiesDTO.setReCaptchaEnabled(false); - return Response.ok(reCaptchaPropertiesDTO).build(); } + return Response.ok(reCaptchaPropertiesDTO).build(); } @Override @@ -94,25 +90,7 @@ public Response verifyCaptcha(ReCaptchaResponseTokenDTO reCaptchaResponse, Strin HttpEntity entity = response.getEntity(); ReCaptchaVerificationResponseDTO reCaptchaVerificationResponseDTO = new ReCaptchaVerificationResponseDTO(); - if (StringUtils.isBlank(reCaptchaType) || reCaptchaType.equals(CaptchaConstants. - RE_CAPTCHA_TYPE_DEFAULT)){ - // For ReCaptcha v2 and v3. - try { - if (entity == null) { - RecoveryUtil.handleBadRequest("ReCaptcha verification response is not received.", - Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); - } - try (InputStream in = entity.getContent()) { - JsonObject verificationResponse = new JsonParser().parse(IOUtils.toString(in)).getAsJsonObject(); - reCaptchaVerificationResponseDTO.setSuccess(verificationResponse.get( - CaptchaConstants.CAPTCHA_SUCCESS).getAsBoolean()); - } - } catch (IOException e) { - log.error("Unable to read the verification response.", e); - RecoveryUtil.handleBadRequest("Unable to read the verification response.", - Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); - } - } else if (reCaptchaType.equals(CaptchaConstants.RE_CAPTCHA_TYPE_ENTERPRISE)) { + if (CaptchaConstants.RE_CAPTCHA_TYPE_ENTERPRISE.equals(reCaptchaType)) { // For ReCaptcha Enterprise. if (entity == null) { RecoveryUtil.handleBadRequest("ReCaptcha Enterprise verification response is not received.", @@ -131,7 +109,25 @@ public Response verifyCaptcha(ReCaptchaResponseTokenDTO reCaptchaResponse, Strin RecoveryUtil.handleBadRequest("Unable to read the verification response.", Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); } + } else { + // For ReCaptcha v2 and v3. + try { + if (entity == null) { + RecoveryUtil.handleBadRequest("ReCaptcha verification response is not received.", + Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + } + try (InputStream in = entity.getContent()) { + JsonObject verificationResponse = new JsonParser().parse(IOUtils.toString(in)).getAsJsonObject(); + reCaptchaVerificationResponseDTO.setSuccess(verificationResponse.get( + CaptchaConstants.CAPTCHA_SUCCESS).getAsBoolean()); + } + } catch (IOException e) { + log.error("Unable to read the verification response.", e); + RecoveryUtil.handleBadRequest("Unable to read the verification response.", + Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + } } + return Response.ok(reCaptchaVerificationResponseDTO).build(); } } diff --git a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaConstants.java b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaConstants.java index 50848fdddc..19f59e3e1d 100644 --- a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaConstants.java +++ b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaConstants.java @@ -74,7 +74,6 @@ public class CaptchaConstants { public static final String CAPTCHA_TOKEN_PROPERTIES = "tokenProperties"; public static final String CAPTCHA_RISK_ANALYSIS = "riskAnalysis"; // Captcha Types. - public static final String RE_CAPTCHA_TYPE_DEFAULT = "default"; public static final String RE_CAPTCHA_TYPE_ENTERPRISE = "enterprise"; // Default value for threshold for score in reCAPTCHA v3. From 7c061ea061a4c4e5d17e3889196f99e281f2457d Mon Sep 17 00:00:00 2001 From: AwesomeNipun Date: Thu, 29 Jun 2023 15:25:30 +0530 Subject: [PATCH 08/15] Fix for CaptchaApiServiceImplTest failure --- .../recovery/endpoint/impl/CaptchaApiServiceImplTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/test/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImplTest.java b/components/org.wso2.carbon.identity.api.user.recovery/src/test/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImplTest.java index 7f0f0e9a0d..354792e128 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/test/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImplTest.java +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/test/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImplTest.java @@ -96,7 +96,7 @@ public void testGetCaptcha(boolean reCaptchaEnabled, String reCaptchaType, ReCaptchaPropertiesDTO reCaptchaPropertiesDTO = response.readEntity(ReCaptchaPropertiesDTO.class); assertEquals(reCaptchaPropertiesDTO.getReCaptchaEnabled().booleanValue(), reCaptchaEnabled); - if (StringUtils.isBlank(reCaptchaType)) { + if (reCaptchaPropertiesDTO.getReCaptchaType() == null) { assertNull(reCaptchaPropertiesDTO.getReCaptchaType()); } else { assertEquals(reCaptchaPropertiesDTO.getReCaptchaType(), reCaptchaType); From 20971463e18dd85f5ab7573318ee5fbdcc95ed63 Mon Sep 17 00:00:00 2001 From: Lakshan Date: Thu, 31 Aug 2023 13:29:10 +0530 Subject: [PATCH 09/15] Add updates done by @AwesomeNipun after resolving merge conflicts --- .../identity/captcha/util/CaptchaUtil.java | 160 ++++++++++++++++-- 1 file changed, 143 insertions(+), 17 deletions(-) diff --git a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaUtil.java b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaUtil.java index 85e30c76e7..bc4f01a152 100644 --- a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaUtil.java +++ b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaUtil.java @@ -18,6 +18,7 @@ package org.wso2.carbon.identity.captcha.util; +import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import org.apache.commons.collections.MapUtils; @@ -27,8 +28,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpEntity; +import org.apache.http.HttpHeaders; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; +import org.apache.http.entity.StringEntity; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.utils.URIBuilder; @@ -269,36 +272,98 @@ public static Map getClaimValues(User user, int tenantId, return claimValues; } - public static boolean isValidCaptcha(String reCaptchaResponse) throws CaptchaException { + private static HttpPost createReCaptchaEnterpriseVerificationHttpPost(String reCaptchaResponse) { - CloseableHttpClient httpclient = HttpClientBuilder.create().useSystemProperties().build(); - HttpPost httppost = new HttpPost(CaptchaDataHolder.getInstance().getReCaptchaVerifyUrl()); - final double scoreThreshold = CaptchaDataHolder.getInstance().getReCaptchaScoreThreshold(); + HttpPost httpPost; + String recaptchaUrl = CaptchaDataHolder.getInstance().getReCaptchaVerifyUrl(); + String projectID = CaptchaDataHolder.getInstance().getReCaptchaProjectID(); + String siteKey = CaptchaDataHolder.getInstance().getReCaptchaSiteKey(); + String secretKey = CaptchaDataHolder.getInstance().getReCaptchaSecretKey(); + + String verifyUrl = recaptchaUrl + "/v1/projects/" + projectID + "/assessments?key=" + secretKey; + httpPost = new HttpPost(verifyUrl); + + httpPost.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); + + String json = String.format("{ \"event\": { \"token\": \"%s\", \"siteKey\": \"%s\" } }", reCaptchaResponse, + siteKey); + + StringEntity entity = new StringEntity(json, StandardCharsets.UTF_8); + + httpPost.setEntity(entity); + + return httpPost; + } + private static HttpPost createReCaptchaVerificationHttpPost(String reCaptchaResponse) { + + HttpPost httpPost; + httpPost = new HttpPost(CaptchaDataHolder.getInstance().getReCaptchaVerifyUrl()); List params = Arrays.asList(new BasicNameValuePair("secret", CaptchaDataHolder - .getInstance().getReCaptchaSecretKey()), new BasicNameValuePair("response", reCaptchaResponse)); - httppost.setEntity(new UrlEncodedFormEntity(params, StandardCharsets.UTF_8)); + .getInstance().getReCaptchaSecretKey()), + new BasicNameValuePair("response", reCaptchaResponse)); + httpPost.setEntity(new UrlEncodedFormEntity(params, StandardCharsets.UTF_8)); + + return httpPost; + } + + private static void verifyReCaptchaEnterpriseResponse(HttpEntity entity) + throws CaptchaServerException, CaptchaClientException { + + final double scoreThreshold = CaptchaDataHolder.getInstance().getReCaptchaScoreThreshold(); - HttpResponse response; try { - response = httpclient.execute(httppost); + try (InputStream in = entity.getContent()) { + JsonElement jsonElement = JsonParser.parseReader(new InputStreamReader(in, StandardCharsets.UTF_8)); + JsonObject verificationResponse = jsonElement.getAsJsonObject(); + if (verificationResponse == null) { + throw new CaptchaClientException("Error receiving reCaptcha response from the server"); + } + JsonObject tokenProperties = verificationResponse.get(CaptchaConstants.CAPTCHA_TOKEN_PROPERTIES). + getAsJsonObject(); + boolean success = tokenProperties.get(CaptchaConstants.CAPTCHA_VALID).getAsBoolean(); + + JsonObject riskAnalysis = verificationResponse.get(CaptchaConstants.CAPTCHA_RISK_ANALYSIS). + getAsJsonObject(); + + // Whether this request was a valid reCAPTCHA token. + if (!success) { + throw new CaptchaClientException("reCaptcha token is invalid. Error:" + + verificationResponse.get("error-codes")); + } + if (riskAnalysis.get(CaptchaConstants.CAPTCHA_SCORE) != null) { + double score = riskAnalysis.get(CaptchaConstants.CAPTCHA_SCORE).getAsDouble(); + // reCAPTCHA enterprise response contains score. + if (log.isDebugEnabled()) { + log.debug("reCAPTCHA Enterprise response { timestamp:" + + tokenProperties.get("createTime") + ", action: " + + tokenProperties.get("action") + ", score: " + score + " }"); + } + if (score < scoreThreshold) { + throw new CaptchaClientException("reCaptcha score is less than the threshold."); + } + } + } } catch (IOException e) { - throw new CaptchaServerException("Unable to get the verification response.", e); + throw new CaptchaServerException("Unable to read the verification response.", e); + } catch (ClassCastException e) { + throw new CaptchaServerException("Unable to cast the response value.", e); } + } - HttpEntity entity = response.getEntity(); - if (entity == null) { - throw new CaptchaServerException("reCaptcha verification response is not received."); - } + private static void verifyReCaptchaResponse(HttpEntity entity) + throws CaptchaServerException, CaptchaClientException { + + final double scoreThreshold = CaptchaDataHolder.getInstance().getReCaptchaScoreThreshold(); try { try (InputStream in = entity.getContent()) { - JsonObject verificationResponse = new JsonParser().parse(IOUtils.toString(in)).getAsJsonObject(); + JsonElement jsonElement = JsonParser.parseReader(new InputStreamReader(in, StandardCharsets.UTF_8)); + JsonObject verificationResponse = jsonElement.getAsJsonObject(); if (verificationResponse == null) { throw new CaptchaClientException("Error receiving reCaptcha response from the server"); } - boolean success = verificationResponse.get(CaptchaConstants.CAPTCHA_SUCCESS) != null - && verificationResponse.get(CaptchaConstants.CAPTCHA_SUCCESS).getAsBoolean(); + boolean success = verificationResponse.get(CaptchaConstants.CAPTCHA_SUCCESS).getAsBoolean(); // Whether this request was a valid reCAPTCHA token. if (!success) { throw new CaptchaClientException("reCaptcha token is invalid. Error:" + @@ -306,7 +371,7 @@ public static boolean isValidCaptcha(String reCaptchaResponse) throws CaptchaExc } if (verificationResponse.get(CaptchaConstants.CAPTCHA_SCORE) != null) { double score = verificationResponse.get(CaptchaConstants.CAPTCHA_SCORE).getAsDouble(); - // reCAPTCHA v3 response contains score + // reCAPTCHA v3 response contains score. if (log.isDebugEnabled()) { log.debug("reCAPTCHA v3 response { timestamp:" + verificationResponse.get("challenge_ts") + ", action: " + @@ -327,6 +392,44 @@ public static boolean isValidCaptcha(String reCaptchaResponse) throws CaptchaExc } catch (ClassCastException e) { throw new CaptchaServerException("Unable to cast the response value.", e); } + } + + public static boolean isValidCaptcha(String reCaptchaResponse) throws CaptchaException { + + CloseableHttpClient httpclient = HttpClientBuilder.create().useSystemProperties().build(); + String reCaptchaType = CaptchaDataHolder.getInstance().getReCaptchaType(); + + HttpPost httpPost; + + // If the reCaptcha type is defined and, it is enterprise, the enterprise process will be done. Otherwise, + // the reCaptcha v2/v3 process will be done. + if (CaptchaConstants.RE_CAPTCHA_TYPE_ENTERPRISE.equals(reCaptchaType)) { + // For ReCaptcha Enterprise. + httpPost = createReCaptchaEnterpriseVerificationHttpPost(reCaptchaResponse); + } else { + // For ReCaptcha v2 and v3. + httpPost = createReCaptchaVerificationHttpPost(reCaptchaResponse); + } + + HttpResponse response; + try { + response = httpclient.execute(httpPost); + } catch (IOException e) { + throw new CaptchaServerException("Unable to get the verification response.", e); + } + + HttpEntity entity = response.getEntity(); + if (entity == null) { + throw new CaptchaServerException("reCaptcha verification response is not received."); + } + + if (CaptchaConstants.RE_CAPTCHA_TYPE_ENTERPRISE.equals(reCaptchaType)) { + // For ReCaptcha Enterprise. + verifyReCaptchaEnterpriseResponse(entity); + } else { + // For Recaptcha v2 and v3. + verifyReCaptchaResponse(entity); + } return true; } @@ -456,6 +559,20 @@ private static UserStoreManager getUserStoreManagerForUser(String userName, private static void setReCaptchaConfigs(Properties properties) { + String reCaptchaType = properties.getProperty(CaptchaConstants.RE_CAPTCHA_TYPE); + if (!StringUtils.isBlank(reCaptchaType)) { + CaptchaDataHolder.getInstance().setReCaptchaType(reCaptchaType); + } + + if (CaptchaConstants.RE_CAPTCHA_TYPE_ENTERPRISE.equals(reCaptchaType)) { + // ReCaptcha Enterprise require Project ID. + String reCaptchaProjectID = properties.getProperty(CaptchaConstants.RE_CAPTCHA_PROJECT_ID); + if (StringUtils.isBlank(reCaptchaProjectID)) { + throw new RuntimeException(getValidationErrorMessage(CaptchaConstants.RE_CAPTCHA_PROJECT_ID)); + } + CaptchaDataHolder.getInstance().setReCaptchaProjectID(reCaptchaProjectID); + } + String reCaptchaAPIUrl = properties.getProperty(CaptchaConstants.RE_CAPTCHA_API_URL); if (StringUtils.isBlank(reCaptchaAPIUrl)) { throw new RuntimeException(getValidationErrorMessage(CaptchaConstants.RE_CAPTCHA_API_URL)); @@ -692,6 +809,15 @@ public static Boolean isReCaptchaEnabled() { return CaptchaDataHolder.getInstance().isReCaptchaEnabled(); } + /** + * Get the ReCaptcha Type. + * @return ReCaptcha Type as a String. + */ + public static String reCaptchaType() { + + return CaptchaDataHolder.getInstance().getReCaptchaType(); + } + /** * Check whether ReCaptcha is forcefully enabled for all tenants. * From 4823ca6b0809a0e85dd48e93225ffa080d9e3c99 Mon Sep 17 00:00:00 2001 From: Lakshan Date: Fri, 1 Sep 2023 09:09:12 +0530 Subject: [PATCH 10/15] Changes requested in PR review --- .../carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java | 1 + .../src/test/resources/testng.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java index 2b3569a29a..1c76ecd912 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java @@ -470,6 +470,7 @@ private static Properties validateCaptchaConfigs(Properties properties) { RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants.RE_CAPTCHA_VERIFY_URL), Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); } + // Check if project id is available for reCaptcha Enterprise if (CaptchaConstants.RE_CAPTCHA_TYPE_ENTERPRISE.equals(reCaptchaType) && StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_PROJECT_ID))) { RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants diff --git a/components/org.wso2.carbon.identity.captcha/src/test/resources/testng.xml b/components/org.wso2.carbon.identity.captcha/src/test/resources/testng.xml index 9dbe5a2ae6..dc33af0505 100644 --- a/components/org.wso2.carbon.identity.captcha/src/test/resources/testng.xml +++ b/components/org.wso2.carbon.identity.captcha/src/test/resources/testng.xml @@ -23,4 +23,4 @@ - \ No newline at end of file + From bdadd5cefb4102aa8b79525487e65cb56821d9c2 Mon Sep 17 00:00:00 2001 From: Lakshan Date: Fri, 1 Sep 2023 15:20:14 +0530 Subject: [PATCH 11/15] Use API Key instead of secret key for recaptcha enterprise --- .../captcha/internal/CaptchaDataHolder.java | 10 ++++++++ .../captcha/util/CaptchaConstants.java | 2 ++ .../identity/captcha/util/CaptchaUtil.java | 23 ++++++++++++------- .../captcha/util/CaptchaUtilTest.java | 7 +++--- .../conf/captcha-config.properties.j2 | 3 +++ 5 files changed, 34 insertions(+), 11 deletions(-) diff --git a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/internal/CaptchaDataHolder.java b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/internal/CaptchaDataHolder.java index 260bb81417..f701657965 100644 --- a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/internal/CaptchaDataHolder.java +++ b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/internal/CaptchaDataHolder.java @@ -47,6 +47,8 @@ public class CaptchaDataHolder { private String reCaptchaSecretKey; + private String reCaptchaAPIKey; + private String reCaptchaProjectID; private String reCaptchaErrorRedirectUrls; @@ -140,6 +142,14 @@ public void setReCaptchaSecretKey(String reCaptchaSecretKey) { this.reCaptchaSecretKey = reCaptchaSecretKey; } + public String getReCaptchaAPIKey() { + return reCaptchaAPIKey; + } + + public void setReCaptchaAPIKey(String reCaptchaAPIKey) { + this.reCaptchaAPIKey = reCaptchaAPIKey; + } + public String getReCaptchaRequestWrapUrls() { return reCaptchaRequestWrapUrls; } diff --git a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaConstants.java b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaConstants.java index 19f59e3e1d..fd9f284922 100644 --- a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaConstants.java +++ b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaConstants.java @@ -49,6 +49,8 @@ public class CaptchaConstants { public static final String RE_CAPTCHA_SECRET_KEY = "recaptcha.secret.key"; + public static final String RE_CAPTCHA_API_KEY = "recaptcha.api.key"; + public static final String RE_CAPTCHA_REQUEST_WRAP_URLS = "recaptcha.request.wrap.urls"; public static final String FAIL_LOGIN_ATTEMPT_VALIDATOR_ENABLED = "failLoginAttemptValidator.enable"; diff --git a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaUtil.java b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaUtil.java index bc4f01a152..875b1e9e6f 100644 --- a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaUtil.java +++ b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaUtil.java @@ -278,9 +278,9 @@ private static HttpPost createReCaptchaEnterpriseVerificationHttpPost(String reC String recaptchaUrl = CaptchaDataHolder.getInstance().getReCaptchaVerifyUrl(); String projectID = CaptchaDataHolder.getInstance().getReCaptchaProjectID(); String siteKey = CaptchaDataHolder.getInstance().getReCaptchaSiteKey(); - String secretKey = CaptchaDataHolder.getInstance().getReCaptchaSecretKey(); + String apiKey = CaptchaDataHolder.getInstance().getReCaptchaAPIKey(); - String verifyUrl = recaptchaUrl + "/v1/projects/" + projectID + "/assessments?key=" + secretKey; + String verifyUrl = recaptchaUrl + "/v1/projects/" + projectID + "/assessments?key=" + apiKey; httpPost = new HttpPost(verifyUrl); httpPost.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); @@ -571,6 +571,19 @@ private static void setReCaptchaConfigs(Properties properties) { throw new RuntimeException(getValidationErrorMessage(CaptchaConstants.RE_CAPTCHA_PROJECT_ID)); } CaptchaDataHolder.getInstance().setReCaptchaProjectID(reCaptchaProjectID); + + String reCaptchaAPIKey = properties.getProperty(CaptchaConstants.RE_CAPTCHA_API_KEY); + if (StringUtils.isBlank(reCaptchaAPIKey)) { + throw new RuntimeException(getValidationErrorMessage(CaptchaConstants.RE_CAPTCHA_API_KEY)); + } + CaptchaDataHolder.getInstance().setReCaptchaAPIKey(reCaptchaAPIKey); + } else { + // Secret Key is only required if recaptcha enterprise is not enabled + String reCaptchaSecretKey = properties.getProperty(CaptchaConstants.RE_CAPTCHA_SECRET_KEY); + if (StringUtils.isBlank(reCaptchaSecretKey)) { + throw new RuntimeException(getValidationErrorMessage(CaptchaConstants.RE_CAPTCHA_SECRET_KEY)); + } + CaptchaDataHolder.getInstance().setReCaptchaSecretKey(reCaptchaSecretKey); } String reCaptchaAPIUrl = properties.getProperty(CaptchaConstants.RE_CAPTCHA_API_URL); @@ -591,12 +604,6 @@ private static void setReCaptchaConfigs(Properties properties) { } CaptchaDataHolder.getInstance().setReCaptchaSiteKey(reCaptchaSiteKey); - String reCaptchaSecretKey = properties.getProperty(CaptchaConstants.RE_CAPTCHA_SECRET_KEY); - if (StringUtils.isBlank(reCaptchaSecretKey)) { - throw new RuntimeException(getValidationErrorMessage(CaptchaConstants.RE_CAPTCHA_SECRET_KEY)); - } - CaptchaDataHolder.getInstance().setReCaptchaSecretKey(reCaptchaSecretKey); - String reCaptchaRequestWrapUrls = properties.getProperty(CaptchaConstants.RE_CAPTCHA_REQUEST_WRAP_URLS); if (reCaptchaRequestWrapUrls == null) { throw new RuntimeException(getValidationErrorMessage(CaptchaConstants.RE_CAPTCHA_REQUEST_WRAP_URLS)); diff --git a/components/org.wso2.carbon.identity.captcha/src/test/java/org/wso2/carbon/identity/captcha/util/CaptchaUtilTest.java b/components/org.wso2.carbon.identity.captcha/src/test/java/org/wso2/carbon/identity/captcha/util/CaptchaUtilTest.java index 37cbdc497e..5d6ee46624 100644 --- a/components/org.wso2.carbon.identity.captcha/src/test/java/org/wso2/carbon/identity/captcha/util/CaptchaUtilTest.java +++ b/components/org.wso2.carbon.identity.captcha/src/test/java/org/wso2/carbon/identity/captcha/util/CaptchaUtilTest.java @@ -40,6 +40,7 @@ public class CaptchaUtilTest { private final String RECAPTCHA_API_URL = "https://www.google.com/recaptcha/api/siteverify"; + private final String RECAPTCHA_ENTERPRISE_API_URL = "https://recaptchaenterprise.googleapis.com"; @BeforeMethod public void setUp() { @@ -103,8 +104,8 @@ private JsonObject getReCaptchaJsonObject(boolean valid, double score) { public void testCreateReCaptchaEnterpriseVerificationHttpPost() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { - CaptchaDataHolder.getInstance().setReCaptchaVerifyUrl(RECAPTCHA_API_URL); - CaptchaDataHolder.getInstance().setReCaptchaSecretKey("dummyKey"); + CaptchaDataHolder.getInstance().setReCaptchaVerifyUrl(RECAPTCHA_ENTERPRISE_API_URL); + CaptchaDataHolder.getInstance().setReCaptchaAPIKey("dummyKey"); CaptchaDataHolder.getInstance().setReCaptchaSiteKey("dummySiteKey"); CaptchaDataHolder.getInstance().setReCaptchaProjectID("dummyProjectId"); @@ -112,7 +113,7 @@ public void testCreateReCaptchaEnterpriseVerificationHttpPost() throws NoSuchMet Method method = getCreateReCaptchaEnterpriseVerificationHttpPostMethod(); HttpPost httpPost = (HttpPost) method.invoke(null, "reCaptchaEnterpriseResponse"); - String expectedURI = RECAPTCHA_API_URL+ "/v1/projects/dummyProjectId/assessments?key=dummyKey"; + String expectedURI = RECAPTCHA_ENTERPRISE_API_URL+ "/v1/projects/dummyProjectId/assessments?key=dummyKey"; Assert.assertEquals(httpPost.getURI().toString(), expectedURI); } diff --git a/features/org.wso2.carbon.identity.captcha.server.feature/resources/conf/captcha-config.properties.j2 b/features/org.wso2.carbon.identity.captcha.server.feature/resources/conf/captcha-config.properties.j2 index bd014187fa..6b8a2a196c 100644 --- a/features/org.wso2.carbon.identity.captcha.server.feature/resources/conf/captcha-config.properties.j2 +++ b/features/org.wso2.carbon.identity.captcha.server.feature/resources/conf/captcha-config.properties.j2 @@ -56,3 +56,6 @@ recaptcha.request.wrap.urls={{recaptcha.request_wrap_urls}} # recaptcha v3 score threshold recaptcha.threshold={{recaptcha.threshold}} + +# reCaptcha API key for enterprise recaptcha +recaptcha.api.key={{recaptcha.api_key}} From d603ed2f95a980a4f05804e9e9bbd7cdf38a0689 Mon Sep 17 00:00:00 2001 From: Lakshan Date: Fri, 8 Sep 2023 09:25:25 +0530 Subject: [PATCH 12/15] Changes based on comments in recaptcha enterprise --- .../recovery/endpoint/Utils/RecoveryUtil.java | 2 +- .../endpoint/impl/CaptchaApiServiceImpl.java | 57 +++++-------- .../impl/CaptchaApiServiceImplTest.java | 1 + .../conf/identity/captcha-config.properties | 3 - .../captcha/util/CaptchaConstants.java | 2 +- .../identity/captcha/util/CaptchaUtil.java | 85 +++++++++---------- .../captcha/util/CaptchaUtilTest.java | 18 ++-- 7 files changed, 74 insertions(+), 94 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java index 1c76ecd912..9d090d0801 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/Utils/RecoveryUtil.java @@ -470,7 +470,7 @@ private static Properties validateCaptchaConfigs(Properties properties) { RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants.RE_CAPTCHA_VERIFY_URL), Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); } - // Check if project id is available for reCaptcha Enterprise + // Check if project id is available for reCaptcha Enterprise. if (CaptchaConstants.RE_CAPTCHA_TYPE_ENTERPRISE.equals(reCaptchaType) && StringUtils.isBlank(properties.getProperty(CaptchaConstants.RE_CAPTCHA_PROJECT_ID))) { RecoveryUtil.handleBadRequest(String.format("%s is not found ", CaptchaConstants diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImpl.java b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImpl.java index 50d928c8ba..fd96ce7afa 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/main/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImpl.java @@ -20,7 +20,6 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpEntity; @@ -90,42 +89,28 @@ public Response verifyCaptcha(ReCaptchaResponseTokenDTO reCaptchaResponse, Strin HttpEntity entity = response.getEntity(); ReCaptchaVerificationResponseDTO reCaptchaVerificationResponseDTO = new ReCaptchaVerificationResponseDTO(); - if (CaptchaConstants.RE_CAPTCHA_TYPE_ENTERPRISE.equals(reCaptchaType)) { - // For ReCaptcha Enterprise. - if (entity == null) { - RecoveryUtil.handleBadRequest("ReCaptcha Enterprise verification response is not received.", - Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); - } - try { - try (InputStream in = entity.getContent()) { - JsonObject verificationResponse = new JsonParser().parse(IOUtils.toString(in)).getAsJsonObject(); - JsonObject tokenProperties = verificationResponse.get(CaptchaConstants.CAPTCHA_TOKEN_PROPERTIES) - .getAsJsonObject(); - boolean success = tokenProperties.get(CaptchaConstants.CAPTCHA_VALID).getAsBoolean(); - reCaptchaVerificationResponseDTO.setSuccess(success); - } - } catch (IOException e) { - log.error("Unable to read the verification response.", e); - RecoveryUtil.handleBadRequest("Unable to read the verification response.", - Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); - } - } else { - // For ReCaptcha v2 and v3. - try { - if (entity == null) { - RecoveryUtil.handleBadRequest("ReCaptcha verification response is not received.", - Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); - } - try (InputStream in = entity.getContent()) { - JsonObject verificationResponse = new JsonParser().parse(IOUtils.toString(in)).getAsJsonObject(); - reCaptchaVerificationResponseDTO.setSuccess(verificationResponse.get( - CaptchaConstants.CAPTCHA_SUCCESS).getAsBoolean()); - } - } catch (IOException e) { - log.error("Unable to read the verification response.", e); - RecoveryUtil.handleBadRequest("Unable to read the verification response.", - Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + if (entity == null) { + RecoveryUtil.handleBadRequest("ReCaptcha verification response is not received.", + Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); + } + try (InputStream in = entity.getContent()) { + JsonObject verificationResponse = new JsonParser().parse(IOUtils.toString(in)).getAsJsonObject(); + + if (CaptchaConstants.RE_CAPTCHA_TYPE_ENTERPRISE.equals(reCaptchaType)) { + // For Recaptcha Enterprise. + JsonObject tokenProperties = verificationResponse.get(CaptchaConstants.CAPTCHA_TOKEN_PROPERTIES) + .getAsJsonObject(); + boolean success = tokenProperties.get(CaptchaConstants.CAPTCHA_VALID).getAsBoolean(); + reCaptchaVerificationResponseDTO.setSuccess(success); + } else { + // For ReCaptcha v2 and v3. + reCaptchaVerificationResponseDTO.setSuccess(verificationResponse.get( + CaptchaConstants.CAPTCHA_SUCCESS).getAsBoolean()); } + } catch (IOException e) { + log.error("Unable to read the verification response.", e); + RecoveryUtil.handleBadRequest("Unable to read the verification response.", + Constants.STATUS_INTERNAL_SERVER_ERROR_MESSAGE_DEFAULT); } return Response.ok(reCaptchaVerificationResponseDTO).build(); diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/test/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImplTest.java b/components/org.wso2.carbon.identity.api.user.recovery/src/test/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImplTest.java index 354792e128..c78f19b42e 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/test/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImplTest.java +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/test/java/org/wso2/carbon/identity/recovery/endpoint/impl/CaptchaApiServiceImplTest.java @@ -109,6 +109,7 @@ public void testGetCaptcha(boolean reCaptchaEnabled, String reCaptchaType, } public Properties getSampleConfigFile() throws IOException { + Path path = Paths.get("src/test/resources", "repository", "conf", "identity", CaptchaConstants.CAPTCHA_CONFIG_FILE_NAME); Properties sampleProperties = new Properties(); diff --git a/components/org.wso2.carbon.identity.api.user.recovery/src/test/resources/repository/conf/identity/captcha-config.properties b/components/org.wso2.carbon.identity.api.user.recovery/src/test/resources/repository/conf/identity/captcha-config.properties index b920c175db..7980a19a37 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/src/test/resources/repository/conf/identity/captcha-config.properties +++ b/components/org.wso2.carbon.identity.api.user.recovery/src/test/resources/repository/conf/identity/captcha-config.properties @@ -21,9 +21,6 @@ # Enable Google reCAPTCHA recaptcha.enabled=true -# Google reCAPTCHA type -recaptcha.type=default - # reCaptcha API URL recaptcha.api.url=https://www.google.com/recaptcha/api.js diff --git a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaConstants.java b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaConstants.java index fd9f284922..742865a234 100644 --- a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaConstants.java +++ b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaConstants.java @@ -76,7 +76,7 @@ public class CaptchaConstants { public static final String CAPTCHA_TOKEN_PROPERTIES = "tokenProperties"; public static final String CAPTCHA_RISK_ANALYSIS = "riskAnalysis"; // Captcha Types. - public static final String RE_CAPTCHA_TYPE_ENTERPRISE = "enterprise"; + public static final String RE_CAPTCHA_TYPE_ENTERPRISE = "recaptcha-enterprise"; // Default value for threshold for score in reCAPTCHA v3. public static final double CAPTCHA_V3_DEFAULT_THRESHOLD = 0.5; diff --git a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaUtil.java b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaUtil.java index 875b1e9e6f..8162079049 100644 --- a/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaUtil.java +++ b/components/org.wso2.carbon.identity.captcha/src/main/java/org/wso2/carbon/identity/captcha/util/CaptchaUtil.java @@ -22,7 +22,6 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import org.apache.commons.collections.MapUtils; -import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.math.NumberUtils; import org.apache.commons.logging.Log; @@ -272,6 +271,46 @@ public static Map getClaimValues(User user, int tenantId, return claimValues; } + public static boolean isValidCaptcha(String reCaptchaResponse) throws CaptchaException { + + CloseableHttpClient httpclient = HttpClientBuilder.create().useSystemProperties().build(); + String reCaptchaType = CaptchaDataHolder.getInstance().getReCaptchaType(); + + HttpPost httpPost; + + // If the reCaptcha type is defined and, it is enterprise, the enterprise process will be done. Otherwise, + // the reCaptcha v2/v3 process will be done. + if (CaptchaConstants.RE_CAPTCHA_TYPE_ENTERPRISE.equals(reCaptchaType)) { + // For ReCaptcha Enterprise. + httpPost = createReCaptchaEnterpriseVerificationHttpPost(reCaptchaResponse); + } else { + // For ReCaptcha v2 and v3. + httpPost = createReCaptchaVerificationHttpPost(reCaptchaResponse); + } + + HttpResponse response; + try { + response = httpclient.execute(httpPost); + } catch (IOException e) { + throw new CaptchaServerException("Unable to get the verification response.", e); + } + + HttpEntity entity = response.getEntity(); + if (entity == null) { + throw new CaptchaServerException("reCaptcha verification response is not received."); + } + + if (CaptchaConstants.RE_CAPTCHA_TYPE_ENTERPRISE.equals(reCaptchaType)) { + // For ReCaptcha Enterprise. + verifyReCaptchaEnterpriseResponse(entity); + } else { + // For Recaptcha v2 and v3. + verifyReCaptchaResponse(entity); + } + + return true; + } + private static HttpPost createReCaptchaEnterpriseVerificationHttpPost(String reCaptchaResponse) { HttpPost httpPost; @@ -394,46 +433,6 @@ private static void verifyReCaptchaResponse(HttpEntity entity) } } - public static boolean isValidCaptcha(String reCaptchaResponse) throws CaptchaException { - - CloseableHttpClient httpclient = HttpClientBuilder.create().useSystemProperties().build(); - String reCaptchaType = CaptchaDataHolder.getInstance().getReCaptchaType(); - - HttpPost httpPost; - - // If the reCaptcha type is defined and, it is enterprise, the enterprise process will be done. Otherwise, - // the reCaptcha v2/v3 process will be done. - if (CaptchaConstants.RE_CAPTCHA_TYPE_ENTERPRISE.equals(reCaptchaType)) { - // For ReCaptcha Enterprise. - httpPost = createReCaptchaEnterpriseVerificationHttpPost(reCaptchaResponse); - } else { - // For ReCaptcha v2 and v3. - httpPost = createReCaptchaVerificationHttpPost(reCaptchaResponse); - } - - HttpResponse response; - try { - response = httpclient.execute(httpPost); - } catch (IOException e) { - throw new CaptchaServerException("Unable to get the verification response.", e); - } - - HttpEntity entity = response.getEntity(); - if (entity == null) { - throw new CaptchaServerException("reCaptcha verification response is not received."); - } - - if (CaptchaConstants.RE_CAPTCHA_TYPE_ENTERPRISE.equals(reCaptchaType)) { - // For ReCaptcha Enterprise. - verifyReCaptchaEnterpriseResponse(entity); - } else { - // For Recaptcha v2 and v3. - verifyReCaptchaResponse(entity); - } - - return true; - } - public static boolean isMaximumFailedLoginAttemptsReached(String usernameWithDomain, String tenantDomain) throws CaptchaException { @@ -578,7 +577,7 @@ private static void setReCaptchaConfigs(Properties properties) { } CaptchaDataHolder.getInstance().setReCaptchaAPIKey(reCaptchaAPIKey); } else { - // Secret Key is only required if recaptcha enterprise is not enabled + // Secret Key is only required if recaptcha enterprise is not enabled. String reCaptchaSecretKey = properties.getProperty(CaptchaConstants.RE_CAPTCHA_SECRET_KEY); if (StringUtils.isBlank(reCaptchaSecretKey)) { throw new RuntimeException(getValidationErrorMessage(CaptchaConstants.RE_CAPTCHA_SECRET_KEY)); @@ -820,7 +819,7 @@ public static Boolean isReCaptchaEnabled() { * Get the ReCaptcha Type. * @return ReCaptcha Type as a String. */ - public static String reCaptchaType() { + public static String getReCaptchaType() { return CaptchaDataHolder.getInstance().getReCaptchaType(); } diff --git a/components/org.wso2.carbon.identity.captcha/src/test/java/org/wso2/carbon/identity/captcha/util/CaptchaUtilTest.java b/components/org.wso2.carbon.identity.captcha/src/test/java/org/wso2/carbon/identity/captcha/util/CaptchaUtilTest.java index 5d6ee46624..0a8083d3c4 100644 --- a/components/org.wso2.carbon.identity.captcha/src/test/java/org/wso2/carbon/identity/captcha/util/CaptchaUtilTest.java +++ b/components/org.wso2.carbon.identity.captcha/src/test/java/org/wso2/carbon/identity/captcha/util/CaptchaUtilTest.java @@ -22,7 +22,6 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.testng.Assert; -import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.wso2.carbon.identity.captcha.internal.CaptchaDataHolder; @@ -32,7 +31,8 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import static org.testng.Assert.*; + +import static org.testng.Assert.assertThrows; /** * Unit tests for CaptchaUtil.java @@ -109,8 +109,6 @@ public void testCreateReCaptchaEnterpriseVerificationHttpPost() throws NoSuchMet CaptchaDataHolder.getInstance().setReCaptchaSiteKey("dummySiteKey"); CaptchaDataHolder.getInstance().setReCaptchaProjectID("dummyProjectId"); - - Method method = getCreateReCaptchaEnterpriseVerificationHttpPostMethod(); HttpPost httpPost = (HttpPost) method.invoke(null, "reCaptchaEnterpriseResponse"); String expectedURI = RECAPTCHA_ENTERPRISE_API_URL+ "/v1/projects/dummyProjectId/assessments?key=dummyKey"; @@ -145,7 +143,7 @@ public void testVerifyReCaptchaEnterpriseResponseWithHighScore() throws IOExcept HttpEntity httpEntity = Mockito.mock(HttpEntity.class); Mockito.when(httpEntity.getContent()).thenReturn(new ByteArrayInputStream( verificationResponse.toString().getBytes())); - // verify no exception is thrown for high score + // Verify no exception is thrown for high score. method.invoke(null, httpEntity); } @@ -160,7 +158,7 @@ public void testVerifyReCaptchaEnterpriseResponseWithLowScore() throws IOExcepti HttpEntity httpEntity = Mockito.mock(HttpEntity.class); Mockito.when(httpEntity.getContent()).thenReturn(new ByteArrayInputStream(verificationResponse.toString(). getBytes())); - // verify an exception is thrown for low score + // Verify an exception is thrown for low score. assertThrows(InvocationTargetException.class, () -> method.invoke(null, httpEntity)); } @@ -175,7 +173,7 @@ public void testVerifyReCaptchaEnterpriseResponseWithInvalidResponse() throws IO HttpEntity httpEntity = Mockito.mock(HttpEntity.class); Mockito.when(httpEntity.getContent()).thenReturn(new ByteArrayInputStream(verificationResponse. toString().getBytes())); - // verify an exception is thrown for invalid response + // Verify an exception is thrown for invalid response. assertThrows(InvocationTargetException.class, () -> method.invoke(null, httpEntity)); } @@ -191,7 +189,7 @@ public void testVerifyReCaptchaResponseWithHighScore() throws IOException, NoSuc HttpEntity httpEntity = Mockito.mock(HttpEntity.class); Mockito.when(httpEntity.getContent()).thenReturn(new ByteArrayInputStream(verificationResponse.toString(). getBytes())); - // verify no exception is thrown for high score + // Verify no exception is thrown for high score. method.invoke(null, httpEntity); } @@ -206,7 +204,7 @@ public void testVerifyReCaptchaResponseWithLowScore() throws IOException, NoSuch HttpEntity httpEntity = Mockito.mock(HttpEntity.class); Mockito.when(httpEntity.getContent()).thenReturn(new ByteArrayInputStream(verificationResponse.toString(). getBytes())); - // verify no exception is thrown for low score + // Verify no exception is thrown for low score. assertThrows(InvocationTargetException.class, () -> method.invoke(null, httpEntity)); } @@ -221,7 +219,7 @@ public void testVerifyReCaptchaResponseWithInvalidResponse() throws IOException, HttpEntity httpEntity = Mockito.mock(HttpEntity.class); Mockito.when(httpEntity.getContent()).thenReturn(new ByteArrayInputStream(verificationResponse.toString(). getBytes())); - // verify no exception is thrown for invalid response + // Verify no exception is thrown for invalid response. assertThrows(InvocationTargetException.class, () -> method.invoke(null, httpEntity)); } } From a44fb3136e9d073d6e606d6a5abae3f6af280b39 Mon Sep 17 00:00:00 2001 From: Thumimku Date: Tue, 12 Sep 2023 10:50:14 +0530 Subject: [PATCH 13/15] move service registration to service component --- .../policy/handler/PasswordPolicyValidationHandler.java | 2 -- .../internal/IdentityPasswordPolicyServiceComponent.java | 7 +++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/components/org.wso2.carbon.identity.password.policy/src/main/java/org/wso2/carbon/identity/password/policy/handler/PasswordPolicyValidationHandler.java b/components/org.wso2.carbon.identity.password.policy/src/main/java/org/wso2/carbon/identity/password/policy/handler/PasswordPolicyValidationHandler.java index 7a34f02f00..f31fefdd28 100644 --- a/components/org.wso2.carbon.identity.password.policy/src/main/java/org/wso2/carbon/identity/password/policy/handler/PasswordPolicyValidationHandler.java +++ b/components/org.wso2.carbon.identity.password.policy/src/main/java/org/wso2/carbon/identity/password/policy/handler/PasswordPolicyValidationHandler.java @@ -232,8 +232,6 @@ public Map getPropertyDescriptionMapping() { public void init(InitConfig configuration) throws IdentityRuntimeException { super.init(configuration); - IdentityPasswordPolicyServiceDataHolder.getInstance().getBundleContext().registerService - (IdentityConnectorConfig.class.getName(), this, null); } public String[] getPropertyNames() { diff --git a/components/org.wso2.carbon.identity.password.policy/src/main/java/org/wso2/carbon/identity/password/policy/internal/IdentityPasswordPolicyServiceComponent.java b/components/org.wso2.carbon.identity.password.policy/src/main/java/org/wso2/carbon/identity/password/policy/internal/IdentityPasswordPolicyServiceComponent.java index 6edaba1956..63fc3e21a8 100644 --- a/components/org.wso2.carbon.identity.password.policy/src/main/java/org/wso2/carbon/identity/password/policy/internal/IdentityPasswordPolicyServiceComponent.java +++ b/components/org.wso2.carbon.identity.password.policy/src/main/java/org/wso2/carbon/identity/password/policy/internal/IdentityPasswordPolicyServiceComponent.java @@ -21,6 +21,7 @@ import org.osgi.service.component.ComponentContext; import org.wso2.carbon.identity.event.handler.AbstractEventHandler; import org.wso2.carbon.identity.governance.IdentityGovernanceService; +import org.wso2.carbon.identity.governance.common.IdentityConnectorConfig; import org.wso2.carbon.identity.password.policy.handler.PasswordPolicyValidationHandler; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; @@ -43,11 +44,13 @@ protected void activate(ComponentContext context) { if (log.isDebugEnabled()) { log.debug("Password Policy Service component is enabled"); } + BundleContext bundleContext = context.getBundleContext(); + IdentityPasswordPolicyServiceDataHolder.getInstance().setBundleContext(bundleContext); if (IdentityPasswordPolicyServiceDataHolder.getInstance().isPasswordPolicyHandlerEnabled()) { - BundleContext bundleContext = context.getBundleContext(); - IdentityPasswordPolicyServiceDataHolder.getInstance().setBundleContext(bundleContext); + PasswordPolicyValidationHandler handler = new PasswordPolicyValidationHandler(); context.getBundleContext().registerService(AbstractEventHandler.class.getName(), handler, null); + context.getBundleContext().registerService(IdentityConnectorConfig.class.getName(), handler, null); } else { if (log.isDebugEnabled()) { log.debug("Password Policy Validation Handler is disabled."); From 84312880339b5f0b99a80982326043936c2a294e Mon Sep 17 00:00:00 2001 From: WSO2 Builder Date: Fri, 15 Sep 2023 04:21:07 +0000 Subject: [PATCH 14/15] [WSO2 Release] [Jenkins #2541] [Release 1.8.67] prepare release v1.8.67 --- .../pom.xml | 2 +- .../org.wso2.carbon.identity.api.user.governance/pom.xml | 4 ++-- components/org.wso2.carbon.identity.api.user.recovery/pom.xml | 4 ++-- .../org.wso2.carbon.identity.auth.attribute.handler/pom.xml | 2 +- components/org.wso2.carbon.identity.captcha/pom.xml | 2 +- components/org.wso2.carbon.identity.governance/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../org.wso2.carbon.identity.multi.attribute.login/pom.xml | 2 +- components/org.wso2.carbon.identity.password.expiry/pom.xml | 2 +- components/org.wso2.carbon.identity.password.history/pom.xml | 2 +- components/org.wso2.carbon.identity.password.policy/pom.xml | 2 +- components/org.wso2.carbon.identity.piicontroller/pom.xml | 2 +- components/org.wso2.carbon.identity.recovery.endpoint/pom.xml | 2 +- components/org.wso2.carbon.identity.recovery.ui/pom.xml | 2 +- components/org.wso2.carbon.identity.recovery/pom.xml | 2 +- .../org.wso2.carbon.identity.tenant.resource.manager/pom.xml | 2 +- components/org.wso2.carbon.identity.user.endpoint/pom.xml | 2 +- components/org.wso2.carbon.identity.user.export.core/pom.xml | 2 +- components/org.wso2.carbon.identity.user.rename.core/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../org.wso2.carbon.identity.captcha.server.feature/pom.xml | 2 +- features/org.wso2.carbon.identity.governance.feature/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../org.wso2.carbon.identity.recovery.server.feature/pom.xml | 2 +- features/org.wso2.carbon.identity.recovery.ui.feature/pom.xml | 2 +- .../pom.xml | 2 +- features/org.wso2.carbon.identity.user.server.feature/pom.xml | 2 +- pom.xml | 4 ++-- .../identity/org.wso2.carbon.identity.recovery.stub/pom.xml | 2 +- service-stubs/identity/pom.xml | 2 +- 39 files changed, 42 insertions(+), 42 deletions(-) diff --git a/components/org.wso2.carbon.identity.account.suspension.notification.task/pom.xml b/components/org.wso2.carbon.identity.account.suspension.notification.task/pom.xml index bdcfa91d2a..503fea646e 100644 --- a/components/org.wso2.carbon.identity.account.suspension.notification.task/pom.xml +++ b/components/org.wso2.carbon.identity.account.suspension.notification.task/pom.xml @@ -20,7 +20,7 @@ identity-governance org.wso2.carbon.identity.governance - 1.8.67-SNAPSHOT + 1.8.67 ../../pom.xml diff --git a/components/org.wso2.carbon.identity.api.user.governance/pom.xml b/components/org.wso2.carbon.identity.api.user.governance/pom.xml index 019118e436..4825c6c872 100644 --- a/components/org.wso2.carbon.identity.api.user.governance/pom.xml +++ b/components/org.wso2.carbon.identity.api.user.governance/pom.xml @@ -23,12 +23,12 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67-SNAPSHOT + 1.8.67 ../.. org.wso2.carbon.identity.api.user.governance - 1.8.67-SNAPSHOT + 1.8.67 jar WSO2 Carbon - User Rest Governance API WSO2 Carbon - User Rest Governance API diff --git a/components/org.wso2.carbon.identity.api.user.recovery/pom.xml b/components/org.wso2.carbon.identity.api.user.recovery/pom.xml index 181f52210e..9dcf07771b 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/pom.xml +++ b/components/org.wso2.carbon.identity.api.user.recovery/pom.xml @@ -23,12 +23,12 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67-SNAPSHOT + 1.8.67 ../.. org.wso2.carbon.identity.api.user.recovery - 1.8.67-SNAPSHOT + 1.8.67 jar WSO2 Carbon - Identity Management Recovery Rest API WSO2 Carbon - Identity Management Recovery Rest API diff --git a/components/org.wso2.carbon.identity.auth.attribute.handler/pom.xml b/components/org.wso2.carbon.identity.auth.attribute.handler/pom.xml index d0632232e5..821fd3eedc 100644 --- a/components/org.wso2.carbon.identity.auth.attribute.handler/pom.xml +++ b/components/org.wso2.carbon.identity.auth.attribute.handler/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67-SNAPSHOT + 1.8.67 ../../pom.xml diff --git a/components/org.wso2.carbon.identity.captcha/pom.xml b/components/org.wso2.carbon.identity.captcha/pom.xml index 5c07f7c845..1cff907ce3 100644 --- a/components/org.wso2.carbon.identity.captcha/pom.xml +++ b/components/org.wso2.carbon.identity.captcha/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67-SNAPSHOT + 1.8.67 ../../pom.xml diff --git a/components/org.wso2.carbon.identity.governance/pom.xml b/components/org.wso2.carbon.identity.governance/pom.xml index 3bfdb2b6d4..5171e34a29 100644 --- a/components/org.wso2.carbon.identity.governance/pom.xml +++ b/components/org.wso2.carbon.identity.governance/pom.xml @@ -18,7 +18,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67-SNAPSHOT + 1.8.67 ../../pom.xml diff --git a/components/org.wso2.carbon.identity.idle.account.identification/pom.xml b/components/org.wso2.carbon.identity.idle.account.identification/pom.xml index b29c53a5c7..35a22f2d6a 100644 --- a/components/org.wso2.carbon.identity.idle.account.identification/pom.xml +++ b/components/org.wso2.carbon.identity.idle.account.identification/pom.xml @@ -18,7 +18,7 @@ identity-governance org.wso2.carbon.identity.governance - 1.8.67-SNAPSHOT + 1.8.67 ../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.multi.attribute.login/org.wso2.carbon.identity.multi.attribute.login.resolver.regex/pom.xml b/components/org.wso2.carbon.identity.multi.attribute.login/org.wso2.carbon.identity.multi.attribute.login.resolver.regex/pom.xml index e3059753a1..264d3429d1 100644 --- a/components/org.wso2.carbon.identity.multi.attribute.login/org.wso2.carbon.identity.multi.attribute.login.resolver.regex/pom.xml +++ b/components/org.wso2.carbon.identity.multi.attribute.login/org.wso2.carbon.identity.multi.attribute.login.resolver.regex/pom.xml @@ -21,7 +21,7 @@ identity-governance org.wso2.carbon.identity.governance - 1.8.67-SNAPSHOT + 1.8.67 ../../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.multi.attribute.login/org.wso2.carbon.identity.multi.attribute.login.service/pom.xml b/components/org.wso2.carbon.identity.multi.attribute.login/org.wso2.carbon.identity.multi.attribute.login.service/pom.xml index 040adddfa7..bc69ffea6a 100644 --- a/components/org.wso2.carbon.identity.multi.attribute.login/org.wso2.carbon.identity.multi.attribute.login.service/pom.xml +++ b/components/org.wso2.carbon.identity.multi.attribute.login/org.wso2.carbon.identity.multi.attribute.login.service/pom.xml @@ -21,7 +21,7 @@ identity-governance org.wso2.carbon.identity.governance - 1.8.67-SNAPSHOT + 1.8.67 ../../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.multi.attribute.login/pom.xml b/components/org.wso2.carbon.identity.multi.attribute.login/pom.xml index cf4de86c55..a6c5a4d54e 100644 --- a/components/org.wso2.carbon.identity.multi.attribute.login/pom.xml +++ b/components/org.wso2.carbon.identity.multi.attribute.login/pom.xml @@ -21,7 +21,7 @@ identity-governance org.wso2.carbon.identity.governance - 1.8.67-SNAPSHOT + 1.8.67 ../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.password.expiry/pom.xml b/components/org.wso2.carbon.identity.password.expiry/pom.xml index 665cf57f83..639f6a4e5f 100644 --- a/components/org.wso2.carbon.identity.password.expiry/pom.xml +++ b/components/org.wso2.carbon.identity.password.expiry/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67-SNAPSHOT + 1.8.67 ../../pom.xml diff --git a/components/org.wso2.carbon.identity.password.history/pom.xml b/components/org.wso2.carbon.identity.password.history/pom.xml index 67d072ba13..58de0ccb50 100644 --- a/components/org.wso2.carbon.identity.password.history/pom.xml +++ b/components/org.wso2.carbon.identity.password.history/pom.xml @@ -18,7 +18,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67-SNAPSHOT + 1.8.67 ../../pom.xml diff --git a/components/org.wso2.carbon.identity.password.policy/pom.xml b/components/org.wso2.carbon.identity.password.policy/pom.xml index f144af7828..70c1a1adc1 100644 --- a/components/org.wso2.carbon.identity.password.policy/pom.xml +++ b/components/org.wso2.carbon.identity.password.policy/pom.xml @@ -18,7 +18,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67-SNAPSHOT + 1.8.67 ../../pom.xml diff --git a/components/org.wso2.carbon.identity.piicontroller/pom.xml b/components/org.wso2.carbon.identity.piicontroller/pom.xml index b41f4b10ec..d55dc252a0 100644 --- a/components/org.wso2.carbon.identity.piicontroller/pom.xml +++ b/components/org.wso2.carbon.identity.piicontroller/pom.xml @@ -19,7 +19,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67-SNAPSHOT + 1.8.67 ../../pom.xml diff --git a/components/org.wso2.carbon.identity.recovery.endpoint/pom.xml b/components/org.wso2.carbon.identity.recovery.endpoint/pom.xml index 803fc34fe6..3474a74c53 100644 --- a/components/org.wso2.carbon.identity.recovery.endpoint/pom.xml +++ b/components/org.wso2.carbon.identity.recovery.endpoint/pom.xml @@ -5,7 +5,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67-SNAPSHOT + 1.8.67 ../../pom.xml diff --git a/components/org.wso2.carbon.identity.recovery.ui/pom.xml b/components/org.wso2.carbon.identity.recovery.ui/pom.xml index 2aa2e4d61c..74cfd6e029 100644 --- a/components/org.wso2.carbon.identity.recovery.ui/pom.xml +++ b/components/org.wso2.carbon.identity.recovery.ui/pom.xml @@ -18,7 +18,7 @@ identity-governance org.wso2.carbon.identity.governance - 1.8.67-SNAPSHOT + 1.8.67 ../../pom.xml diff --git a/components/org.wso2.carbon.identity.recovery/pom.xml b/components/org.wso2.carbon.identity.recovery/pom.xml index 3d39409ece..97ffebcfd0 100644 --- a/components/org.wso2.carbon.identity.recovery/pom.xml +++ b/components/org.wso2.carbon.identity.recovery/pom.xml @@ -18,7 +18,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67-SNAPSHOT + 1.8.67 ../../pom.xml diff --git a/components/org.wso2.carbon.identity.tenant.resource.manager/pom.xml b/components/org.wso2.carbon.identity.tenant.resource.manager/pom.xml index fce1911a1b..8c210bdd4d 100644 --- a/components/org.wso2.carbon.identity.tenant.resource.manager/pom.xml +++ b/components/org.wso2.carbon.identity.tenant.resource.manager/pom.xml @@ -22,7 +22,7 @@ identity-governance org.wso2.carbon.identity.governance - 1.8.67-SNAPSHOT + 1.8.67 ../../pom.xml diff --git a/components/org.wso2.carbon.identity.user.endpoint/pom.xml b/components/org.wso2.carbon.identity.user.endpoint/pom.xml index c45312d439..9b004f96dc 100644 --- a/components/org.wso2.carbon.identity.user.endpoint/pom.xml +++ b/components/org.wso2.carbon.identity.user.endpoint/pom.xml @@ -5,7 +5,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67-SNAPSHOT + 1.8.67 ../../pom.xml diff --git a/components/org.wso2.carbon.identity.user.export.core/pom.xml b/components/org.wso2.carbon.identity.user.export.core/pom.xml index 434d769e25..d068c06289 100644 --- a/components/org.wso2.carbon.identity.user.export.core/pom.xml +++ b/components/org.wso2.carbon.identity.user.export.core/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67-SNAPSHOT + 1.8.67 ../../pom.xml diff --git a/components/org.wso2.carbon.identity.user.rename.core/pom.xml b/components/org.wso2.carbon.identity.user.rename.core/pom.xml index 7682b065cb..43948485b6 100644 --- a/components/org.wso2.carbon.identity.user.rename.core/pom.xml +++ b/components/org.wso2.carbon.identity.user.rename.core/pom.xml @@ -20,7 +20,7 @@ identity-governance org.wso2.carbon.identity.governance - 1.8.67-SNAPSHOT + 1.8.67 ../../pom.xml 4.0.0 diff --git a/features/org.wso2.carbon.identity.account.suspension.notification.task.server.feature/pom.xml b/features/org.wso2.carbon.identity.account.suspension.notification.task.server.feature/pom.xml index 7b6d207c51..f49359f857 100644 --- a/features/org.wso2.carbon.identity.account.suspension.notification.task.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.account.suspension.notification.task.server.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.governance identity-governance ../../pom.xml - 1.8.67-SNAPSHOT + 1.8.67 4.0.0 diff --git a/features/org.wso2.carbon.identity.auth.attribute.handler.server.feature/pom.xml b/features/org.wso2.carbon.identity.auth.attribute.handler.server.feature/pom.xml index b4f6654767..2005bb9e76 100644 --- a/features/org.wso2.carbon.identity.auth.attribute.handler.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.auth.attribute.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.governance identity-governance ../../pom.xml - 1.8.67-SNAPSHOT + 1.8.67 4.0.0 diff --git a/features/org.wso2.carbon.identity.captcha.server.feature/pom.xml b/features/org.wso2.carbon.identity.captcha.server.feature/pom.xml index 0d79c4ff45..177ad1c7d3 100644 --- a/features/org.wso2.carbon.identity.captcha.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.captcha.server.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.governance identity-governance ../../pom.xml - 1.8.67-SNAPSHOT + 1.8.67 4.0.0 diff --git a/features/org.wso2.carbon.identity.governance.feature/pom.xml b/features/org.wso2.carbon.identity.governance.feature/pom.xml index 8ce4b95c45..509152e1d8 100644 --- a/features/org.wso2.carbon.identity.governance.feature/pom.xml +++ b/features/org.wso2.carbon.identity.governance.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67-SNAPSHOT + 1.8.67 ../../pom.xml diff --git a/features/org.wso2.carbon.identity.governance.server.feature/pom.xml b/features/org.wso2.carbon.identity.governance.server.feature/pom.xml index 22162090b6..42be2deb1e 100644 --- a/features/org.wso2.carbon.identity.governance.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.governance.server.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.governance identity-governance ../../pom.xml - 1.8.67-SNAPSHOT + 1.8.67 4.0.0 diff --git a/features/org.wso2.carbon.identity.idle.account.identification.server.feature/pom.xml b/features/org.wso2.carbon.identity.idle.account.identification.server.feature/pom.xml index fe967ce49b..2e201bf336 100644 --- a/features/org.wso2.carbon.identity.idle.account.identification.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.idle.account.identification.server.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.governance identity-governance ../../pom.xml - 1.8.67-SNAPSHOT + 1.8.67 4.0.0 diff --git a/features/org.wso2.carbon.identity.multi.attribute.login.service.server.feature/pom.xml b/features/org.wso2.carbon.identity.multi.attribute.login.service.server.feature/pom.xml index ad0b43460f..d3042a7ce5 100644 --- a/features/org.wso2.carbon.identity.multi.attribute.login.service.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.multi.attribute.login.service.server.feature/pom.xml @@ -3,7 +3,7 @@ identity-governance org.wso2.carbon.identity.governance - 1.8.67-SNAPSHOT + 1.8.67 ../../pom.xml 4.0.0 diff --git a/features/org.wso2.carbon.identity.password.expiry.server.feature/pom.xml b/features/org.wso2.carbon.identity.password.expiry.server.feature/pom.xml index cccbb199c2..219e4ba300 100644 --- a/features/org.wso2.carbon.identity.password.expiry.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.password.expiry.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.governance identity-governance ../../pom.xml - 1.8.67-SNAPSHOT + 1.8.67 4.0.0 diff --git a/features/org.wso2.carbon.identity.password.history.server.feature/pom.xml b/features/org.wso2.carbon.identity.password.history.server.feature/pom.xml index bf9668063d..f62a74a5e2 100644 --- a/features/org.wso2.carbon.identity.password.history.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.password.history.server.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.governance identity-governance ../../pom.xml - 1.8.67-SNAPSHOT + 1.8.67 4.0.0 diff --git a/features/org.wso2.carbon.identity.password.policy.server.feature/pom.xml b/features/org.wso2.carbon.identity.password.policy.server.feature/pom.xml index 12111994ce..3d7d2f089b 100644 --- a/features/org.wso2.carbon.identity.password.policy.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.password.policy.server.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.governance identity-governance ../../pom.xml - 1.8.67-SNAPSHOT + 1.8.67 4.0.0 diff --git a/features/org.wso2.carbon.identity.piicontroller.server.feature/pom.xml b/features/org.wso2.carbon.identity.piicontroller.server.feature/pom.xml index ac1c7e66ce..af5fdf8c4e 100644 --- a/features/org.wso2.carbon.identity.piicontroller.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.piicontroller.server.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.governance identity-governance ../../pom.xml - 1.8.67-SNAPSHOT + 1.8.67 4.0.0 diff --git a/features/org.wso2.carbon.identity.recovery.server.feature/pom.xml b/features/org.wso2.carbon.identity.recovery.server.feature/pom.xml index e23f6a549c..bd0e8810df 100644 --- a/features/org.wso2.carbon.identity.recovery.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.recovery.server.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.governance identity-governance ../../pom.xml - 1.8.67-SNAPSHOT + 1.8.67 4.0.0 diff --git a/features/org.wso2.carbon.identity.recovery.ui.feature/pom.xml b/features/org.wso2.carbon.identity.recovery.ui.feature/pom.xml index 00ab362af8..352d02b217 100644 --- a/features/org.wso2.carbon.identity.recovery.ui.feature/pom.xml +++ b/features/org.wso2.carbon.identity.recovery.ui.feature/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67-SNAPSHOT + 1.8.67 ../../pom.xml diff --git a/features/org.wso2.carbon.identity.tenant.resource.manager.feature/pom.xml b/features/org.wso2.carbon.identity.tenant.resource.manager.feature/pom.xml index 341275cc16..880b655ae8 100644 --- a/features/org.wso2.carbon.identity.tenant.resource.manager.feature/pom.xml +++ b/features/org.wso2.carbon.identity.tenant.resource.manager.feature/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67-SNAPSHOT + 1.8.67 ../../pom.xml diff --git a/features/org.wso2.carbon.identity.user.server.feature/pom.xml b/features/org.wso2.carbon.identity.user.server.feature/pom.xml index 0d97546cac..71a379457d 100644 --- a/features/org.wso2.carbon.identity.user.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.user.server.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.governance identity-governance ../../pom.xml - 1.8.67-SNAPSHOT + 1.8.67 4.0.0 diff --git a/pom.xml b/pom.xml index 8202c8d0a9..ec2409590f 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67-SNAPSHOT + 1.8.67 4.0.0 pom WSO2 Carbon - Governance Module @@ -37,7 +37,7 @@ https://github.com/wso2-extensions/identity-governance.git scm:git:https://github.com/wso2-extensions/identity-governance.git scm:git:https://github.com/wso2-extensions/identity-governance.git - v1.1.0-SNAPSHOT + v1.8.67 diff --git a/service-stubs/identity/org.wso2.carbon.identity.recovery.stub/pom.xml b/service-stubs/identity/org.wso2.carbon.identity.recovery.stub/pom.xml index 69901e4f05..0e01c677e9 100644 --- a/service-stubs/identity/org.wso2.carbon.identity.recovery.stub/pom.xml +++ b/service-stubs/identity/org.wso2.carbon.identity.recovery.stub/pom.xml @@ -19,7 +19,7 @@ org.wso2.carbon.identity.governance carbon-service-stubs - 1.8.67-SNAPSHOT + 1.8.67 ../pom.xml diff --git a/service-stubs/identity/pom.xml b/service-stubs/identity/pom.xml index 3fa6493f98..77c286ccb1 100644 --- a/service-stubs/identity/pom.xml +++ b/service-stubs/identity/pom.xml @@ -19,7 +19,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67-SNAPSHOT + 1.8.67 ../../pom.xml From fdb9a1e75ca5c3e521b1ef036f5c129a5ba291cc Mon Sep 17 00:00:00 2001 From: WSO2 Builder Date: Fri, 15 Sep 2023 04:21:09 +0000 Subject: [PATCH 15/15] [WSO2 Release] [Jenkins #2541] [Release 1.8.67] prepare for next development iteration --- .../pom.xml | 2 +- .../org.wso2.carbon.identity.api.user.governance/pom.xml | 4 ++-- components/org.wso2.carbon.identity.api.user.recovery/pom.xml | 4 ++-- .../org.wso2.carbon.identity.auth.attribute.handler/pom.xml | 2 +- components/org.wso2.carbon.identity.captcha/pom.xml | 2 +- components/org.wso2.carbon.identity.governance/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../org.wso2.carbon.identity.multi.attribute.login/pom.xml | 2 +- components/org.wso2.carbon.identity.password.expiry/pom.xml | 2 +- components/org.wso2.carbon.identity.password.history/pom.xml | 2 +- components/org.wso2.carbon.identity.password.policy/pom.xml | 2 +- components/org.wso2.carbon.identity.piicontroller/pom.xml | 2 +- components/org.wso2.carbon.identity.recovery.endpoint/pom.xml | 2 +- components/org.wso2.carbon.identity.recovery.ui/pom.xml | 2 +- components/org.wso2.carbon.identity.recovery/pom.xml | 2 +- .../org.wso2.carbon.identity.tenant.resource.manager/pom.xml | 2 +- components/org.wso2.carbon.identity.user.endpoint/pom.xml | 2 +- components/org.wso2.carbon.identity.user.export.core/pom.xml | 2 +- components/org.wso2.carbon.identity.user.rename.core/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../org.wso2.carbon.identity.captcha.server.feature/pom.xml | 2 +- features/org.wso2.carbon.identity.governance.feature/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../org.wso2.carbon.identity.recovery.server.feature/pom.xml | 2 +- features/org.wso2.carbon.identity.recovery.ui.feature/pom.xml | 2 +- .../pom.xml | 2 +- features/org.wso2.carbon.identity.user.server.feature/pom.xml | 2 +- pom.xml | 4 ++-- .../identity/org.wso2.carbon.identity.recovery.stub/pom.xml | 2 +- service-stubs/identity/pom.xml | 2 +- 39 files changed, 42 insertions(+), 42 deletions(-) diff --git a/components/org.wso2.carbon.identity.account.suspension.notification.task/pom.xml b/components/org.wso2.carbon.identity.account.suspension.notification.task/pom.xml index 503fea646e..c13dd2146f 100644 --- a/components/org.wso2.carbon.identity.account.suspension.notification.task/pom.xml +++ b/components/org.wso2.carbon.identity.account.suspension.notification.task/pom.xml @@ -20,7 +20,7 @@ identity-governance org.wso2.carbon.identity.governance - 1.8.67 + 1.8.68-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.api.user.governance/pom.xml b/components/org.wso2.carbon.identity.api.user.governance/pom.xml index 4825c6c872..19a75be55f 100644 --- a/components/org.wso2.carbon.identity.api.user.governance/pom.xml +++ b/components/org.wso2.carbon.identity.api.user.governance/pom.xml @@ -23,12 +23,12 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67 + 1.8.68-SNAPSHOT ../.. org.wso2.carbon.identity.api.user.governance - 1.8.67 + 1.8.68-SNAPSHOT jar WSO2 Carbon - User Rest Governance API WSO2 Carbon - User Rest Governance API diff --git a/components/org.wso2.carbon.identity.api.user.recovery/pom.xml b/components/org.wso2.carbon.identity.api.user.recovery/pom.xml index 9dcf07771b..98ac3ad3db 100644 --- a/components/org.wso2.carbon.identity.api.user.recovery/pom.xml +++ b/components/org.wso2.carbon.identity.api.user.recovery/pom.xml @@ -23,12 +23,12 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67 + 1.8.68-SNAPSHOT ../.. org.wso2.carbon.identity.api.user.recovery - 1.8.67 + 1.8.68-SNAPSHOT jar WSO2 Carbon - Identity Management Recovery Rest API WSO2 Carbon - Identity Management Recovery Rest API diff --git a/components/org.wso2.carbon.identity.auth.attribute.handler/pom.xml b/components/org.wso2.carbon.identity.auth.attribute.handler/pom.xml index 821fd3eedc..a2f234dc75 100644 --- a/components/org.wso2.carbon.identity.auth.attribute.handler/pom.xml +++ b/components/org.wso2.carbon.identity.auth.attribute.handler/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67 + 1.8.68-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.captcha/pom.xml b/components/org.wso2.carbon.identity.captcha/pom.xml index 1cff907ce3..d3e5b314c0 100644 --- a/components/org.wso2.carbon.identity.captcha/pom.xml +++ b/components/org.wso2.carbon.identity.captcha/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67 + 1.8.68-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.governance/pom.xml b/components/org.wso2.carbon.identity.governance/pom.xml index 5171e34a29..b618d5c55d 100644 --- a/components/org.wso2.carbon.identity.governance/pom.xml +++ b/components/org.wso2.carbon.identity.governance/pom.xml @@ -18,7 +18,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67 + 1.8.68-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.idle.account.identification/pom.xml b/components/org.wso2.carbon.identity.idle.account.identification/pom.xml index 35a22f2d6a..f34b93c6f3 100644 --- a/components/org.wso2.carbon.identity.idle.account.identification/pom.xml +++ b/components/org.wso2.carbon.identity.idle.account.identification/pom.xml @@ -18,7 +18,7 @@ identity-governance org.wso2.carbon.identity.governance - 1.8.67 + 1.8.68-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.multi.attribute.login/org.wso2.carbon.identity.multi.attribute.login.resolver.regex/pom.xml b/components/org.wso2.carbon.identity.multi.attribute.login/org.wso2.carbon.identity.multi.attribute.login.resolver.regex/pom.xml index 264d3429d1..5477c4af57 100644 --- a/components/org.wso2.carbon.identity.multi.attribute.login/org.wso2.carbon.identity.multi.attribute.login.resolver.regex/pom.xml +++ b/components/org.wso2.carbon.identity.multi.attribute.login/org.wso2.carbon.identity.multi.attribute.login.resolver.regex/pom.xml @@ -21,7 +21,7 @@ identity-governance org.wso2.carbon.identity.governance - 1.8.67 + 1.8.68-SNAPSHOT ../../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.multi.attribute.login/org.wso2.carbon.identity.multi.attribute.login.service/pom.xml b/components/org.wso2.carbon.identity.multi.attribute.login/org.wso2.carbon.identity.multi.attribute.login.service/pom.xml index bc69ffea6a..0f3f9b1e9f 100644 --- a/components/org.wso2.carbon.identity.multi.attribute.login/org.wso2.carbon.identity.multi.attribute.login.service/pom.xml +++ b/components/org.wso2.carbon.identity.multi.attribute.login/org.wso2.carbon.identity.multi.attribute.login.service/pom.xml @@ -21,7 +21,7 @@ identity-governance org.wso2.carbon.identity.governance - 1.8.67 + 1.8.68-SNAPSHOT ../../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.multi.attribute.login/pom.xml b/components/org.wso2.carbon.identity.multi.attribute.login/pom.xml index a6c5a4d54e..dd1fcffa28 100644 --- a/components/org.wso2.carbon.identity.multi.attribute.login/pom.xml +++ b/components/org.wso2.carbon.identity.multi.attribute.login/pom.xml @@ -21,7 +21,7 @@ identity-governance org.wso2.carbon.identity.governance - 1.8.67 + 1.8.68-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/org.wso2.carbon.identity.password.expiry/pom.xml b/components/org.wso2.carbon.identity.password.expiry/pom.xml index 639f6a4e5f..1d8470daae 100644 --- a/components/org.wso2.carbon.identity.password.expiry/pom.xml +++ b/components/org.wso2.carbon.identity.password.expiry/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67 + 1.8.68-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.password.history/pom.xml b/components/org.wso2.carbon.identity.password.history/pom.xml index 58de0ccb50..d7a93d2aef 100644 --- a/components/org.wso2.carbon.identity.password.history/pom.xml +++ b/components/org.wso2.carbon.identity.password.history/pom.xml @@ -18,7 +18,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67 + 1.8.68-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.password.policy/pom.xml b/components/org.wso2.carbon.identity.password.policy/pom.xml index 70c1a1adc1..3a7d07427e 100644 --- a/components/org.wso2.carbon.identity.password.policy/pom.xml +++ b/components/org.wso2.carbon.identity.password.policy/pom.xml @@ -18,7 +18,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67 + 1.8.68-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.piicontroller/pom.xml b/components/org.wso2.carbon.identity.piicontroller/pom.xml index d55dc252a0..d96401efd6 100644 --- a/components/org.wso2.carbon.identity.piicontroller/pom.xml +++ b/components/org.wso2.carbon.identity.piicontroller/pom.xml @@ -19,7 +19,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67 + 1.8.68-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.recovery.endpoint/pom.xml b/components/org.wso2.carbon.identity.recovery.endpoint/pom.xml index 3474a74c53..8e6b043d57 100644 --- a/components/org.wso2.carbon.identity.recovery.endpoint/pom.xml +++ b/components/org.wso2.carbon.identity.recovery.endpoint/pom.xml @@ -5,7 +5,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67 + 1.8.68-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.recovery.ui/pom.xml b/components/org.wso2.carbon.identity.recovery.ui/pom.xml index 74cfd6e029..ffc7f16216 100644 --- a/components/org.wso2.carbon.identity.recovery.ui/pom.xml +++ b/components/org.wso2.carbon.identity.recovery.ui/pom.xml @@ -18,7 +18,7 @@ identity-governance org.wso2.carbon.identity.governance - 1.8.67 + 1.8.68-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.recovery/pom.xml b/components/org.wso2.carbon.identity.recovery/pom.xml index 97ffebcfd0..1a8553497d 100644 --- a/components/org.wso2.carbon.identity.recovery/pom.xml +++ b/components/org.wso2.carbon.identity.recovery/pom.xml @@ -18,7 +18,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67 + 1.8.68-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.tenant.resource.manager/pom.xml b/components/org.wso2.carbon.identity.tenant.resource.manager/pom.xml index 8c210bdd4d..7a8b918d47 100644 --- a/components/org.wso2.carbon.identity.tenant.resource.manager/pom.xml +++ b/components/org.wso2.carbon.identity.tenant.resource.manager/pom.xml @@ -22,7 +22,7 @@ identity-governance org.wso2.carbon.identity.governance - 1.8.67 + 1.8.68-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.user.endpoint/pom.xml b/components/org.wso2.carbon.identity.user.endpoint/pom.xml index 9b004f96dc..7136f94e21 100644 --- a/components/org.wso2.carbon.identity.user.endpoint/pom.xml +++ b/components/org.wso2.carbon.identity.user.endpoint/pom.xml @@ -5,7 +5,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67 + 1.8.68-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.user.export.core/pom.xml b/components/org.wso2.carbon.identity.user.export.core/pom.xml index d068c06289..f0e7ec1ff2 100644 --- a/components/org.wso2.carbon.identity.user.export.core/pom.xml +++ b/components/org.wso2.carbon.identity.user.export.core/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67 + 1.8.68-SNAPSHOT ../../pom.xml diff --git a/components/org.wso2.carbon.identity.user.rename.core/pom.xml b/components/org.wso2.carbon.identity.user.rename.core/pom.xml index 43948485b6..6b56878bb5 100644 --- a/components/org.wso2.carbon.identity.user.rename.core/pom.xml +++ b/components/org.wso2.carbon.identity.user.rename.core/pom.xml @@ -20,7 +20,7 @@ identity-governance org.wso2.carbon.identity.governance - 1.8.67 + 1.8.68-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/features/org.wso2.carbon.identity.account.suspension.notification.task.server.feature/pom.xml b/features/org.wso2.carbon.identity.account.suspension.notification.task.server.feature/pom.xml index f49359f857..147061264f 100644 --- a/features/org.wso2.carbon.identity.account.suspension.notification.task.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.account.suspension.notification.task.server.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.governance identity-governance ../../pom.xml - 1.8.67 + 1.8.68-SNAPSHOT 4.0.0 diff --git a/features/org.wso2.carbon.identity.auth.attribute.handler.server.feature/pom.xml b/features/org.wso2.carbon.identity.auth.attribute.handler.server.feature/pom.xml index 2005bb9e76..dc8d85c35a 100644 --- a/features/org.wso2.carbon.identity.auth.attribute.handler.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.auth.attribute.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.governance identity-governance ../../pom.xml - 1.8.67 + 1.8.68-SNAPSHOT 4.0.0 diff --git a/features/org.wso2.carbon.identity.captcha.server.feature/pom.xml b/features/org.wso2.carbon.identity.captcha.server.feature/pom.xml index 177ad1c7d3..de562382f9 100644 --- a/features/org.wso2.carbon.identity.captcha.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.captcha.server.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.governance identity-governance ../../pom.xml - 1.8.67 + 1.8.68-SNAPSHOT 4.0.0 diff --git a/features/org.wso2.carbon.identity.governance.feature/pom.xml b/features/org.wso2.carbon.identity.governance.feature/pom.xml index 509152e1d8..57292a9f67 100644 --- a/features/org.wso2.carbon.identity.governance.feature/pom.xml +++ b/features/org.wso2.carbon.identity.governance.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67 + 1.8.68-SNAPSHOT ../../pom.xml diff --git a/features/org.wso2.carbon.identity.governance.server.feature/pom.xml b/features/org.wso2.carbon.identity.governance.server.feature/pom.xml index 42be2deb1e..3a1e559fd5 100644 --- a/features/org.wso2.carbon.identity.governance.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.governance.server.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.governance identity-governance ../../pom.xml - 1.8.67 + 1.8.68-SNAPSHOT 4.0.0 diff --git a/features/org.wso2.carbon.identity.idle.account.identification.server.feature/pom.xml b/features/org.wso2.carbon.identity.idle.account.identification.server.feature/pom.xml index 2e201bf336..73e1a6703b 100644 --- a/features/org.wso2.carbon.identity.idle.account.identification.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.idle.account.identification.server.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.governance identity-governance ../../pom.xml - 1.8.67 + 1.8.68-SNAPSHOT 4.0.0 diff --git a/features/org.wso2.carbon.identity.multi.attribute.login.service.server.feature/pom.xml b/features/org.wso2.carbon.identity.multi.attribute.login.service.server.feature/pom.xml index d3042a7ce5..84fdc4e725 100644 --- a/features/org.wso2.carbon.identity.multi.attribute.login.service.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.multi.attribute.login.service.server.feature/pom.xml @@ -3,7 +3,7 @@ identity-governance org.wso2.carbon.identity.governance - 1.8.67 + 1.8.68-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/features/org.wso2.carbon.identity.password.expiry.server.feature/pom.xml b/features/org.wso2.carbon.identity.password.expiry.server.feature/pom.xml index 219e4ba300..287b2db3b5 100644 --- a/features/org.wso2.carbon.identity.password.expiry.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.password.expiry.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.governance identity-governance ../../pom.xml - 1.8.67 + 1.8.68-SNAPSHOT 4.0.0 diff --git a/features/org.wso2.carbon.identity.password.history.server.feature/pom.xml b/features/org.wso2.carbon.identity.password.history.server.feature/pom.xml index f62a74a5e2..1055cbaa4e 100644 --- a/features/org.wso2.carbon.identity.password.history.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.password.history.server.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.governance identity-governance ../../pom.xml - 1.8.67 + 1.8.68-SNAPSHOT 4.0.0 diff --git a/features/org.wso2.carbon.identity.password.policy.server.feature/pom.xml b/features/org.wso2.carbon.identity.password.policy.server.feature/pom.xml index 3d7d2f089b..59068f5580 100644 --- a/features/org.wso2.carbon.identity.password.policy.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.password.policy.server.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.governance identity-governance ../../pom.xml - 1.8.67 + 1.8.68-SNAPSHOT 4.0.0 diff --git a/features/org.wso2.carbon.identity.piicontroller.server.feature/pom.xml b/features/org.wso2.carbon.identity.piicontroller.server.feature/pom.xml index af5fdf8c4e..b626640455 100644 --- a/features/org.wso2.carbon.identity.piicontroller.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.piicontroller.server.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.governance identity-governance ../../pom.xml - 1.8.67 + 1.8.68-SNAPSHOT 4.0.0 diff --git a/features/org.wso2.carbon.identity.recovery.server.feature/pom.xml b/features/org.wso2.carbon.identity.recovery.server.feature/pom.xml index bd0e8810df..cb5814a524 100644 --- a/features/org.wso2.carbon.identity.recovery.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.recovery.server.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.governance identity-governance ../../pom.xml - 1.8.67 + 1.8.68-SNAPSHOT 4.0.0 diff --git a/features/org.wso2.carbon.identity.recovery.ui.feature/pom.xml b/features/org.wso2.carbon.identity.recovery.ui.feature/pom.xml index 352d02b217..df819e25aa 100644 --- a/features/org.wso2.carbon.identity.recovery.ui.feature/pom.xml +++ b/features/org.wso2.carbon.identity.recovery.ui.feature/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67 + 1.8.68-SNAPSHOT ../../pom.xml diff --git a/features/org.wso2.carbon.identity.tenant.resource.manager.feature/pom.xml b/features/org.wso2.carbon.identity.tenant.resource.manager.feature/pom.xml index 880b655ae8..111b47796c 100644 --- a/features/org.wso2.carbon.identity.tenant.resource.manager.feature/pom.xml +++ b/features/org.wso2.carbon.identity.tenant.resource.manager.feature/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67 + 1.8.68-SNAPSHOT ../../pom.xml diff --git a/features/org.wso2.carbon.identity.user.server.feature/pom.xml b/features/org.wso2.carbon.identity.user.server.feature/pom.xml index 71a379457d..9b57b3d839 100644 --- a/features/org.wso2.carbon.identity.user.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.user.server.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.identity.governance identity-governance ../../pom.xml - 1.8.67 + 1.8.68-SNAPSHOT 4.0.0 diff --git a/pom.xml b/pom.xml index ec2409590f..c05c6e5778 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67 + 1.8.68-SNAPSHOT 4.0.0 pom WSO2 Carbon - Governance Module @@ -37,7 +37,7 @@ https://github.com/wso2-extensions/identity-governance.git scm:git:https://github.com/wso2-extensions/identity-governance.git scm:git:https://github.com/wso2-extensions/identity-governance.git - v1.8.67 + v1.1.0-SNAPSHOT diff --git a/service-stubs/identity/org.wso2.carbon.identity.recovery.stub/pom.xml b/service-stubs/identity/org.wso2.carbon.identity.recovery.stub/pom.xml index 0e01c677e9..1618479b5b 100644 --- a/service-stubs/identity/org.wso2.carbon.identity.recovery.stub/pom.xml +++ b/service-stubs/identity/org.wso2.carbon.identity.recovery.stub/pom.xml @@ -19,7 +19,7 @@ org.wso2.carbon.identity.governance carbon-service-stubs - 1.8.67 + 1.8.68-SNAPSHOT ../pom.xml diff --git a/service-stubs/identity/pom.xml b/service-stubs/identity/pom.xml index 77c286ccb1..ce98332ee9 100644 --- a/service-stubs/identity/pom.xml +++ b/service-stubs/identity/pom.xml @@ -19,7 +19,7 @@ org.wso2.carbon.identity.governance identity-governance - 1.8.67 + 1.8.68-SNAPSHOT ../../pom.xml