Skip to content

Commit

Permalink
Merge pull request #5022 from ashanthamara/bug-fixing-identity-apps
Browse files Browse the repository at this point in the history
Use request.authParams instead of redundant REST api calls in several jsp files
  • Loading branch information
madurangasiriwardena authored Dec 11, 2023
2 parents c8d54cc + ca79743 commit 402865f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 73 deletions.
5 changes: 5 additions & 0 deletions .changeset/thick-lamps-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wso2is/identity-apps-core": patch
---

Removed redundant REST api calls in several jsps
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<%@ page import="com.google.gson.Gson" %>
<%@ page import="org.owasp.encoder.Encode" %>
<%@ page import="org.wso2.carbon.identity.application.authentication.endpoint.util.AuthenticationEndpointUtil" %>
<%@ page import="org.wso2.carbon.identity.application.authentication.endpoint.util.AuthContextAPIClient" %>
<%@ page import="org.wso2.carbon.identity.application.authentication.endpoint.util.client.model.AuthenticationRequestWrapper" %>
<%@ page import="org.wso2.carbon.identity.application.authentication.endpoint.util.Constants" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementEndpointUtil" %>
<%@ page import="org.wso2.carbon.identity.template.mgt.model.Template" %>
Expand All @@ -41,20 +41,8 @@
<%
String templateId = request.getParameter("templateId");
String promptId = request.getParameter("promptId");
String authAPIURL = application.getInitParameter(Constants.AUTHENTICATION_REST_ENDPOINT_URL);
if (StringUtils.isBlank(authAPIURL)) {
authAPIURL = IdentityManagementEndpointUtil.getBasePath(tenantDomain, "/api/identity/auth/v1.1/", true);
} else {
// Resolve tenant domain for the authentication API URL.
authAPIURL = AuthenticationEndpointUtil.resolveTenantDomain(authAPIURL);
}
if (!authAPIURL.endsWith("/")) {
authAPIURL += "/";
}
authAPIURL += "context/" + request.getParameter("promptId");
String contextProperties = AuthContextAPIClient.getContextProperties(authAPIURL);
Gson gson = new Gson();
Map data = gson.fromJson(contextProperties, Map.class);
Map data = ((AuthenticationRequestWrapper) request).getAuthParams();
String templatePath = templateMap.get(templateId);
%>

Expand All @@ -77,11 +65,6 @@
<% } else { %>
<jsp:include page="includes/header.jsp"/>
<% } %>

<script type="text/javascript">
var data = JSON.parse("<%=Encode.forJavaScript(contextProperties)%>");
var prompt_id = "<%= Encode.forJavaScriptBlock(promptId) %>";
</script>
</head>
<body class="login-portal layout authentication-portal-layout">
<layout:main layoutName="<%= layout %>" layoutFileRelativePath="<%= layoutFileRelativePath %>" data="<%= layoutData %>" >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<%@ page import="org.owasp.encoder.Encode" %>
<%@ page import="org.apache.commons.text.StringEscapeUtils" %>
<%@ page import="org.wso2.carbon.identity.application.authentication.endpoint.util.AuthenticationEndpointUtil" %>
<%@ page import="org.wso2.carbon.identity.application.authentication.endpoint.util.AuthContextAPIClient" %>
<%@ page import="org.wso2.carbon.identity.application.authentication.endpoint.util.client.model.AuthenticationRequestWrapper" %>
<%@ page import="org.wso2.carbon.identity.application.authentication.endpoint.util.Constants" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementEndpointUtil" %>

Expand All @@ -35,22 +35,7 @@
<%
String authRequest = request.getParameter("data");
String authAPIURL = application.getInitParameter(Constants.AUTHENTICATION_REST_ENDPOINT_URL);
if (StringUtils.isBlank(authAPIURL)) {
authAPIURL = IdentityManagementEndpointUtil.getBasePath(tenantDomain, "/api/identity/auth/v1.1/", true);
} else {
// Resolve tenant domain for the authentication API URL.
authAPIURL = AuthenticationEndpointUtil.resolveTenantDomain(authAPIURL);
}
if (!authAPIURL.endsWith("/")) {
authAPIURL += "/";
}
authAPIURL += "context/" + Encode.forUriComponent(request.getParameter("sessionDataKey"));
String contextProperties = AuthContextAPIClient.getContextProperties(authAPIURL);
Gson gson = new Gson();
Map data = gson.fromJson(contextProperties, Map.class);
Map data = ((AuthenticationRequestWrapper) request).getAuthParams();
boolean enablePasskeyProgressiveEnrollment = (boolean) data.get("FIDO.EnablePasskeyProgressiveEnrollment");
%>

