From f1d3a5cc750a1b60865e71e66140cb7ed404ec28 Mon Sep 17 00:00:00 2001 From: Bill Riehl Date: Thu, 17 Aug 2023 15:55:56 -0400 Subject: [PATCH 01/13] update to use anonymous user ids --- src/client/js/gtagSupport.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/js/gtagSupport.js b/src/client/js/gtagSupport.js index e55c3992..19fd97c2 100644 --- a/src/client/js/gtagSupport.js +++ b/src/client/js/gtagSupport.js @@ -319,7 +319,7 @@ function main() { const auth = await getAuth(); if (auth) { - pageView.user_id = auth.user; + pageView.user_id = auth.anonid; } pushGTag('event', 'page_view', pageView); From d4e1c8abb2a879663fec506ee6e7bc2a05596348 Mon Sep 17 00:00:00 2001 From: Bill Riehl Date: Thu, 17 Aug 2023 16:02:50 -0400 Subject: [PATCH 02/13] update release notes next --- release-notes/RELEASE_NOTES_NEXT.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release-notes/RELEASE_NOTES_NEXT.md b/release-notes/RELEASE_NOTES_NEXT.md index 8f693dbb..56194397 100644 --- a/release-notes/RELEASE_NOTES_NEXT.md +++ b/release-notes/RELEASE_NOTES_NEXT.md @@ -1,6 +1,6 @@ # KBase kbase-ui NEXT Release Notes -none +The main change here is to update the call to Google Analytics to anonymize the user id sent. ## CHANGES @@ -18,7 +18,7 @@ none ### IMPROVEMENTS -none +- UIP-35: sends an anonymous id to Google Analytics instead of a user name ### FIXES From d9c4d08e540ab50afd77b69b631bd65deeff490f Mon Sep 17 00:00:00 2001 From: David Lyon Date: Mon, 19 Sep 2022 10:30:15 -0700 Subject: [PATCH 03/13] initial europa commit From 2161f1774c392e11aa31d28318290741cf349697 Mon Sep 17 00:00:00 2001 From: David Lyon Date: Mon, 26 Sep 2022 09:24:00 -0700 Subject: [PATCH 04/13] temp: add console log to messenger.send --- src/client/modules/app/services/route.ts | 5 +++++ src/client/modules/lib/messenger.ts | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/client/modules/app/services/route.ts b/src/client/modules/app/services/route.ts index 4b5f7ae9..06aa9730 100644 --- a/src/client/modules/app/services/route.ts +++ b/src/client/modules/app/services/route.ts @@ -71,6 +71,11 @@ export class RouteService extends Service { this.currentRouteHandler = null; this.receivers = []; this.eventListeners = []; + this.runtime.receive('app', 'route-component', (routed) => { + if(window.parent){ + window.parent.postMessage(routed,'https://ci-europa.kbase.us') + } + }); } doRoute() { diff --git a/src/client/modules/lib/messenger.ts b/src/client/modules/lib/messenger.ts index b6b4c1c4..adfe5903 100644 --- a/src/client/modules/lib/messenger.ts +++ b/src/client/modules/lib/messenger.ts @@ -131,6 +131,9 @@ export class Messenger { const channelName = publishDef.channel; const message = publishDef.message; + const console_workaround = console; + console_workaround.log("Messenger.send",publishDef) + const channel = this.channels.get(channelName); if (!channel) { return; From bba92f4a7c0200999cbe78d582ed9a5e4a692576 Mon Sep 17 00:00:00 2001 From: David Lyon Date: Wed, 28 Sep 2022 10:02:32 -0700 Subject: [PATCH 05/13] add europa messaging listener/postMessage --- src/client/modules/app/services/europa.ts | 20 ++++++++++++++++++++ src/client/modules/app/services/route.ts | 7 ++----- 2 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 src/client/modules/app/services/europa.ts diff --git a/src/client/modules/app/services/europa.ts b/src/client/modules/app/services/europa.ts new file mode 100644 index 00000000..8147184a --- /dev/null +++ b/src/client/modules/app/services/europa.ts @@ -0,0 +1,20 @@ +import { Runtime } from '../../lib/types'; + +export const initEuropaRoutes = (runtime: Runtime) => { + runtime.receive('app', 'route-component', (payload) => { + if (window.parent) { + window.parent.postMessage( + { source: 'kbase-ui.app.route-component', payload }, + 'https://ci-europa.kbase.us' + ); + } + }); + runtime.receive('ui', 'setTitle', (payload) => { + if (window.parent) { + window.parent.postMessage( + { source: 'kbase-ui.ui.setTitle', payload }, + 'https://ci-europa.kbase.us' + ); + } + }); +}; diff --git a/src/client/modules/app/services/route.ts b/src/client/modules/app/services/route.ts index 06aa9730..4c691c8e 100644 --- a/src/client/modules/app/services/route.ts +++ b/src/client/modules/app/services/route.ts @@ -11,6 +11,7 @@ import { RoutingLocation, } from "./router"; import { Receiver, Runtime, Service, SimpleMap } from "../../lib/types"; +import { initEuropaRoutes } from "./europa"; type RouteHandler = RoutedRequest; @@ -71,11 +72,7 @@ export class RouteService extends Service { this.currentRouteHandler = null; this.receivers = []; this.eventListeners = []; - this.runtime.receive('app', 'route-component', (routed) => { - if(window.parent){ - window.parent.postMessage(routed,'https://ci-europa.kbase.us') - } - }); + initEuropaRoutes(this.runtime); } doRoute() { From a227d660e2fc23070b9b33bcca10008a8ee87dfd Mon Sep 17 00:00:00 2001 From: Dakota Blair Date: Tue, 27 Sep 2022 16:49:43 -0400 Subject: [PATCH 06/13] Hide kbase-ui chrome. --- .../modules/reactComponents/MainWindow/style.css | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/client/modules/reactComponents/MainWindow/style.css b/src/client/modules/reactComponents/MainWindow/style.css index b6b9cf6a..1a1aa7eb 100644 --- a/src/client/modules/reactComponents/MainWindow/style.css +++ b/src/client/modules/reactComponents/MainWindow/style.css @@ -28,6 +28,10 @@ flex: 0 0 75px; } +.MainWindow .-header, .MainWindow .-nav { + display: none; +} + .MainWindow .-body > .-content { flex: 1 1 0px; display: flex; @@ -136,7 +140,7 @@ /* Navbar */ -/* +/* * Main Navigation Bar */ @@ -245,8 +249,8 @@ /* Body */ -/* Tweak navbar, sidebar and main content areas to fit together -The navbar and sidebar are fixed -- so out of flow and need absolute positioning +/* Tweak navbar, sidebar and main content areas to fit together +The navbar and sidebar are fixed -- so out of flow and need absolute positioning Although the sidebar is partially positioned with part of the navbar. The content area is normal flow and just needs to have a matching top margin. */ From 754de9f75e3fb398b230047b4cfaef93b8883301 Mon Sep 17 00:00:00 2001 From: David Lyon Date: Thu, 29 Sep 2022 11:39:14 -0700 Subject: [PATCH 07/13] add (hacky) listener for europa navigate events --- src/client/modules/app/services/europa.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/client/modules/app/services/europa.ts b/src/client/modules/app/services/europa.ts index 8147184a..485d2b2d 100644 --- a/src/client/modules/app/services/europa.ts +++ b/src/client/modules/app/services/europa.ts @@ -1,11 +1,14 @@ import { Runtime } from '../../lib/types'; +// TODO: DO NOT MERGE WITHOUT SAFER TARGET ORIGIN +const europaTargetOrigin = '*'; // 'https://ci-europa.kbase.us' + export const initEuropaRoutes = (runtime: Runtime) => { runtime.receive('app', 'route-component', (payload) => { if (window.parent) { window.parent.postMessage( { source: 'kbase-ui.app.route-component', payload }, - 'https://ci-europa.kbase.us' + europaTargetOrigin ); } }); @@ -13,8 +16,17 @@ export const initEuropaRoutes = (runtime: Runtime) => { if (window.parent) { window.parent.postMessage( { source: 'kbase-ui.ui.setTitle', payload }, - 'https://ci-europa.kbase.us' + europaTargetOrigin ); } }); + window.addEventListener('message', (message) => { + if (message.source !== window.parent) return; + if ( + message?.data?.source && + message?.data?.source == 'europa.navigate' + ) { + runtime.send('app', 'navigate', message.data.payload); + } + }); }; From 04ba6853cc9ddb2345607ddefcfa1161b274b570 Mon Sep 17 00:00:00 2001 From: David Lyon Date: Thu, 6 Oct 2022 10:55:35 -0700 Subject: [PATCH 08/13] set target to _top on AutoPostForm, rename europa init func --- src/client/modules/app/services/europa.ts | 2 +- src/client/modules/app/services/route.ts | 4 ++-- src/client/modules/pluginSupport/AutoPostForm.js | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/client/modules/app/services/europa.ts b/src/client/modules/app/services/europa.ts index 485d2b2d..bec58c33 100644 --- a/src/client/modules/app/services/europa.ts +++ b/src/client/modules/app/services/europa.ts @@ -3,7 +3,7 @@ import { Runtime } from '../../lib/types'; // TODO: DO NOT MERGE WITHOUT SAFER TARGET ORIGIN const europaTargetOrigin = '*'; // 'https://ci-europa.kbase.us' -export const initEuropaRoutes = (runtime: Runtime) => { +export const initEuropa = (runtime: Runtime) => { runtime.receive('app', 'route-component', (payload) => { if (window.parent) { window.parent.postMessage( diff --git a/src/client/modules/app/services/route.ts b/src/client/modules/app/services/route.ts index 4c691c8e..ab6bc83c 100644 --- a/src/client/modules/app/services/route.ts +++ b/src/client/modules/app/services/route.ts @@ -11,7 +11,7 @@ import { RoutingLocation, } from "./router"; import { Receiver, Runtime, Service, SimpleMap } from "../../lib/types"; -import { initEuropaRoutes } from "./europa"; +import { initEuropa } from "./europa"; type RouteHandler = RoutedRequest; @@ -72,7 +72,7 @@ export class RouteService extends Service { this.currentRouteHandler = null; this.receivers = []; this.eventListeners = []; - initEuropaRoutes(this.runtime); + initEuropa(this.runtime); } doRoute() { diff --git a/src/client/modules/pluginSupport/AutoPostForm.js b/src/client/modules/pluginSupport/AutoPostForm.js index 694c3dad..316522f4 100644 --- a/src/client/modules/pluginSupport/AutoPostForm.js +++ b/src/client/modules/pluginSupport/AutoPostForm.js @@ -41,6 +41,7 @@ define([ return html`
Date: Thu, 6 Oct 2022 11:06:57 -0700 Subject: [PATCH 09/13] TEMP: add hardcoded domain to session cookie setter --- src/client/modules/lib/kb_lib/Auth2Session.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/client/modules/lib/kb_lib/Auth2Session.ts b/src/client/modules/lib/kb_lib/Auth2Session.ts index c0e1a2f2..b7899d3a 100644 --- a/src/client/modules/lib/kb_lib/Auth2Session.ts +++ b/src/client/modules/lib/kb_lib/Auth2Session.ts @@ -649,6 +649,7 @@ export class Auth2Session { setSessionCookie(token: string, expiration: number) { const sessionCookie = new Cookie(this.cookieName, token) .setPath('/') + .setDomain('ci-europa.kbase.us') .setSecure(true); sessionCookie.setExpires(new Date(expiration).toUTCString()); From 47709ac822405ddc97d334dc58ca4245e1b18fa4 Mon Sep 17 00:00:00 2001 From: David Lyon Date: Thu, 6 Oct 2022 12:43:52 -0700 Subject: [PATCH 10/13] add europa login message, undo previous TEMP commit --- src/client/modules/app/services/europa.ts | 13 +++++++++++++ src/client/modules/lib/kb_lib/Auth2Session.ts | 1 - 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/client/modules/app/services/europa.ts b/src/client/modules/app/services/europa.ts index bec58c33..c9ce7dee 100644 --- a/src/client/modules/app/services/europa.ts +++ b/src/client/modules/app/services/europa.ts @@ -20,6 +20,19 @@ export const initEuropa = (runtime: Runtime) => { ); } }); + runtime.receive('session', 'loggedin', () => { + if (window.parent) { + window.parent.postMessage( + { + source: 'kbase-ui.session.loggedin', + payload: { + token: runtime.service('session').getAuthToken(), + }, + }, + europaTargetOrigin + ); + } + }); window.addEventListener('message', (message) => { if (message.source !== window.parent) return; if ( diff --git a/src/client/modules/lib/kb_lib/Auth2Session.ts b/src/client/modules/lib/kb_lib/Auth2Session.ts index b7899d3a..c0e1a2f2 100644 --- a/src/client/modules/lib/kb_lib/Auth2Session.ts +++ b/src/client/modules/lib/kb_lib/Auth2Session.ts @@ -649,7 +649,6 @@ export class Auth2Session { setSessionCookie(token: string, expiration: number) { const sessionCookie = new Cookie(this.cookieName, token) .setPath('/') - .setDomain('ci-europa.kbase.us') .setSecure(true); sessionCookie.setExpires(new Date(expiration).toUTCString()); From 9e19883b7677a661ae8d7e20a7d3bb2a68338a21 Mon Sep 17 00:00:00 2001 From: David Lyon <5115845+dauglyon@users.noreply.github.com> Date: Wed, 8 Mar 2023 11:06:03 -0800 Subject: [PATCH 11/13] Update Auth2Session.ts --- src/client/modules/lib/kb_lib/Auth2Session.ts | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/client/modules/lib/kb_lib/Auth2Session.ts b/src/client/modules/lib/kb_lib/Auth2Session.ts index c0e1a2f2..f9d613a5 100644 --- a/src/client/modules/lib/kb_lib/Auth2Session.ts +++ b/src/client/modules/lib/kb_lib/Auth2Session.ts @@ -674,19 +674,6 @@ export class Auth2Session { new Cookie(this.cookieName, '').setPath('/') ); - // Also remove the domain level cookie in case it was in advertently - // created. This can be a cause for a corrupt token, since the old auth - // system tokens are invalid, and it could create domain level cookies. - // New auth code does not (other than the backup cookie.) - const domainParts = window.location.hostname.split('.'); - let domain; - for (let len = 2; len <= domainParts.length; len += 1) { - domain = domainParts.slice(-len).join('.'); - this.cookieManager.removeItem( - new Cookie(this.cookieName, '').setPath('/').setDomain(domain) - ); - } - if (this.extraCookies) { this.extraCookies.forEach((cookieConfig) => { this.cookieManager.removeItem( From 680ea0a3143506159a623d935c91c541780f472a Mon Sep 17 00:00:00 2001 From: David Lyon Date: Tue, 6 Feb 2024 12:26:06 -0800 Subject: [PATCH 12/13] Explicitly use host domain for auth cookie get/set/delete --- src/client/modules/lib/kb_lib/Auth2Session.ts | 15 ++++++++++++--- src/client/modules/lib/kb_lib/Cookie.ts | 7 +++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/client/modules/lib/kb_lib/Auth2Session.ts b/src/client/modules/lib/kb_lib/Auth2Session.ts index f9d613a5..a616e9c8 100644 --- a/src/client/modules/lib/kb_lib/Auth2Session.ts +++ b/src/client/modules/lib/kb_lib/Auth2Session.ts @@ -431,7 +431,10 @@ export class Auth2Session { } getAuthCookie(): string | null { - let cookies = this.cookieManager.getItems(this.cookieName); + let cookies = this.cookieManager.getItems( + this.cookieName, + document.location.hostname + ); // Expected case, just a single session cookie. if (cookies.length === 1) { @@ -451,7 +454,10 @@ export class Auth2Session { if (cookies.length === 2) { this.removeSessionCookie(); } - cookies = this.cookieManager.getItems(this.cookieName); + cookies = this.cookieManager.getItems( + this.cookieName, + document.location.hostname + ); if (cookies.length > 0) { throw new Error( 'Duplicate session cookie detected and cannot remove it. Please delete your browser cookies for this site.' @@ -649,6 +655,7 @@ export class Auth2Session { setSessionCookie(token: string, expiration: number) { const sessionCookie = new Cookie(this.cookieName, token) .setPath('/') + .setDomain(document.location.hostname) .setSecure(true); sessionCookie.setExpires(new Date(expiration).toUTCString()); @@ -671,7 +678,9 @@ export class Auth2Session { removeSessionCookie(): void { // Remove host-based cookie. this.cookieManager.removeItem( - new Cookie(this.cookieName, '').setPath('/') + new Cookie(this.cookieName, '') + .setPath('/') + .setDomain(document.location.hostname) ); if (this.extraCookies) { diff --git a/src/client/modules/lib/kb_lib/Cookie.ts b/src/client/modules/lib/kb_lib/Cookie.ts index fb38cd50..605eb81c 100644 --- a/src/client/modules/lib/kb_lib/Cookie.ts +++ b/src/client/modules/lib/kb_lib/Cookie.ts @@ -216,8 +216,11 @@ export class CookieManager { return cookie[0].value; } - getItems(key: string): Array { - const cookie = this.findCookies(key); + getItems(key: string, domain?: string): Array { + let cookie = this.findCookies(key); + if (domain) { + cookie = cookie.filter((item) => item.domain === domain); + } if (cookie.length === 0) { return []; } From 3b872bd05442e4ebb2933262a87bbe4a49213be7 Mon Sep 17 00:00:00 2001 From: David Lyon Date: Tue, 6 Feb 2024 13:53:25 -0800 Subject: [PATCH 13/13] Revert "Explicitly use host domain for auth cookie get/set/delete" This reverts commit 680ea0a3143506159a623d935c91c541780f472a. --- src/client/modules/lib/kb_lib/Auth2Session.ts | 15 +++------------ src/client/modules/lib/kb_lib/Cookie.ts | 7 ++----- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/src/client/modules/lib/kb_lib/Auth2Session.ts b/src/client/modules/lib/kb_lib/Auth2Session.ts index a616e9c8..f9d613a5 100644 --- a/src/client/modules/lib/kb_lib/Auth2Session.ts +++ b/src/client/modules/lib/kb_lib/Auth2Session.ts @@ -431,10 +431,7 @@ export class Auth2Session { } getAuthCookie(): string | null { - let cookies = this.cookieManager.getItems( - this.cookieName, - document.location.hostname - ); + let cookies = this.cookieManager.getItems(this.cookieName); // Expected case, just a single session cookie. if (cookies.length === 1) { @@ -454,10 +451,7 @@ export class Auth2Session { if (cookies.length === 2) { this.removeSessionCookie(); } - cookies = this.cookieManager.getItems( - this.cookieName, - document.location.hostname - ); + cookies = this.cookieManager.getItems(this.cookieName); if (cookies.length > 0) { throw new Error( 'Duplicate session cookie detected and cannot remove it. Please delete your browser cookies for this site.' @@ -655,7 +649,6 @@ export class Auth2Session { setSessionCookie(token: string, expiration: number) { const sessionCookie = new Cookie(this.cookieName, token) .setPath('/') - .setDomain(document.location.hostname) .setSecure(true); sessionCookie.setExpires(new Date(expiration).toUTCString()); @@ -678,9 +671,7 @@ export class Auth2Session { removeSessionCookie(): void { // Remove host-based cookie. this.cookieManager.removeItem( - new Cookie(this.cookieName, '') - .setPath('/') - .setDomain(document.location.hostname) + new Cookie(this.cookieName, '').setPath('/') ); if (this.extraCookies) { diff --git a/src/client/modules/lib/kb_lib/Cookie.ts b/src/client/modules/lib/kb_lib/Cookie.ts index 605eb81c..fb38cd50 100644 --- a/src/client/modules/lib/kb_lib/Cookie.ts +++ b/src/client/modules/lib/kb_lib/Cookie.ts @@ -216,11 +216,8 @@ export class CookieManager { return cookie[0].value; } - getItems(key: string, domain?: string): Array { - let cookie = this.findCookies(key); - if (domain) { - cookie = cookie.filter((item) => item.domain === domain); - } + getItems(key: string): Array { + const cookie = this.findCookies(key); if (cookie.length === 0) { return []; }