diff --git a/boot/d4s-boot.js b/boot/d4s-boot.js index 21c3a8d..b3296bd 100644 --- a/boot/d4s-boot.js +++ b/boot/d4s-boot.js @@ -21,6 +21,7 @@ window.customElements.define('d4s-boot-2', class extends HTMLElement { #queue = [] #interval = null #config = null + #uma = false #rpt = null constructor() { @@ -63,8 +64,8 @@ window.customElements.define('d4s-boot-2', class extends HTMLElement { console.log("Keycloak initialized and user authenticated") //console.log("Token exp: " + this.expirationDate(this.#keycloak.tokenParsed.exp)) - //if an audience is provided then perform also authorization - if (this.#audience) { + //if an audience is provided and UMA flow requested then perform also authorization + if (this.#audience && this.#uma) { return this.loadConfig() } else { Promise.resolve() @@ -101,7 +102,11 @@ window.customElements.define('d4s-boot-2', class extends HTMLElement { clientId: this.#clientId }) - return this.#keycloak.init({onLoad: 'login-required', checkLoginIframe: false }) + const properties = {onLoad: 'login-required', checkLoginIframe: false} + if(this.#audience && !this.#uma){ + properties["scope"] = `d4s-context:${this.#audience}` + } + return this.#keycloak.init(properties) } startStateChecker() { @@ -113,7 +118,7 @@ window.customElements.define('d4s-boot-2', class extends HTMLElement { } else { if (this.#queue.length > 0) { this.#keycloak.updateToken(30).then(() => { - if (this.#audience) { + if (this.#uma && this.#audience) { //console.log("Checking entitlement for audience", this.#audience) const audience = encodeURIComponent(this.#audience) return this.entitlement(audience) @@ -156,18 +161,19 @@ window.customElements.define('d4s-boot-2', class extends HTMLElement { return d } - checkContext() { - const parseJwt = this.parseJwt - const expDt = this.expirationDate - const audience = encodeURIComponent(this.#audience) - this.entitlement(audience).then(function (rpt) { - // onGrant callback function. - // If authorization was successful you'll receive an RPT - // with the necessary permissions to access the resource server - //console.log(rpt) - //console.log("rpt expires: " + expDt(parseJwt(rpt).exp)) - }) - } + // TODO: Candidate for removal + // checkContext() { + // const parseJwt = this.parseJwt + // const expDt = this.expirationDate + // const audience = encodeURIComponent(this.#audience) + // this.entitlement(audience).then(function (rpt) { + // // onGrant callback function. + // // If authorization was successful you'll receive an RPT + // // with the necessary permissions to access the resource server + // //console.log(rpt) + // //console.log("rpt expires: " + expDt(parseJwt(rpt).exp)) + // }) + // } secureFetch(url, request) { const p = new Promise((resolve, reject) => { @@ -291,7 +297,7 @@ window.customElements.define('d4s-boot-2', class extends HTMLElement { } static get observedAttributes() { - return ["url", "realm", "gateway", "redirect-url", "context"]; + return ["url", "realm", "gateway", "redirect-url", "context", "uma"]; } attributeChangedCallback(name, oldValue, newValue) { @@ -312,10 +318,17 @@ window.customElements.define('d4s-boot-2', class extends HTMLElement { case "context": this.#audience = newValue break + case "uma": + this.#uma = newValue === "true" ? true : false + break } } } + get uma(){ + return this.#uma + } + get authenticated(){ return this.#authenticated } diff --git a/ccp/js/executionformcontroller.js b/ccp/js/executionformcontroller.js index 83cea27..91b7e26 100644 --- a/ccp/js/executionformcontroller.js +++ b/ccp/js/executionformcontroller.js @@ -491,7 +491,7 @@ class CCPExecutionForm extends HTMLElement { "in": (e, d) => { return Object.values(d.inputs) }, target: "div", apply: (e, d) => { - e.innerHTML = `` + e.innerHTML = `` } } ] @@ -504,7 +504,7 @@ class CCPExecutionForm extends HTMLElement { "in": (e, d) => { return Object.values(d.outputs) }, target: "div", apply: (e, d) => { - e.innerHTML = `` + e.innerHTML = `` } } ] diff --git a/ccp/js/executionhistorycontroller.js b/ccp/js/executionhistorycontroller.js index 7ce2b03..ab157d8 100644 --- a/ccp/js/executionhistorycontroller.js +++ b/ccp/js/executionhistorycontroller.js @@ -53,7 +53,9 @@ class CCPExecutionHistory extends HTMLElement { "runtime_help" : "The runtime where this execution has been scheduled on", "loading_archived_help" : "Loading archived executions from workspace. This can take a while.", "err_reexecute" : "Unable to re-submit the execution. Please check console for further info", - "err_generate_code_for" : "Unable to generate code for " + "err_generate_code_for" : "Unable to generate code for ", + "show_metadata" : "Show metadata", + "show_metadata_help" : "Show also metadata related to this execution", } } @@ -180,8 +182,12 @@ class CCPExecutionHistory extends HTMLElement {
-