Skip to content

Commit eccc669

Browse files
josegonzalezJHSaunders
authored andcommitted
feat: disable cookie/localstorage access under restricted sandboxes (plotly#729)
When dash is embedded into an iframe with a sandbox attribute that only has allow-scripts, cookie/localstorage access is disabled and dash-core-components fails to load. As such, we need to restrict our cookie/localstorage usage by disabling functionality. This patch moves the disabled functionality to a place where it doesn't get autoloaded regardless of usage, allowing dash-core-components to load in very restricted iframes.
1 parent 0e896d8 commit eccc669

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [Unreleased]
6+
7+
### Changed
8+
- [#729](https://github.com/plotly/dash-core-components/pull/729) Handle case where dcc fails to load when used inside an iframe with a sandbox attribute that only has allow-scripts
9+
510
## [1.7.1] - 2020-01-15 (JS-only)
611
### Fixed
712
- [#734](https://github.com/plotly/dash-core-components/pull/734) Fix JS-facing release bug where `Plotly.js` was listed in `devDependencies` instead of `dependencies`

src/components/Store.react.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,6 @@ class WebStore {
112112
}
113113
}
114114

115-
const _localStore = new WebStore(window.localStorage);
116-
const _sessionStore = new WebStore(window.sessionStorage);
117-
118115
/**
119116
* Easily keep data on the client side with this component.
120117
* The data is not inserted in the DOM.
@@ -126,9 +123,9 @@ export default class Store extends React.Component {
126123
super(props);
127124

128125
if (props.storage_type === 'local') {
129-
this._backstore = _localStore;
126+
this._backstore = new WebStore(window.localStorage);
130127
} else if (props.storage_type === 'session') {
131-
this._backstore = _sessionStore;
128+
this._backstore = new WebStore(window.sessionStorage);
132129
} else if (props.storage_type === 'memory') {
133130
this._backstore = new MemStore();
134131
}

0 commit comments

Comments
 (0)