Skip to content

Commit

Permalink
Merge pull request #787 from ashanthamara/bug-fix-governance
Browse files Browse the repository at this point in the history
Disregard callback url regex validation when accessurl is configured in the app
  • Loading branch information
chamathns authored Dec 6, 2023
2 parents 6b137f0 + 3199891 commit 510730c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public class IdentityRecoveryConstants {
public static final String EXECUTE_ACTION = "ui.execute";
public static final String UTF_8 = "UTF-8";
public static final String CALLBACK = "callback";
public static final String IS_ACCESS_URL_AVAILABLE = "isAccessUrlAvailable";
public static final String IS_LITE_SIGN_UP = "isLiteSignUp";
public static final String DEFAULT_CALLBACK_REGEX = ".*";
public static final String IS_USER_PORTAL_URL = "isUserPortalURL";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,13 @@ private void validateCallback(Property[] properties, String tenantDomain) throws

String callbackURL = null;
try {
callbackURL = Utils.getCallbackURL(properties);
if (StringUtils.isNotBlank(callbackURL) && !Utils.validateCallbackURL(callbackURL, tenantDomain,
IdentityRecoveryConstants.ConnectorConfig.RECOVERY_CALLBACK_REGEX)) {
throw Utils.handleServerException(
IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_CALLBACK_URL_NOT_VALID, callbackURL);
if (!Utils.isAccessUrlAvailable(properties)) {
callbackURL = Utils.getCallbackURL(properties);
if (StringUtils.isNotBlank(callbackURL) && !Utils.validateCallbackURL(callbackURL, tenantDomain,
IdentityRecoveryConstants.ConnectorConfig.RECOVERY_CALLBACK_REGEX)) {
throw Utils.handleServerException(
IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_CALLBACK_URL_NOT_VALID, callbackURL);
}
}
} catch (URISyntaxException | UnsupportedEncodingException | IdentityEventException e) {
throw Utils.handleServerException(IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_CALLBACK_URL_NOT_VALID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@

import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.ArrayList;
Expand Down Expand Up @@ -154,11 +155,13 @@ public NotificationResponseBean registerUser(User user, String password, Claim[]
// Callback URL validation
String callbackURL = null;
try {
callbackURL = Utils.getCallbackURLFromRegistration(properties);
if (StringUtils.isNotBlank(callbackURL) && !Utils.validateCallbackURL(callbackURL, tenantDomain,
IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_CALLBACK_REGEX)) {
throw Utils.handleServerException(
IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_CALLBACK_URL_NOT_VALID, callbackURL);
if (!Utils.isAccessUrlAvailable(properties)) {
callbackURL = Utils.getCallbackURLFromRegistration(properties);
if (StringUtils.isNotBlank(callbackURL) && !Utils.validateCallbackURL(callbackURL, tenantDomain,
IdentityRecoveryConstants.ConnectorConfig.SELF_REGISTRATION_CALLBACK_REGEX)) {
throw Utils.handleServerException(
IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_CALLBACK_URL_NOT_VALID, callbackURL);
}
}
} catch (MalformedURLException | UnsupportedEncodingException | IdentityEventException e) {
throw Utils.handleServerException(IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_CALLBACK_URL_NOT_VALID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,24 @@ public static String getCallbackURL(org.wso2.carbon.identity.recovery.model.Prop
return callbackURL;
}

/**
* Get isAccessUrlAvailable property value.
*
* @param properties Properties array.
* @return Boolean value of the isAccessUrlAvailable property.
*/
public static Boolean isAccessUrlAvailable(org.wso2.carbon.identity.recovery.model.Property[] properties) {

if (properties != null) {
for (org.wso2.carbon.identity.recovery.model.Property property : properties) {
if (IdentityRecoveryConstants.IS_ACCESS_URL_AVAILABLE.equals(property.getKey())) {
return Boolean.parseBoolean(property.getValue());
}
}
}
return false;
}

/**
* Get whether this is tenant flow
*
Expand Down

0 comments on commit 510730c

Please sign in to comment.