|
23 | 23 | <%@ page import="org.wso2.carbon.identity.application.authentication.endpoint.util.AuthenticationEndpointUtil" %> |
24 | 24 | <%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.IdentityRecoveryException" %> |
25 | 25 | <%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementEndpointUtil" %> |
| 26 | +<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.PreferenceRetrievalClient" %> |
| 27 | +<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.PreferenceRetrievalClientException" %> |
| 28 | +<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.ApplicationDataRetrievalClient" %> |
26 | 29 | <%@ page import="java.io.File" %> |
27 | 30 | <%@ page import="java.net.URISyntaxException" %> |
28 | 31 | <%@ taglib prefix="layout" uri="org.wso2.identity.apps.taglibs.layout.controller" %> |
|
57 | 60 | successMessageTitle = "username.recovery.sms.success.heading"; |
58 | 61 | successMessageDescrition = "username.recovery.sms.success.body"; |
59 | 62 | } |
| 63 | +
|
| 64 | + boolean isValidCallBackURL = true; |
| 65 | +
|
| 66 | + try { |
| 67 | + isValidCallBackURL = AuthenticationEndpointUtil.isSchemeSafeURL(callback); |
| 68 | +
|
| 69 | + if (isValidCallBackURL && StringUtils.isNotBlank(callback)) { |
| 70 | + ApplicationDataRetrievalClient applicationDataRetrievalClient = new ApplicationDataRetrievalClient(); |
| 71 | + String applicationAccessUrl = applicationDataRetrievalClient.getApplicationAccessURL(tenantDomain, spAppName); |
| 72 | +
|
| 73 | + if (StringUtils.isNotBlank(applicationAccessUrl)) { |
| 74 | + // If the application access URL is present, only then allow the callback to be that URL. |
| 75 | + isValidCallBackURL = StringUtils.equals(callback, applicationAccessUrl); |
| 76 | + } else { |
| 77 | + // If the application access URL is not present, callback should be a valid multi option URL. |
| 78 | + String encodedCallback = IdentityManagementEndpointUtil.getURLEncodedCallback(callback); |
| 79 | + isValidCallBackURL = AuthenticationEndpointUtil.isValidMultiOptionURI(encodedCallback); |
| 80 | + } |
| 81 | + } |
| 82 | + } catch (Exception e) { |
| 83 | + isValidCallBackURL = false; |
| 84 | + } |
60 | 85 | %> |
61 | 86 |
|
62 | 87 | <% request.setAttribute("pageName", "username-recovery-complete"); %> |
|
101 | 126 | <%=i18n(recoveryResourceBundle, customText, successMessageDescrition)%> |
102 | 127 | <br><br> |
103 | 128 | <% |
104 | | - if(StringUtils.isNotBlank(callback) && AuthenticationEndpointUtil.isSchemeSafeURL(callback)) { |
| 129 | + if (StringUtils.isNotBlank(callback) && isValidCallBackURL) { |
105 | 130 | %> |
106 | 131 | <br/><br/> |
107 | 132 | <i class="caret left icon primary"></i> |
|
0 commit comments