From 42f20132ce91e46172b6dc22d690c65d747ef526 Mon Sep 17 00:00:00 2001 From: Josemi Date: Mon, 9 Dec 2024 13:39:21 +0100 Subject: [PATCH 1/3] iva-app: Remove cookies and reset OpenCGA session when saved token is not valid #TASK-7256 --- src/sites/iva/iva-app.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sites/iva/iva-app.js b/src/sites/iva/iva-app.js index b3aa7b010..a72b8a6a9 100644 --- a/src/sites/iva/iva-app.js +++ b/src/sites/iva/iva-app.js @@ -596,6 +596,9 @@ class IvaApp extends LitElement { .catch(e => { console.error(e); this.notificationManager.error("Error creating session", e.message); + // clear cookies and reset opencgaSession + this.opencgaClient.logout(); + this._createOpencgaSessionFromConfig(); }) .finally(() => { this.isCreatingSession = false; From 51399ecec4a0434f7077c7addee04bb567a64f64 Mon Sep 17 00:00:00 2001 From: Josemi Date: Mon, 9 Dec 2024 13:43:30 +0100 Subject: [PATCH 2/3] clients: Force logout to clear also sso cookie #TASK-7256 --- src/core/clients/opencga/opencga-client.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/clients/opencga/opencga-client.js b/src/core/clients/opencga/opencga-client.js index bb7cd4c83..01d3646b4 100644 --- a/src/core/clients/opencga/opencga-client.js +++ b/src/core/clients/opencga/opencga-client.js @@ -345,6 +345,11 @@ export class OpenCGAClient { Cookies.expire(this._config.cookies.prefix + "_userId"); // eslint-disable-next-line no-undef Cookies.expire(this._config.cookies.prefix + "_sid"); + // Remove sso token only if sso mode is enabled + if (this._config?.sso?.active && this._config?.sso?.cookie) { + // eslint-disable-next-line no-undef + Cookies.expire(this._config.sso.cookie); + } } } From 1b9a326feaead5976dc705d16ef4dba0d3e6e4ce Mon Sep 17 00:00:00 2001 From: Josemi Date: Mon, 9 Dec 2024 13:44:08 +0100 Subject: [PATCH 3/3] iva-app: Removing sso cookie is now handled by opencga client #TASK-7256 --- src/sites/iva/iva-app.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/sites/iva/iva-app.js b/src/sites/iva/iva-app.js index a72b8a6a9..5d3f96c54 100644 --- a/src/sites/iva/iva-app.js +++ b/src/sites/iva/iva-app.js @@ -692,9 +692,6 @@ class IvaApp extends LitElement { // 3. Check if sso is active and logged user is not local // In this case, we will redirect to 'meta/sso/logout' endpoint if (this.opencgaClient?._config?.sso?.active && !isLocalUser) { - // eslint-disable-next-line no-undef - Cookies.expire(this.opencgaClient._config.sso.cookie); - const config = this.opencgaClient._config; const ivaUrl = window.location; window.location = `${config.host}/webservices/rest/${config.version}/meta/sso/logout?url=${ivaUrl}`;