From 0917d3bf7fdb8e8bba00fd4a5569268080a6b31c Mon Sep 17 00:00:00 2001 From: Vigneshan Date: Fri, 4 Dec 2020 10:06:28 +0530 Subject: [PATCH] Improve consent management page to process oidc requests --- .../consent-do.hbs | 8 ++++---- .../consent-do.js | 19 ++++++++++++++++--- .../public/js/script.js | 10 +++++++--- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in.consent-do/consent-do.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in.consent-do/consent-do.hbs index 56f05e6956..22869a4828 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in.consent-do/consent-do.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in.consent-do/consent-do.hbs @@ -29,7 +29,7 @@
-
+

By selecting following attributes I agree to share them with the above service provider.

{{#unless singleMandatoryClaim}}
@@ -60,9 +60,9 @@

Mandatory claims are marked with an asterisk ( * )

- + - +
@@ -72,4 +72,4 @@ {{/zone}} {{#zone "bottomJs"}} {{js "js/script.js"}} -{{/zone}} \ No newline at end of file +{{/zone}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in.consent-do/consent-do.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in.consent-do/consent-do.js index 346b81df46..e3e4224eda 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in.consent-do/consent-do.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in.consent-do/consent-do.js @@ -1,7 +1,21 @@ function onRequest(context) { var Encode = Packages.org.owasp.encoder.Encode; var viewModel = {}; - viewModel.appName = Encode.forHtml(request.getParameter("sp")); + + // if sp is received, its a saml request or else its oidc + if(request.getParameter("sp") !== null) { + viewModel.appName = Encode.forHtml(request.getParameter("sp")); + viewModel.action = "/commonauth"; + viewModel.sessionDataKey = Encode.forHtmlAttribute(request.getParameter("sessionDataKey")); + viewModel.sessionDataKeyName = "sessionDataKey"; + viewModel.ssoProtocol = "saml"; + } else { + viewModel.appName = Encode.forHtml(request.getParameter("application")); + viewModel.action = "../oauth2/authorize"; + viewModel.sessionDataKey = Encode.forHtmlAttribute(request.getParameter("sessionDataKeyConsent")); + viewModel.sessionDataKeyName = "sessionDataKeyConsent"; + viewModel.ssoProtocol = "oidc"; + } var mandatoryClaims = []; var requestedClaims = []; var singleMandatoryClaim = false; @@ -36,6 +50,5 @@ function onRequest(context) { viewModel.mandatoryClaims = mandatoryClaims; viewModel.requestedClaims = requestedClaims; viewModel.singleMandatoryClaim = singleMandatoryClaim; - viewModel.sessionDataKey = Encode.forHtmlAttribute(request.getParameter("sessionDataKey")); return viewModel; -} \ No newline at end of file +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in.consent-do/public/js/script.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in.consent-do/public/js/script.js index 8588c004a9..7f6fff8d8b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in.consent-do/public/js/script.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in.consent-do/public/js/script.js @@ -1,9 +1,13 @@ -function approved() { +function approved(ssoProtocol) { var mandatoryClaimCBs = $(".mandatory-claim"); var checkedMandatoryClaimCBs = $(".mandatory-claim:checked"); if (checkedMandatoryClaimCBs.length == mandatoryClaimCBs.length) { - document.getElementById('consent').value = "approve"; + if(ssoProtocol === "saml") { + document.getElementById('consent').value = "approve"; + } else if(ssoProtocol === "oidc") { + document.getElementById('consent').value = "approveAlways"; + } document.getElementById("consentForm").submit(); } else { $("#modal_claim_validation").modal(); @@ -32,4 +36,4 @@ $(document).ready(function () { $("#consent_select_all").prop("checked", false); } }); -}); \ No newline at end of file +});