Skip to content

Commit

Permalink
Merge pull request #7117 from VimukthiRajapaksha/master_rar
Browse files Browse the repository at this point in the history
  • Loading branch information
pavinduLakshan authored Jan 24, 2025
2 parents fb65f7e + ef66c33 commit f646ab5
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/wise-queens-fix.md
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ under.construction=このページは現在作成中です
by.selecting.following.attributes=以下の属性を選択することで、それらを共有することに同意したものとみなされます
select.all=すべて選択
requested.scopes=以下への許可を取得:
requested.authorization.details=同意を得る
requested.attributes=詳細を理解してください
please.select.approve.always=スコープを継続する場合は、「一度だけ承認」または「常に承認」のいずれかを選択してください
ok=了解
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ under.construction=此页面正在建设中
by.selecting.following.attributes=通过选择以下属性,您同意与之共享
select.all=全选
requested.scopes=获得许可
requested.authorization.details==获得同意
requested.attributes=了解您的一些细节
please.select.approve.always=请选择“一次批准”或“批准”以提供要求继续的范围的同意
ok=
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%--
~
~ Copyright (c) 2023, 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
Expand All @@ -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" %>
Expand All @@ -25,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" %>

Expand Down Expand Up @@ -62,6 +64,24 @@
}
boolean displayScopes = Boolean.parseBoolean(getServletContext().getInitParameter("displayScopes"));
final Map<String, String> authorizationDetailsToBeDisplayed = new HashMap<>();
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
}
%>

<%-- Data for the layout from the page --%>
Expand Down Expand Up @@ -233,6 +253,45 @@
}
%>

<%
if (MapUtils.isNotEmpty(authorizationDetailsToBeDisplayed)) {
%>
<div style="text-align: left;">
<div class="claim-list ui list">
<div class="item mt-2">
<i aria-hidden="true" class="circle tiny icon primary consent-item-bullet" id="Authorization Details Types"></i>
<div class="content mt-2">
<div class="header light-font">
<%= i18n(resourceBundle, customText, "requested.authorization.details") %>
</div>
</div>
<div class="content light-font">
<div class="border-gray margin-bottom-double">
<div class="claim-list">
<%
for (Map.Entry<String, String> authorizationDetailEntry : authorizationDetailsToBeDisplayed.entrySet()) {
%>
<div class="mt-1 pl-2">
<div class="ui checkbox" style="display: flex">
<input type="checkbox" class="hidden" name="<%=authorizationDetailEntry.getKey()%>" id="<%=authorizationDetailEntry.getKey()%>" />
<label id="<%=authorizationDetailEntry.getKey()%>" for="<%=authorizationDetailEntry.getKey()%>">
<%=Encode.forHtml(authorizationDetailEntry.getValue())%>
</label>
</div>
</div>
<%
}
%>
</div>
</div>
</div>
</div>
</div>
</div>
<%
}
%>

<div class="ui divider hidden"></div>

<div class="field mt-4 text-center login-portal-app-des-font">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%--
~
~ Copyright (c) 2021, 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
Expand All @@ -10,6 +10,7 @@
--%>

<%@ page import="org.apache.commons.collections.CollectionUtils" %>
<%@ page import="org.apache.commons.collections.MapUtils" %>
<%@ page import="org.apache.commons.lang.ArrayUtils" %>
<%@ page import="org.apache.commons.lang.StringUtils" %>
<%@ page import="org.owasp.encoder.Encode" %>
Expand All @@ -29,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" %>
Expand Down Expand Up @@ -57,22 +59,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);
}
}
Expand Down Expand Up @@ -169,6 +171,24 @@
scopesSize = openIdScopes.size();
}
int claimSize = requestedClaimList.length + mandatoryClaimList.length;
final Map<String, String> authorizationDetailsToBeDisplayed = new HashMap<>();
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
}
%>

<!doctype html>
Expand Down Expand Up @@ -204,7 +224,7 @@
<% } %>
<%
if (!(ArrayUtils.isNotEmpty(mandatoryClaimList) || ArrayUtils.isNotEmpty(requestedClaimList) || CollectionUtils.isNotEmpty(openIdScopes)
|| CollectionUtils.isNotEmpty(scopesWithMetadata))){
|| CollectionUtils.isNotEmpty(scopesWithMetadata) || MapUtils.isNotEmpty(authorizationDetailsToBeDisplayed))) {
%>
<form action="<%=oauth2AuthorizeURL%>" method="post" id="profile2" name="oauth2_authz">
<input type="hidden" name="<%=Constants.SESSION_DATA_KEY_CONSENT%>"
Expand Down Expand Up @@ -233,7 +253,7 @@
</h4>
</div>
</div>

<p class="login-portal-app-consent-request larger-font">
<%=AuthenticationEndpointUtil.i18n(resourceBundle, "this.will.allow.application.to")%>:
</p>
Expand Down Expand Up @@ -392,6 +412,42 @@
}
}
%>

<%
if (MapUtils.isNotEmpty(authorizationDetailsToBeDisplayed)) {
%>
<div class="item">
<i aria-hidden="true" class="circle tiny icon primary consent-item-bullet" id="Grant access"></i>
<div class="content mt-2 pl-1 consentItem">
<div class="header light-font">
<%= i18n(resourceBundle, customText, "requested.authorization.details") %>
</div>
</div>
<div class="content light-font">
<div class="border-gray margin-bottom-double">
<div class="claim-list">
<%
for (Map.Entry<String, String> authorizationDetailEntry : authorizationDetailsToBeDisplayed.entrySet()) {
%>
<div class="mt-1 pl-2">
<div class="ui checkbox" style="display: flex">
<input type="checkbox" class="hidden" name="<%=authorizationDetailEntry.getKey()%>" id="<%=authorizationDetailEntry.getKey()%>" />
<label id="<%=authorizationDetailEntry.getKey()%>" for="<%=authorizationDetailEntry.getKey()%>">
<%=Encode.forHtml(authorizationDetailEntry.getValue())%>
</label>
</div>
</div>
<%
}
%>
</div>
</div>
</div>
</div>
<%
}
%>

</div>
</div>
<div class="ui divider hidden"></div>
Expand Down

0 comments on commit f646ab5

Please sign in to comment.