diff --git a/adapters/oidc/js/src/main/resources/keycloak-authz.js b/adapters/oidc/js/src/main/resources/keycloak-authz.js index 4e4255637e..2ce9ba4465 100644 --- a/adapters/oidc/js/src/main/resources/keycloak-authz.js +++ b/adapters/oidc/js/src/main/resources/keycloak-authz.js @@ -118,12 +118,11 @@ /** * Obtains all entitlements from a Keycloak Server based on a give resourceServerId. */ - this.entitlement = function (resourceSeververId) { + this.entitlement = function (resourceSeververId, permissionRequests) { this.then = function (onGrant, onDeny, onError) { var request = new XMLHttpRequest(); - request.open('GET', keycloak.authServerUrl + '/realms/' + keycloak.realm + '/authz/entitlement/' + resourceSeververId, true); - request.setRequestHeader('Authorization', 'Bearer ' + keycloak.token) + request.onreadystatechange = function () { if (request.readyState == 4) { @@ -149,7 +148,19 @@ } }; - request.send(null); + var erJson = null + + if(permissionRequests) { + request.open('POST', keycloak.authServerUrl + '/realms/' + keycloak.realm + '/authz/entitlement/' + resourceSeververId, true); + request.setRequestHeader("Content-type", "application/json"); + erJson = JSON.stringify(permissionRequests) + } else { + request.open('GET', keycloak.authServerUrl + '/realms/' + keycloak.realm + '/authz/entitlement/' + resourceSeververId, true); + } + + request.setRequestHeader('Authorization', 'Bearer ' + keycloak.token) + request.send(erJson); + }; return this;