Skip to content

Commit 260792c

Browse files
committed
feat: disable cookie access under restricted sandboxes
When dash is embedded into an iframe with a sandbox attribute that only has allow-scripts, cookie access is disabled and dash fails to load. As such, we need to restrict our cookie usage by disabling functionality. This patch removes the disabled functionality in a graceful manner, allowing dash to load in very restricted iframes.
1 parent 735480b commit 260792c

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

Diff for: dash-renderer/src/AccessDenied.react.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@ function AccessDenied(props) {
2828
<a
2929
style={styles.base.a}
3030
onClick={() => {
31-
document.cookie =
32-
`${constants.OAUTH_COOKIE_NAME}=; ` +
33-
'expires=Thu, 01 Jan 1970 00:00:01 GMT;';
31+
/* eslint no-empty: ["error", { "allowEmptyCatch": true }] */
32+
try {
33+
document.cookie =
34+
`${constants.OAUTH_COOKIE_NAME}=; ` +
35+
'expires=Thu, 01 Jan 1970 00:00:01 GMT;';
36+
} catch (e) {}
3437
window.location.reload(true);
3538
}}
3639
>

Diff for: dash-renderer/src/actions/index.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,13 @@ export function hydrateInitialOutputs() {
5555
}
5656

5757
export function getCSRFHeader() {
58-
return {
59-
'X-CSRFToken': cookie.parse(document.cookie)._csrf_token,
60-
};
58+
try {
59+
return {
60+
'X-CSRFToken': cookie.parse(document.cookie)._csrf_token,
61+
};
62+
} catch (e) {
63+
return {};
64+
}
6165
}
6266

6367
function triggerDefaultState(dispatch, getState) {

0 commit comments

Comments
 (0)