Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

feat: disable cookie/localstorage access under restricted sandboxes #729

Merged
merged 1 commit into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Changed
- [#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

## [1.7.1] - 2020-01-15 (JS-only)
### Fixed
- [#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`
Expand Down
7 changes: 2 additions & 5 deletions src/components/Store.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,6 @@ class WebStore {
}
}

const _localStore = new WebStore(window.localStorage);
const _sessionStore = new WebStore(window.sessionStorage);

/**
* Easily keep data on the client side with this component.
* The data is not inserted in the DOM.
Expand All @@ -126,9 +123,9 @@ export default class Store extends React.Component {
super(props);

if (props.storage_type === 'local') {
this._backstore = _localStore;
this._backstore = new WebStore(window.localStorage);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message we get when trying to access localStorage is fairly informative / helpful:

Uncaught DOMException: Failed to read the 'localStorage' property from 'Window': The document is sandboxed and lacks the 'allow-same-origin' flag.

I don't think it needs to be improved to make sense to an app developer and as such can be exposed as-is.

} else if (props.storage_type === 'session') {
this._backstore = _sessionStore;
this._backstore = new WebStore(window.sessionStorage);
} else if (props.storage_type === 'memory') {
this._backstore = new MemStore();
}
Expand Down