suddjian commented on code in PR #20251:
URL: https://github.com/apache/superset/pull/20251#discussion_r889244838
##########
superset-frontend/src/embedded/index.tsx:
##########
@@ -154,15 +157,39 @@ function setupGuestClient(guestToken: string) {
}
function validateMessageEvent(event: MessageEvent) {
- // if (!ALLOW_ORIGINS.includes(event.origin)) {
- // throw new Error('Message origin is not in the allowed list');
- // }
-
if (typeof event.data !== 'object' || event.data.type !== MESSAGE_TYPE) {
throw new Error(`Message type does not match type used for embedded
comms`);
}
}
+function validateAllowedDomains() {
+ const uuid = window.location.pathname.replace('/embedded/', '');
+ const getDashaboardConfig = makeApi<void, { result: EmbeddedDashboard }>({
+ method: 'GET',
+ endpoint: `/api/v1/embedded_dashboard/${uuid}`,
+ });
+ return getDashaboardConfig().then(
+ ({ result }) => {
+ const parentOrigin = new URL(document.referrer).origin;
+ if (
+ result.allowed_domains.length > 0 &&
+ !result.allowed_domains.includes(parentOrigin)
+ ) {
+ showFailureMessage(
+ `iframe parent ${parentOrigin} is not in the list of allowed
domains`,
+ );
+ }
+ },
+ err => {
Review Comment:
Looks like you copied this from the `getMe` call in the `start` function,
but that endpoint is specifically being used to check guest token validity.
This error handler is inappropriate outside that case.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]