-
Notifications
You must be signed in to change notification settings - Fork 10k
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
+32
−0
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yurydelendik
changed the title
Allow foriegn origin URLs only of hosted viewers.
Allow foriegn origin URLs only for hosted viewers.
Jan 22, 2016
yurydelendik
force-pushed
the
hosted-viewer
branch
from
January 22, 2016 17:54
3ec39ea
to
7c89bdc
Compare
brendandahl
added a commit
that referenced
this pull request
Jan 22, 2016
Allow foriegn origin URLs only for hosted viewers.
This was referenced Apr 4, 2016
vlymar
pushed a commit
to dobtco/pdfjs_viewer-rails
that referenced
this pull request
Mar 19, 2018
- 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.