From 072aefa9567ec763dca64076f31aa333da99b8e1 Mon Sep 17 00:00:00 2001 From: Josemi Date: Tue, 10 Oct 2023 11:51:55 +0200 Subject: [PATCH 1/8] wc: add dropdownParent to select2 configuration in select-token-filter #TASK-5019 --- src/webcomponents/commons/forms/select-token-filter.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/webcomponents/commons/forms/select-token-filter.js b/src/webcomponents/commons/forms/select-token-filter.js index c1438e802d..6c79b01884 100644 --- a/src/webcomponents/commons/forms/select-token-filter.js +++ b/src/webcomponents/commons/forms/select-token-filter.js @@ -55,6 +55,7 @@ export default class SelectTokenFilter extends LitElement { firstUpdated() { this.select = $("#" + this._prefix); this.select.select2({ + dropdownParent: document.querySelector(`#${this._prefix}`).parentElement, separator: this._config.separator ?? [","], tags: this._config.freeTag ?? true, multiple: this._config.multiple ?? true, From 470b07fdd04fcec2f70713a93f4dc4188e9a40a1 Mon Sep 17 00:00:00 2001 From: Josemi Date: Tue, 10 Oct 2023 16:50:52 +0200 Subject: [PATCH 2/8] iva: disable creating sso cookie in iva app #TASK-5096 --- src/sites/iva/iva-app.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/sites/iva/iva-app.js b/src/sites/iva/iva-app.js index 96737fac09..d954963412 100644 --- a/src/sites/iva/iva-app.js +++ b/src/sites/iva/iva-app.js @@ -338,15 +338,16 @@ class IvaApp extends LitElement { const opencgaVersion = serverConf?.version || this.config.opencga.version; const opencgaPrefix = serverConf?.cookie?.prefix || this.config.opencga.cookie.prefix; const opencgaSsoActive = serverConf?.sso?.active ?? this.config.opencga.sso?.active ?? false; - const opencgaSsoCookie = serverConf?.sso?.cookie ?? this.config.opencga.sso?.cookie ?? "JSESSIONID"; + // const opencgaSsoCookie = serverConf?.sso?.cookie ?? this.config.opencga.sso?.cookie ?? "JSESSIONID"; // Check if SSO mode is enabled if (opencgaSsoActive) { const currentUrl = new URL(window.location); - if (currentUrl.searchParams.has("token") && currentUrl.searchParams.has(opencgaSsoCookie)) { + // if (currentUrl.searchParams.has("token") && currentUrl.searchParams.has(opencgaSsoCookie)) { + if (currentUrl.searchParams.has("token")) { // Save token and session ID in cookies // eslint-disable-next-line no-undef - Cookies.set(opencgaSsoCookie, currentUrl.searchParams.get(opencgaSsoCookie), {secure: true}); + // Cookies.set(opencgaSsoCookie, currentUrl.searchParams.get(opencgaSsoCookie), {secure: true}); // eslint-disable-next-line no-undef Cookies.set(opencgaPrefix + "_sid", currentUrl.searchParams.get("token"), {secure: true}); @@ -640,7 +641,7 @@ class IvaApp extends LitElement { // Check if sso is active: we will redirect to 'meta/sso/logout' endpoint if (this.opencgaClient?._config?.sso) { // eslint-disable-next-line no-undef - Cookies.expire("JSESSIONID"); + // Cookies.expire("JSESSIONID"); const config = this.opencgaClient._config; const ivaUrl = window.location; From 3488ed27c27b8a60b044179ab0dd225530dedddc Mon Sep 17 00:00:00 2001 From: Josemi Date: Mon, 16 Oct 2023 18:35:16 +0200 Subject: [PATCH 3/8] iva: remove commented code #TASK-5096 --- src/sites/iva/iva-app.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/sites/iva/iva-app.js b/src/sites/iva/iva-app.js index d954963412..0a6bce92d2 100644 --- a/src/sites/iva/iva-app.js +++ b/src/sites/iva/iva-app.js @@ -338,16 +338,11 @@ class IvaApp extends LitElement { const opencgaVersion = serverConf?.version || this.config.opencga.version; const opencgaPrefix = serverConf?.cookie?.prefix || this.config.opencga.cookie.prefix; const opencgaSsoActive = serverConf?.sso?.active ?? this.config.opencga.sso?.active ?? false; - // const opencgaSsoCookie = serverConf?.sso?.cookie ?? this.config.opencga.sso?.cookie ?? "JSESSIONID"; // Check if SSO mode is enabled if (opencgaSsoActive) { const currentUrl = new URL(window.location); - // if (currentUrl.searchParams.has("token") && currentUrl.searchParams.has(opencgaSsoCookie)) { if (currentUrl.searchParams.has("token")) { - // Save token and session ID in cookies - // eslint-disable-next-line no-undef - // Cookies.set(opencgaSsoCookie, currentUrl.searchParams.get(opencgaSsoCookie), {secure: true}); // eslint-disable-next-line no-undef Cookies.set(opencgaPrefix + "_sid", currentUrl.searchParams.get("token"), {secure: true}); @@ -640,9 +635,6 @@ class IvaApp extends LitElement { // Check if sso is active: we will redirect to 'meta/sso/logout' endpoint if (this.opencgaClient?._config?.sso) { - // eslint-disable-next-line no-undef - // Cookies.expire("JSESSIONID"); - const config = this.opencgaClient._config; const ivaUrl = window.location; window.location = `${config.host}/webservices/rest/${config.version}/meta/sso/logout?url=${ivaUrl}`; From 3ff54d9f92289bf3049363a1cddd9eb9be6167d6 Mon Sep 17 00:00:00 2001 From: Josemi Date: Wed, 18 Oct 2023 13:02:04 +0200 Subject: [PATCH 4/8] iva: restore generating sso cookie #TASK-5096 --- src/sites/iva/iva-app.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/sites/iva/iva-app.js b/src/sites/iva/iva-app.js index 0a6bce92d2..96737fac09 100644 --- a/src/sites/iva/iva-app.js +++ b/src/sites/iva/iva-app.js @@ -338,11 +338,15 @@ class IvaApp extends LitElement { const opencgaVersion = serverConf?.version || this.config.opencga.version; const opencgaPrefix = serverConf?.cookie?.prefix || this.config.opencga.cookie.prefix; const opencgaSsoActive = serverConf?.sso?.active ?? this.config.opencga.sso?.active ?? false; + const opencgaSsoCookie = serverConf?.sso?.cookie ?? this.config.opencga.sso?.cookie ?? "JSESSIONID"; // Check if SSO mode is enabled if (opencgaSsoActive) { const currentUrl = new URL(window.location); - if (currentUrl.searchParams.has("token")) { + if (currentUrl.searchParams.has("token") && currentUrl.searchParams.has(opencgaSsoCookie)) { + // Save token and session ID in cookies + // eslint-disable-next-line no-undef + Cookies.set(opencgaSsoCookie, currentUrl.searchParams.get(opencgaSsoCookie), {secure: true}); // eslint-disable-next-line no-undef Cookies.set(opencgaPrefix + "_sid", currentUrl.searchParams.get("token"), {secure: true}); @@ -635,6 +639,9 @@ class IvaApp extends LitElement { // Check if sso is active: we will redirect to 'meta/sso/logout' endpoint if (this.opencgaClient?._config?.sso) { + // eslint-disable-next-line no-undef + Cookies.expire("JSESSIONID"); + const config = this.opencgaClient._config; const ivaUrl = window.location; window.location = `${config.host}/webservices/rest/${config.version}/meta/sso/logout?url=${ivaUrl}`; From 37933c55cd42b25f80a59ad10466d70102ba00eb Mon Sep 17 00:00:00 2001 From: Josemi Date: Wed, 18 Oct 2023 13:11:56 +0200 Subject: [PATCH 5/8] iva: fix deleting sso cookie in logout #TASK-5096 --- src/sites/iva/iva-app.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/sites/iva/iva-app.js b/src/sites/iva/iva-app.js index 96737fac09..d76fb5c4f8 100644 --- a/src/sites/iva/iva-app.js +++ b/src/sites/iva/iva-app.js @@ -381,7 +381,10 @@ class IvaApp extends LitElement { active: true, prefix: opencgaPrefix, }, - sso: opencgaSsoActive, + sso: { + active: opencgaSsoActive, + cookie: opencgaSsoCookie, + }, }); this.reactomeClient = new ReactomeClient(); @@ -638,9 +641,9 @@ class IvaApp extends LitElement { await this.opencgaClient.logout(); // Check if sso is active: we will redirect to 'meta/sso/logout' endpoint - if (this.opencgaClient?._config?.sso) { + if (this.opencgaClient?._config?.sso?.active) { // eslint-disable-next-line no-undef - Cookies.expire("JSESSIONID"); + Cookies.expire(this.opencgaClient._config.sso.cookie); const config = this.opencgaClient._config; const ivaUrl = window.location; From a17dee51f9ef85bf5b4dabc1fcab38719949bff6 Mon Sep 17 00:00:00 2001 From: Josemi Date: Wed, 18 Oct 2023 14:45:25 +0200 Subject: [PATCH 6/8] clients: change default config for sso in opencga-client #TASK-5096 --- src/core/clients/opencga/opencga-client.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/clients/opencga/opencga-client.js b/src/core/clients/opencga/opencga-client.js index aaf6d0b6a5..a3ac9c9962 100644 --- a/src/core/clients/opencga/opencga-client.js +++ b/src/core/clients/opencga/opencga-client.js @@ -57,7 +57,10 @@ export class OpenCGAClient { prefix: "" // expirationTime: "" }, - sso: false, + sso: { + active: false, + cookie: "JSESSIONID", + }, }; } @@ -80,7 +83,7 @@ export class OpenCGAClient { console.error(e); // Josemi NOTE 20230324 Terrible hack to prevent displaying OpenCGA host not available error // when iva starts, as the /meta/about is restricted when SSO is enabled - if (!this._config.sso) { + if (!this._config?.sso?.active) { globalEvent("signingInError", {value: "Opencga host not available."}); globalEvent("hostInit", {host: "opencga", value: "NOT AVAILABLE"}); } From b76daea7b0816c2cbacba4f9419179d08fe08527 Mon Sep 17 00:00:00 2001 From: Josemi Date: Wed, 18 Oct 2023 14:45:55 +0200 Subject: [PATCH 7/8] clients: fix checking if sso is active in parent class of opencga-client #TASK-5096 --- src/core/clients/opencga/opencga-parent-class.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/clients/opencga/opencga-parent-class.js b/src/core/clients/opencga/opencga-parent-class.js index 5df7e4934f..14e74f6eec 100644 --- a/src/core/clients/opencga/opencga-parent-class.js +++ b/src/core/clients/opencga/opencga-parent-class.js @@ -49,7 +49,7 @@ export default class OpenCGAParentClass { } // Enable credentials - _options.includeCredentials = !!this._config.sso; + _options.includeCredentials = !!this._config?.sso?.active; // console.log(`OpenCGA client calling to ${url}`); // if the URL query fails we try with next host @@ -83,7 +83,7 @@ export default class OpenCGAParentClass { } // Enable credentials - _options.includeCredentials = !!this._config.sso; + _options.includeCredentials = !!this._config?.sso?.active; return this.restClient.call(url, _options, k); } @@ -106,7 +106,7 @@ export default class OpenCGAParentClass { // _options.body = _params.body; // Enable credentials - _options.includeCredentials = !!this._config.sso; + _options.includeCredentials = !!this._config?.sso?.active; return this.restClient.call(url, _options, k); } From fad455b1043615b37f6af6186f0b152df9469b12 Mon Sep 17 00:00:00 2001 From: Josemi Date: Wed, 18 Oct 2023 14:51:03 +0200 Subject: [PATCH 8/8] wc: fix checking if sso mode is active in custom-landing and fix sso button style #TASK-5096 --- .../commons/layouts/custom-landing.js | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/webcomponents/commons/layouts/custom-landing.js b/src/webcomponents/commons/layouts/custom-landing.js index 80cc6fedf9..58a43231bd 100644 --- a/src/webcomponents/commons/layouts/custom-landing.js +++ b/src/webcomponents/commons/layouts/custom-landing.js @@ -242,20 +242,22 @@ export default class CustomLanding extends LitElement { ` : null}