Skip to content

Commit

Permalink
simplified handshake
Browse files Browse the repository at this point in the history
  • Loading branch information
suddjian committed Dec 9, 2021
1 parent b5e7e26 commit 8b388e1
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions superset-frontend/src/embedded/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ try {
'This page is intended to be embedded by the Superset SDK, but there does not appear to be an SDK context present.';
}

// todo: check the referrer on the route serving this page and serve this list in bootstrap data
// if the page is embedded in an origin that hasn't
// been authorized by the curator, we forbid access entirely.
// todo: check the referrer on the route serving this page instead
const ALLOW_ORIGINS = ['http://127.0.0.1:9001', 'http://localhost:9001'];
const parentOrigin = new URL(document.referrer).origin;
if (!ALLOW_ORIGINS.includes(parentOrigin)) {
Expand All @@ -66,17 +68,12 @@ try {
ReactDOM.render(<EmbeddedPage />, appMountPoint);
}

console.info('[superset] posting handshake init');
window.parent.postMessage(
{ type: MESSAGE_TYPE, iframeName: window.name, handshake: 'init' },
parentOrigin,
);

function validateMessageEvent(event: MessageEvent<any>) {
function validateMessageEvent(event: MessageEvent) {
if (
event.data?.type === 'webpackClose' ||
event.data?.source === '@devtools-page'
) {
// sometimes devtools use the messaging api and we want to ignore those
throw new Error("Sir, this is a Wendy's");
}

Expand Down

0 comments on commit 8b388e1

Please sign in to comment.