Allow foriegn origin URLs only for hosted viewers. #6916
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.
The text was updated successfully, but these errors were encountered:
- 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