Improve consent management page to process oidc requests

revert-70ac1926
Vigneshan Seshamany 4 years ago
parent f31befb342
commit 0917d3bf7f

@ -29,7 +29,7 @@
</div>
<div class="panel-body">
<form id="consentForm" method="POST" action="/commonauth">
<form id="consentForm" method="POST" action={{action}}>
<p>By selecting following attributes I agree to share them with the above service provider.</p>
{{#unless singleMandatoryClaim}}
<div class="wr-input-control">
@ -60,9 +60,9 @@
</div>
<p class="small">Mandatory claims are marked with an asterisk ( * )</p>
<div class="wr-input-control wr-btn-grp">
<input type="hidden" name="sessionDataKey" value="{{sessionDataKey}}"/>
<input type="hidden" name="{{sessionDataKeyName}}" value="{{sessionDataKey}}"/>
<input type="hidden" name="consent" id="consent" value="deny"/>
<button class="btn btn-primary" onclick="approved()">Approve</button>
<button class="btn btn-primary" onclick="approved('{{ssoProtocol}}')">Approve</button>
<button class="btn btn-default" onclick="deny()">Deny</button>
</div>
</form>
@ -72,4 +72,4 @@
{{/zone}}
{{#zone "bottomJs"}}
{{js "js/script.js"}}
{{/zone}}
{{/zone}}

@ -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;
}
}

@ -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);
}
});
});
});

Loading…
Cancel
Save