Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c2d47ed
initial europa commit
dauglyon Sep 19, 2022
06524de
temp: add console log to messenger.send
dauglyon Sep 26, 2022
ce3f014
Hide kbase-ui chrome.
dakotablair Sep 27, 2022
3ad2655
add europa messaging listener/postMessage
dauglyon Sep 28, 2022
ae728ec
Merge branch 'europa' of github.com:kbase/kbase-ui into europa
dauglyon Sep 28, 2022
8cb590d
add (hacky) listener for europa navigate events
dauglyon Sep 29, 2022
8482c0f
set target to _top on AutoPostForm, rename europa init func
dauglyon Oct 6, 2022
e9965ab
TEMP: add hardcoded domain to session cookie setter
dauglyon Oct 6, 2022
9249040
add europa login message, undo previous TEMP commit
dauglyon Oct 6, 2022
fa0f22d
initial europa commit
dauglyon Sep 19, 2022
bbc0704
temp: add console log to messenger.send
dauglyon Sep 26, 2022
0bce81c
add europa messaging listener/postMessage
dauglyon Sep 28, 2022
ab38028
Hide kbase-ui chrome.
dakotablair Sep 27, 2022
73e6bec
add (hacky) listener for europa navigate events
dauglyon Sep 29, 2022
c027ec5
set target to _top on AutoPostForm, rename europa init func
dauglyon Oct 6, 2022
b311aa0
TEMP: add hardcoded domain to session cookie setter
dauglyon Oct 6, 2022
8a2957e
add europa login message, undo previous TEMP commit
dauglyon Oct 6, 2022
47d1c28
Update Auth2Session.ts
dauglyon Mar 8, 2023
0ac48d0
Merge branch 'europa' of github.com:kbase/kbase-ui into europa
dauglyon Sep 28, 2023
4bb9a48
More secure message targets, implement europa.identify receiver
dauglyon Sep 28, 2023
1fa926f
remove console.log
dauglyon Oct 2, 2023
58ab6ef
add loggedout postmessage event
dauglyon Oct 18, 2023
1f16ee8
fix postmessage target origin
dauglyon Oct 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions src/client/modules/app/services/europa.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { Runtime } from '../../lib/types';

// This line assumes kbase-ui is running on a direct subdomain on the Europa instance
// this subdomain relationship is _required_ for CORS security policy reasons
// i.e. legacy.ci-europa.kbase.us --> ci-europa.kbase.us
const europaTargetOrigin = window.location.origin.replace('legacy.', '');

// This variable is undefined by default but will be set if
// the iframe receives a 'europa.identify' message from a parent
// which specifies a parent domain which is not the one above.
// WHEN TRUTHY, token events will not propagate to the parent
// This enables development in localhost.
let insecureParent: string | undefined = undefined;

const getMessageDomain = () =>
insecureParent ? insecureParent : europaTargetOrigin;

export const initEuropa = (runtime: Runtime) => {
runtime.receive('app', 'route-component', (payload) => {
if (window.parent) {
window.parent.postMessage(
{ source: 'kbase-ui.app.route-component', payload },
getMessageDomain()
);
}
});
runtime.receive('ui', 'setTitle', (payload) => {
if (window.parent) {
window.parent.postMessage(
{ source: 'kbase-ui.ui.setTitle', payload },
getMessageDomain()
);
}
});
runtime.receive('session', 'loggedin', () => {
if (window.parent && !insecureParent) {
window.parent.postMessage(
{
source: 'kbase-ui.session.loggedin',
payload: {
token: runtime.service('session').getAuthToken(),
},
},
europaTargetOrigin
);
}
});
runtime.receive('session', 'loggedout', () => {
if (window.parent && !insecureParent) {
window.parent.postMessage(
{
source: 'kbase-ui.session.loggedout',
payload: undefined,
},
europaTargetOrigin
);
}
});
window.addEventListener('message', (message) => {
// only look at messages which come from the iframe parent
if (message.source !== window.parent || !message?.data?.source) return;
// Navigate events
if (message?.data?.source == 'europa.navigate') {
runtime.send('app', 'navigate', message.data.payload);
}
// Domain identify events
else if (message?.data?.source == 'europa.identify') {
if (message.data.payload !== europaTargetOrigin) {
// we could allow only specific domains here
// (i.e. localhost:3000) in the future
insecureParent = message.data.payload;
}
}
});
};
2 changes: 2 additions & 0 deletions src/client/modules/app/services/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
RoutingLocation,
} from "./router";
import { Receiver, Runtime, Service, SimpleMap } from "../../lib/types";
import { initEuropa } from "./europa";

type RouteHandler = RoutedRequest;

Expand Down Expand Up @@ -71,6 +72,7 @@ export class RouteService extends Service<RouteServiceConfig> {
this.currentRouteHandler = null;
this.receivers = [];
this.eventListeners = [];
initEuropa(this.runtime);
}

doRoute() {
Expand Down
13 changes: 0 additions & 13 deletions src/client/modules/lib/kb_lib/Auth2Session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions src/client/modules/pluginSupport/AutoPostForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ define([
return html`
<form method="post"
ref=${this.ref}
target="_top"
id=${formID}
action=${action}
style=${{display: 'hidden'}}
Expand Down
10 changes: 7 additions & 3 deletions src/client/modules/reactComponents/MainWindow/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
flex: 0 0 75px;
}

.MainWindow .-header, .MainWindow .-nav {
display: none;
}

.MainWindow .-body > .-content {
flex: 1 1 0px;
display: flex;
Expand Down Expand Up @@ -136,7 +140,7 @@

/* Navbar */

/*
/*
* Main Navigation Bar
*/

Expand Down Expand Up @@ -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.
*/
Expand Down