Expand Down Expand Up @@ -159,7 +144,7 @@
</p>
<div class="mt-4">
<div class="buttons">
<button class="ui primary fluid large button" type="button" onclick="retry()"
<button class="ui primary fluid large button" type="button" onclick="retry()"
data-testid="login-page-fido-retry-button">
<%=AuthenticationEndpointUtil.i18n(resourceBundle, "fido.retry" )%>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<%@ page import="org.owasp.encoder.Encode" %>
<%@ page import="org.apache.commons.text.StringEscapeUtils" %>
<%@ page import="org.wso2.carbon.identity.application.authentication.endpoint.util.AuthenticationEndpointUtil" %>
<%@ page import="org.wso2.carbon.identity.application.authentication.endpoint.util.AuthContextAPIClient" %>
<%@ page import="org.wso2.carbon.identity.application.authentication.endpoint.util.client.model.AuthenticationRequestWrapper" %>
<%@ page import="org.wso2.carbon.identity.application.authentication.endpoint.util.Constants" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementEndpointUtil" %>

Expand All @@ -33,22 +33,7 @@
<%@include file="includes/init-url.jsp" %>

<%
String authAPIURL = application.getInitParameter(Constants.AUTHENTICATION_REST_ENDPOINT_URL);
if (StringUtils.isBlank(authAPIURL)) {
authAPIURL = IdentityManagementEndpointUtil.getBasePath(tenantDomain, "/api/identity/auth/v1.1/", true);
} else {
// Resolve tenant domain for the authentication API URL.
authAPIURL = AuthenticationEndpointUtil.resolveTenantDomain(authAPIURL);
}
if (!authAPIURL.endsWith("/")) {
authAPIURL += "/";
}
authAPIURL += "context/" + Encode.forUriComponent(request.getParameter("sessionDataKey"));
String contextProperties = AuthContextAPIClient.getContextProperties(authAPIURL);
Gson gson = new Gson();
Map data = gson.fromJson(contextProperties, Map.class);
Map data = ((AuthenticationRequestWrapper) request).getAuthParams();
boolean enablePasskeyProgressiveEnrollment = (boolean) data.get("FIDO.EnablePasskeyProgressiveEnrollment");
%>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<%@ page import="java.io.File" %>
<%@ page import="org.owasp.encoder.Encode" %>
<%@ page import="org.apache.commons.text.StringEscapeUtils" %>
<%@ page import="org.wso2.carbon.identity.application.authentication.endpoint.util.AuthContextAPIClient" %>
<%@ page import="org.wso2.carbon.identity.application.authentication.endpoint.util.client.model.AuthenticationRequestWrapper" %>
<%@ page import="org.wso2.carbon.identity.application.authentication.endpoint.util.Constants" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementEndpointUtil" %>

Expand All @@ -33,22 +33,7 @@
<%
String isKeyExist = request.getParameter("keyExist");
String authAPIURL = application.getInitParameter(Constants.AUTHENTICATION_REST_ENDPOINT_URL);
if (StringUtils.isBlank(authAPIURL)) {
authAPIURL = IdentityManagementEndpointUtil.getBasePath(tenantDomain, "/api/identity/auth/v1.1/", true);
} else {
// Resolve tenant domain for the authentication API URL.
authAPIURL = AuthenticationEndpointUtil.resolveTenantDomain(authAPIURL);
}
if (!authAPIURL.endsWith("/")) {
authAPIURL += "/";
}
authAPIURL += "context/" + Encode.forUriComponent(request.getParameter("sessionDataKey"));
String contextProperties = AuthContextAPIClient.getContextProperties(authAPIURL);
Gson gson = new Gson();
Map data = gson.fromJson(contextProperties, Map.class);
Map data = ((AuthenticationRequestWrapper) request).getAuthParams();
boolean enablePasskeyProgressiveEnrollment = (boolean) data.get("FIDO.EnablePasskeyProgressiveEnrollment");
%>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</c:forEach>
<input type="hidden" id="promptResp" name="promptResp" value="true">
<input type="hidden" id="promptId" name="promptId" value="${requestScope.promptId}">
<input type="submit" class="ui primary medium button" value="Submit">
<input type="submit" class="ui primary fluid large button" value="Submit">
</form>
</div>
<%-- /content --%>

0 comments on commit 402865f

Please sign in to comment.