Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow foriegn origin URLs only for hosted viewers. #6916

Merged
merged 1 commit into from Jan 22, 2016

Conversation

Projects
None yet
2 participants
@yurydelendik
Copy link
Contributor

yurydelendik commented Jan 22, 2016

Currently we provide demo viewer source code so web developers can extend and build custom viewers upon it. The "file" parameter is causing confusions among developers due to XHR restrictions such as CORS or passing binary data.

Also, most of the developers don’t want or forget to modify viewer to adapt it to their own use case. The primary use case the PDF.js team considered is hosting generic viewer to view files from different locations.

This patch locks down the "file" parameter to be used only for the files located at the same server by default. The main reason for it is to minimize unintended use of viewer host network resources to display somebody else’s documents (e.g. full viewer size might reach up to 2MB) and avoid content spoofing to avoid presenting false information on behalf of the host domain. The exceptions for now are viewers that are hosted at "file:///..." and "http://mozilla.github.io/" locations. If a host's use case matches ours, the validation function/parameters can be adjusted to change that.

@yurydelendik yurydelendik changed the title Allow foriegn origin URLs only of hosted viewers. Allow foriegn origin URLs only for hosted viewers. Jan 22, 2016

@yurydelendik yurydelendik force-pushed the yurydelendik:hosted-viewer branch from 3ec39ea to 7c89bdc Jan 22, 2016

brendandahl added a commit that referenced this pull request Jan 22, 2016

Merge pull request #6916 from yurydelendik/hosted-viewer
Allow foriegn origin URLs only for hosted viewers.

@brendandahl brendandahl merged commit 059e826 into mozilla:master Jan 22, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@yurydelendik yurydelendik deleted the yurydelendik:hosted-viewer branch Jan 28, 2016

@mikecousins mikecousins referenced this pull request Aug 1, 2017

Closed

CORS ? #24

@vlymar vlymar referenced this pull request Mar 14, 2018

Merged

wip #1

vlymar added a commit to dobtco/pdfjs_viewer-rails that referenced this pull request Mar 19, 2018

Implement a number of DOBT specific changes and fixes (#1)
- Replaces mozilla's domains with our own in the `HOSTED_VIEWER_ORIGINS` whitelist.
  - this whitelist allows us to make cross origin requests for files (i.e. to s3).
  - mozilla/pdf.js#6916 is a summary of why this whitelist exists
- Renames main engine controller from `PdfjsViewer::ApplicationController` to `PdfjsViewer::PdfApplicationController` to prevent namespace collisions with our main app's ApplicationController
- Allows the engine routes to be embedded as iframes only under our base url
  - implemented with a combination of `X-Frame-Options` and `Content-Security-Policy` headers
- Restricts the domains that files will be loaded from to a whitelist
- Viewer can only be loaded in an iframe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.