mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Improve consent management page to process oidc requests
This commit is contained in:
parent
f31befb342
commit
0917d3bf7f
@ -29,7 +29,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="panel-body">
|
<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>
|
<p>By selecting following attributes I agree to share them with the above service provider.</p>
|
||||||
{{#unless singleMandatoryClaim}}
|
{{#unless singleMandatoryClaim}}
|
||||||
<div class="wr-input-control">
|
<div class="wr-input-control">
|
||||||
@ -60,9 +60,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<p class="small">Mandatory claims are marked with an asterisk ( * )</p>
|
<p class="small">Mandatory claims are marked with an asterisk ( * )</p>
|
||||||
<div class="wr-input-control wr-btn-grp">
|
<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"/>
|
<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>
|
<button class="btn btn-default" onclick="deny()">Deny</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@ -72,4 +72,4 @@
|
|||||||
{{/zone}}
|
{{/zone}}
|
||||||
{{#zone "bottomJs"}}
|
{{#zone "bottomJs"}}
|
||||||
{{js "js/script.js"}}
|
{{js "js/script.js"}}
|
||||||
{{/zone}}
|
{{/zone}}
|
||||||
|
|||||||
@ -1,7 +1,21 @@
|
|||||||
function onRequest(context) {
|
function onRequest(context) {
|
||||||
var Encode = Packages.org.owasp.encoder.Encode;
|
var Encode = Packages.org.owasp.encoder.Encode;
|
||||||
var viewModel = {};
|
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 mandatoryClaims = [];
|
||||||
var requestedClaims = [];
|
var requestedClaims = [];
|
||||||
var singleMandatoryClaim = false;
|
var singleMandatoryClaim = false;
|
||||||
@ -36,6 +50,5 @@ function onRequest(context) {
|
|||||||
viewModel.mandatoryClaims = mandatoryClaims;
|
viewModel.mandatoryClaims = mandatoryClaims;
|
||||||
viewModel.requestedClaims = requestedClaims;
|
viewModel.requestedClaims = requestedClaims;
|
||||||
viewModel.singleMandatoryClaim = singleMandatoryClaim;
|
viewModel.singleMandatoryClaim = singleMandatoryClaim;
|
||||||
viewModel.sessionDataKey = Encode.forHtmlAttribute(request.getParameter("sessionDataKey"));
|
|
||||||
return viewModel;
|
return viewModel;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,13 @@
|
|||||||
function approved() {
|
function approved(ssoProtocol) {
|
||||||
var mandatoryClaimCBs = $(".mandatory-claim");
|
var mandatoryClaimCBs = $(".mandatory-claim");
|
||||||
var checkedMandatoryClaimCBs = $(".mandatory-claim:checked");
|
var checkedMandatoryClaimCBs = $(".mandatory-claim:checked");
|
||||||
|
|
||||||
if (checkedMandatoryClaimCBs.length == mandatoryClaimCBs.length) {
|
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();
|
document.getElementById("consentForm").submit();
|
||||||
} else {
|
} else {
|
||||||
$("#modal_claim_validation").modal();
|
$("#modal_claim_validation").modal();
|
||||||
@ -32,4 +36,4 @@ $(document).ready(function () {
|
|||||||
$("#consent_select_all").prop("checked", false);
|
$("#consent_select_all").prop("checked", false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user