From 3eca2d134ce11e636f04419516735baef68b2b0e Mon Sep 17 00:00:00 2001 From: vimukthiRajapaksha Date: Wed, 13 Nov 2024 16:15:57 +0530 Subject: [PATCH 1/8] Add support for rich authorization requests --- .../src/main/webapp/oauth2_authz.jsp | 56 +++++++++++++++- .../src/main/webapp/oauth2_consent.jsp | 67 ++++++++++++++++--- 2 files changed, 114 insertions(+), 9 deletions(-) diff --git a/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_authz.jsp b/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_authz.jsp index a5a86614250..fd104a6a8d7 100644 --- a/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_authz.jsp +++ b/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_authz.jsp @@ -1,6 +1,6 @@ <%-- ~ - ~ Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. + ~ Copyright (c) 2023-2024, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. ~ ~ This software is the property of WSO2 LLC. and its suppliers, if any. ~ Dissemination of any information or reproduction of any material contained @@ -10,6 +10,7 @@ --%> <%@ page import="org.apache.commons.collections.CollectionUtils" %> +<%@ page import="org.apache.commons.collections.MapUtils" %> <%@ page import="org.apache.commons.lang.StringUtils" %> <%@ page import="org.owasp.encoder.Encode" %> <%@ page import="org.wso2.carbon.identity.application.authentication.endpoint.util.Constants" %> @@ -62,6 +63,20 @@ } boolean displayScopes = Boolean.parseBoolean(getServletContext().getInitParameter("displayScopes")); + + final String authorizationDetailsParam = request.getParameter("authorization_details"); + final Map authorizationDetailsToBeDisplayed = new HashMap<>(); + if (StringUtils.isNotBlank(authorizationDetailsParam)) { + final JSONArray authorizationDetails = new JSONArray(authorizationDetailsParam); + for (int index = 0; index < authorizationDetails.length(); index++) { + JSONObject authorizationDetail = authorizationDetails.getJSONObject(index); + + // Check if consent description is not empty, otherwise use type. + final String description = authorizationDetail.optString("_description", authorizationDetail.getString("type")); + final String authorizationDetailId = "authorization_detail_id_" + authorizationDetail.getString("_id"); + authorizationDetailsToBeDisplayed.put(authorizationDetailId, description); + } + } %> <%-- Data for the layout from the page --%> @@ -233,6 +248,45 @@ } %> + <% + if (MapUtils.isNotEmpty(authorizationDetailsToBeDisplayed)) { + %> +
+
+
+ +
+
+ <%=AuthenticationEndpointUtil.i18n(resourceBundle, "requested.authorization-details")%> +
+
+
+
+
+ <% + for (Map.Entry authorizationDetailEntry : authorizationDetailsToBeDisplayed.entrySet()) { + %> +
+
+ + +
+
+ <% + } + %> +
+
+
+
+
+
+ <% + } + %> + - + @@ -392,6 +407,42 @@ } } %> + + <% + if (MapUtils.isNotEmpty(authorizationDetailsToBeDisplayed)) { + %> +
+ +
+
+ <%=AuthenticationEndpointUtil.i18n(resourceBundle, "requested.authorization-details")%> +
+
+
+
+
+ <% + for (Map.Entry authorizationDetailEntry : authorizationDetailsToBeDisplayed.entrySet()) { + %> +
+
+ + +
+
+ <% + } + %> +
+
+
+
+ <% + } + %> + From 230e379a26771a07d050af758c2d32893e152f72 Mon Sep 17 00:00:00 2001 From: vimukthiRajapaksha Date: Wed, 13 Nov 2024 16:21:33 +0530 Subject: [PATCH 2/8] Add rich authorization requests i18n --- .../endpoint/i18n/Resources.properties | 1 + .../src/main/webapp/oauth2_consent.jsp | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources.properties b/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources.properties index 48db124d9ba..5b1c3d22a13 100644 --- a/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources.properties +++ b/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources.properties @@ -192,6 +192,7 @@ under.construction=This page is under construction by.selecting.following.attributes=By selecting the following attributes you agree to share them with select.all=Select All requested.scopes=Obtain permission for +requested.authorization-details=Gain consent for requested.attributes=Know some of your details please.select.approve.always=Please select either "Approve Once" or "Approve Always" to provide consent to requested scopes to continue ok=Ok diff --git a/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_consent.jsp b/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_consent.jsp index d3d32bb2460..c6889b1ce57 100644 --- a/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_consent.jsp +++ b/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_consent.jsp @@ -58,22 +58,22 @@ JSONArray scopeArray = new JSONArray (jsonObj.get("scopes").toString()); for (int scopeCount = 0; scopeCount < scopeArray.length(); scopeCount++) { JSONObject scope = (JSONObject) scopeArray.get(scopeCount); - + // Get the displayName. String displayName = (String) scope.get("displayName"); - + // Use optString to get description; it returns "" if the key is not found. String description = scope.optString("description", ""); // Check if description is not empty, otherwise use displayName. String scopeName = !StringUtils.isBlank(description) ? description : displayName; - + // Add the determined scopeName to the scopes list. scopes.add(scopeName); - + // Add the identifier to the scopesWithMetadata list scopesWithMetadata.add((String) scope.get("identifier")); - } + } scopeDetails.put(key,scopes); } } @@ -248,7 +248,7 @@ - + From 5e0ea07fbcee57ac60f7b0dd667488cb50d59975 Mon Sep 17 00:00:00 2001 From: vimukthiRajapaksha Date: Fri, 24 Jan 2025 14:52:26 +0530 Subject: [PATCH 3/8] Bump framework and oauth versions to latest --- identity-apps-core/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/identity-apps-core/pom.xml b/identity-apps-core/pom.xml index df417b19844..1738f3fd2e4 100644 --- a/identity-apps-core/pom.xml +++ b/identity-apps-core/pom.xml @@ -729,14 +729,14 @@ 3.0.0 5.1.5 1.0.8 - 7.2.30 + 7.7.130 [5.0.0, 8.0.0) 1.0.77 [1.0.77, 2.0.0) 1.3.89 [1.3.89, 2.0.0) - 6.7.130 + 7.0.224 [6.1.0, 8.0.0) 1.8.41 3.2.2 From aadc5e4f564fa66901e5748255528b380fad132a Mon Sep 17 00:00:00 2001 From: vimukthiRajapaksha Date: Fri, 24 Jan 2025 15:12:13 +0530 Subject: [PATCH 4/8] Update year of the license headers --- .../src/main/webapp/oauth2_authz.jsp | 2 +- .../src/main/webapp/oauth2_consent.jsp | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_authz.jsp b/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_authz.jsp index fd104a6a8d7..61b852ccf0c 100644 --- a/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_authz.jsp +++ b/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_authz.jsp @@ -1,6 +1,6 @@ <%-- ~ - ~ Copyright (c) 2023-2024, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. + ~ Copyright (c) 2023-2025, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. ~ ~ This software is the property of WSO2 LLC. and its suppliers, if any. ~ Dissemination of any information or reproduction of any material contained diff --git a/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_consent.jsp b/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_consent.jsp index c6889b1ce57..c68df3b5086 100644 --- a/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_consent.jsp +++ b/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_consent.jsp @@ -1,6 +1,6 @@ <%-- ~ - ~ Copyright (c) 2021-2024, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. + ~ Copyright (c) 2021-2025, WSO2 LLC. (https://www.wso2.com). All Rights Reserved. ~ ~ This software is the property of WSO2 LLC. and its suppliers, if any. ~ Dissemination of any information or reproduction of any material contained @@ -58,22 +58,22 @@ JSONArray scopeArray = new JSONArray (jsonObj.get("scopes").toString()); for (int scopeCount = 0; scopeCount < scopeArray.length(); scopeCount++) { JSONObject scope = (JSONObject) scopeArray.get(scopeCount); - + // Get the displayName. String displayName = (String) scope.get("displayName"); - + // Use optString to get description; it returns "" if the key is not found. String description = scope.optString("description", ""); // Check if description is not empty, otherwise use displayName. String scopeName = !StringUtils.isBlank(description) ? description : displayName; - + // Add the determined scopeName to the scopes list. scopes.add(scopeName); - + // Add the identifier to the scopesWithMetadata list scopesWithMetadata.add((String) scope.get("identifier")); - } + } scopeDetails.put(key,scopes); } } @@ -248,7 +248,7 @@ - + From a54ea18350058523e7ef006bbd3cd57fdb570968 Mon Sep 17 00:00:00 2001 From: vimukthiRajapaksha Date: Fri, 24 Jan 2025 15:42:37 +0530 Subject: [PATCH 5/8] Add RAR language properties --- .../authentication/endpoint/i18n/Resources.properties | 2 +- .../authentication/endpoint/i18n/Resources_de_DE.properties | 1 + .../authentication/endpoint/i18n/Resources_es_ES.properties | 1 + .../authentication/endpoint/i18n/Resources_fr_FR.properties | 1 + .../authentication/endpoint/i18n/Resources_ja_JP.properties | 1 + .../authentication/endpoint/i18n/Resources_pt_BR.properties | 1 + .../authentication/endpoint/i18n/Resources_pt_PT.properties | 1 + .../authentication/endpoint/i18n/Resources_zh_CN.properties | 1 + .../apps/authentication-portal/src/main/webapp/oauth2_authz.jsp | 2 +- .../authentication-portal/src/main/webapp/oauth2_consent.jsp | 2 +- 10 files changed, 10 insertions(+), 3 deletions(-) diff --git a/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources.properties b/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources.properties index 2683e77eb27..4b2e8ce87fe 100644 --- a/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources.properties +++ b/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources.properties @@ -192,7 +192,7 @@ under.construction=This page is under construction by.selecting.following.attributes=By selecting the following attributes you agree to share them with select.all=Select All requested.scopes=Obtain permission for -requested.authorization-details=Gain consent for +requested.authorization.details=Gain consent for requested.attributes=Know some of your details please.select.approve.always=Please select either "Approve Once" or "Approve Always" to provide consent to requested scopes to continue ok=Ok diff --git a/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_de_DE.properties b/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_de_DE.properties index fdae8aa9b3c..8ba7dca54ae 100644 --- a/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_de_DE.properties +++ b/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_de_DE.properties @@ -183,6 +183,7 @@ under.construction=Diese Seite befindet sich im Aufbau by.selecting.following.attributes=Durch die Auswahl der folgenden Attribute erklären Sie sich damit einverstanden, sie mit (...) zu teilen select.all=Alle auswählen requested.scopes=Genehmigung für (...) erhalten +requested.authorization.details=Holen Sie die Zustimmung dazu ein requested.attributes=einige Ihrer Details kennen please.select.approve.always=Bitte wählen Sie entweder "Einmal zulassen" oder "immer zulassen",um den angeforderten Bereiche zuzustimmen und fortzufahren ok=ok diff --git a/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_es_ES.properties b/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_es_ES.properties index 229ee36387c..25379d04864 100644 --- a/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_es_ES.properties +++ b/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_es_ES.properties @@ -183,6 +183,7 @@ under.construction=Esta página se encuentra en construcción by.selecting.following.attributes=Al seleccionar los siguientes atributos, acepta compartirlos select.all=Seleccionar todo requested.scopes=Obtener permiso para +requested.authorization.details=Obtener el consentimiento para requested.attributes=Conocer algunos de sus datos please.select.approve.always=Seleccione "aprobar una vez" o "aprobar siempre" para proporcionar consentimiento a los ámbitos solicitados para continuar ok=OK diff --git a/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_fr_FR.properties b/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_fr_FR.properties index 8455850ed3b..9c77ce61997 100644 --- a/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_fr_FR.properties +++ b/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_fr_FR.properties @@ -183,6 +183,7 @@ under.construction=Cette page est en cours de construction by.selecting.following.attributes=En sélectionnant les attributs suivants, vous acceptez de les partager avec select.all=Sélectionner tout requested.scopes=Obtenez la permission pour +requested.authorization.details=Obtenir le consentement pour requested.attributes= Connaître certaines de vos données personnelles please.select.approve.always=Veuillez sélectionner "Approuver une fois" ou "Approuver toujours" pour donner votre consentement pour transmettre les informations demandés ok=Ok diff --git a/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_ja_JP.properties b/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_ja_JP.properties index e9d0ff788a7..65f4e140057 100644 --- a/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_ja_JP.properties +++ b/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_ja_JP.properties @@ -183,6 +183,7 @@ under.construction=このページは現在作成中です by.selecting.following.attributes=以下の属性を選択することで、それらを共有することに同意したものとみなされます select.all=すべて選択 requested.scopes=以下への許可を取得: +requested.authorization.details=同意を得る requested.attributes=詳細を理解してください please.select.approve.always=スコープを継続する場合は、「一度だけ承認」または「常に承認」のいずれかを選択してください ok=了解 diff --git a/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_pt_BR.properties b/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_pt_BR.properties index 1f7e5c49d1f..c1356c1103e 100644 --- a/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_pt_BR.properties +++ b/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_pt_BR.properties @@ -180,6 +180,7 @@ under.construction=Esta página está em construção by.selecting.following.attributes=Ao selecionar os atributos abaixo, você concorda em compartilhá-los com select.all=Selecionar tudo requested.scopes=Obter permissão para +requested.authorization.details=Obtenha consentimento para requested.attributes=Conheça alguns dos seus detalhes please.select.approve.always=Selecione "aprovar uma vez" ou "aprovar sempre" para fornecer consentimento aos escopos solicitados para continuar ok=OK diff --git a/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_pt_PT.properties b/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_pt_PT.properties index d4d26211a5f..baae7479892 100644 --- a/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_pt_PT.properties +++ b/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_pt_PT.properties @@ -183,6 +183,7 @@ under.construction=Esta página está em construção by.selecting.following.attributes=Ao selecionar os seguintes atributos, você concorda em compartilhá-los select.all=Selecionar tudo requested.scopes=Obter permissão para +requested.authorization.details=Obtenha consentimento para requested.attributes=Conheça alguns dos seus detalhes please.select.approve.always=Selecione "aprovar uma vez" ou "aprovar sempre" para fornecer consentimento aos escopos solicitados para continuar ok=OK diff --git a/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_zh_CN.properties b/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_zh_CN.properties index 1076f9eee2f..46865bb6aca 100644 --- a/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_zh_CN.properties +++ b/identity-apps-core/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_zh_CN.properties @@ -183,6 +183,7 @@ under.construction=此页面正在建设中 by.selecting.following.attributes=通过选择以下属性,您同意与之共享 select.all=全选 requested.scopes=获得许可 +requested.authorization.details==获得同意 requested.attributes=了解您的一些细节 please.select.approve.always=请选择“一次批准”或“批准”以提供要求继续的范围的同意 ok=行 diff --git a/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_authz.jsp b/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_authz.jsp index 61b852ccf0c..b63fef86d99 100644 --- a/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_authz.jsp +++ b/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_authz.jsp @@ -257,7 +257,7 @@
- <%=AuthenticationEndpointUtil.i18n(resourceBundle, "requested.authorization-details")%> + <%=AuthenticationEndpointUtil.i18n(resourceBundle, "requested.authorization.details")%>
diff --git a/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_consent.jsp b/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_consent.jsp index c68df3b5086..89b97b1a92d 100644 --- a/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_consent.jsp +++ b/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_consent.jsp @@ -415,7 +415,7 @@
- <%=AuthenticationEndpointUtil.i18n(resourceBundle, "requested.authorization-details")%> + <%=AuthenticationEndpointUtil.i18n(resourceBundle, "requested.authorization.details")%>
From 0cd18daa0adc3105751c2f1423a2c5ebfd7b6b5e Mon Sep 17 00:00:00 2001 From: vimukthiRajapaksha Date: Fri, 24 Jan 2025 16:36:52 +0530 Subject: [PATCH 6/8] Use i18n method from localize.jsp --- .../authentication-portal/src/main/webapp/oauth2_authz.jsp | 2 +- .../authentication-portal/src/main/webapp/oauth2_consent.jsp | 2 +- identity-apps-core/pom.xml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_authz.jsp b/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_authz.jsp index b63fef86d99..da3053b78db 100644 --- a/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_authz.jsp +++ b/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_authz.jsp @@ -257,7 +257,7 @@
- <%=AuthenticationEndpointUtil.i18n(resourceBundle, "requested.authorization.details")%> + <%= i18n(resourceBundle, customText, "requested.authorization.details") %>
diff --git a/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_consent.jsp b/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_consent.jsp index 89b97b1a92d..eda20bd4fda 100644 --- a/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_consent.jsp +++ b/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_consent.jsp @@ -415,7 +415,7 @@
- <%=AuthenticationEndpointUtil.i18n(resourceBundle, "requested.authorization.details")%> + <%= i18n(resourceBundle, customText, "requested.authorization.details") %>
diff --git a/identity-apps-core/pom.xml b/identity-apps-core/pom.xml index 1738f3fd2e4..df417b19844 100644 --- a/identity-apps-core/pom.xml +++ b/identity-apps-core/pom.xml @@ -729,14 +729,14 @@ 3.0.0 5.1.5 1.0.8 - 7.7.130 + 7.2.30 [5.0.0, 8.0.0) 1.0.77 [1.0.77, 2.0.0) 1.3.89 [1.3.89, 2.0.0) - 7.0.224 + 6.7.130 [6.1.0, 8.0.0) 1.8.41 3.2.2 From 8bb552a24c6cac4d01b38932add6c46905dc24c9 Mon Sep 17 00:00:00 2001 From: vimukthiRajapaksha Date: Fri, 24 Jan 2025 17:17:24 +0530 Subject: [PATCH 7/8] Add changeset --- .changeset/wise-queens-fix.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/wise-queens-fix.md diff --git a/.changeset/wise-queens-fix.md b/.changeset/wise-queens-fix.md new file mode 100644 index 00000000000..740a98a08c3 --- /dev/null +++ b/.changeset/wise-queens-fix.md @@ -0,0 +1,5 @@ +--- +"@wso2is/identity-apps-core": minor +--- + +Added support to display authorization details on the consent screen. This optional field, if included in the authorize request, will be shown on the consent screen when user consent is required. From ef66c3344f1e03eb0923588042aa52f9f72ac807 Mon Sep 17 00:00:00 2001 From: vimukthiRajapaksha Date: Fri, 24 Jan 2025 20:01:21 +0530 Subject: [PATCH 8/8] Catch JSONException and ignore the error for invalid JSON payloads --- .../src/main/webapp/oauth2_authz.jsp | 25 +++++++++++-------- .../src/main/webapp/oauth2_consent.jsp | 25 +++++++++++-------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_authz.jsp b/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_authz.jsp index da3053b78db..44a30d0fd90 100644 --- a/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_authz.jsp +++ b/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_authz.jsp @@ -26,6 +26,7 @@ <%@ page import="java.io.File" %> <%@ page import="java.util.Set" %> <%@ page import="org.json.JSONArray" %> +<%@ page import="org.json.JSONException" %> <%@ page import="org.json.JSONObject" %> <%@ taglib prefix="layout" uri="org.wso2.identity.apps.taglibs.layout.controller" %> @@ -64,18 +65,22 @@ boolean displayScopes = Boolean.parseBoolean(getServletContext().getInitParameter("displayScopes")); - final String authorizationDetailsParam = request.getParameter("authorization_details"); final Map authorizationDetailsToBeDisplayed = new HashMap<>(); - if (StringUtils.isNotBlank(authorizationDetailsParam)) { - final JSONArray authorizationDetails = new JSONArray(authorizationDetailsParam); - for (int index = 0; index < authorizationDetails.length(); index++) { - JSONObject authorizationDetail = authorizationDetails.getJSONObject(index); - - // Check if consent description is not empty, otherwise use type. - final String description = authorizationDetail.optString("_description", authorizationDetail.getString("type")); - final String authorizationDetailId = "authorization_detail_id_" + authorizationDetail.getString("_id"); - authorizationDetailsToBeDisplayed.put(authorizationDetailId, description); + try { + final String authorizationDetailsParam = request.getParameter("authorization_details"); + if (StringUtils.isNotBlank(authorizationDetailsParam)) { + final JSONArray authorizationDetails = new JSONArray(authorizationDetailsParam); + for (int index = 0; index < authorizationDetails.length(); index++) { + JSONObject authorizationDetail = authorizationDetails.getJSONObject(index); + + // Check if consent description is not empty, otherwise use type. + final String description = authorizationDetail.optString("_description", authorizationDetail.getString("type")); + final String authorizationDetailId = "authorization_detail_id_" + authorizationDetail.getString("_id"); + authorizationDetailsToBeDisplayed.put(authorizationDetailId, description); + } } + } catch (JSONException e) { + // Ignore the error } %> diff --git a/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_consent.jsp b/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_consent.jsp index eda20bd4fda..c0bcddffe4c 100644 --- a/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_consent.jsp +++ b/identity-apps-core/apps/authentication-portal/src/main/webapp/oauth2_consent.jsp @@ -30,6 +30,7 @@ <%@ page import="java.util.stream.Stream" %> <%@ page import="java.util.Set" %> <%@ page import="org.json.JSONArray" %> +<%@ page import="org.json.JSONException" %> <%@ page import="org.json.JSONObject" %> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="layout" uri="org.wso2.identity.apps.taglibs.layout.controller" %> @@ -171,18 +172,22 @@ } int claimSize = requestedClaimList.length + mandatoryClaimList.length; - final String authorizationDetailsParam = request.getParameter("authorization_details"); final Map authorizationDetailsToBeDisplayed = new HashMap<>(); - if (StringUtils.isNotBlank(authorizationDetailsParam)) { - org.json.JSONArray authorizationDetails = new JSONArray(authorizationDetailsParam); - for (int index = 0; index < authorizationDetails.length(); index++) { - JSONObject authorizationDetail = authorizationDetails.getJSONObject(index); - - // Check if consent description is not empty, otherwise use type. - final String description = authorizationDetail.optString("_description", authorizationDetail.getString("type")); - final String authorizationDetailId = "authorization_detail_id_" + authorizationDetail.getString("_id"); - authorizationDetailsToBeDisplayed.put(authorizationDetailId, description); + try { + final String authorizationDetailsParam = request.getParameter("authorization_details"); + if (StringUtils.isNotBlank(authorizationDetailsParam)) { + org.json.JSONArray authorizationDetails = new JSONArray(authorizationDetailsParam); + for (int index = 0; index < authorizationDetails.length(); index++) { + JSONObject authorizationDetail = authorizationDetails.getJSONObject(index); + + // Check if consent description is not empty, otherwise use type. + final String description = authorizationDetail.optString("_description", authorizationDetail.getString("type")); + final String authorizationDetailId = "authorization_detail_id_" + authorizationDetail.getString("_id"); + authorizationDetailsToBeDisplayed.put(authorizationDetailId, description); + } } + } catch (JSONException e) { + // Ignore the error } %>