-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
wip #1
Merged
wip #1
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
234b570
wip
91deaf9
revert pdf.worker.js
0d955a6
revert spacing change
eedbbf7
remove mozilla origins from whitelist.
9230981
Add staging and production viewer.js hosts.
5bbc546
Whitelist new attachments.dobt.dev subdomain.
029befe
Strip X-Frame-Options headers so that pdf can be rendered on a differ…
8f4779c
Send both XFO and CSP headers. Adds documentation too.
c59cb39
Whitelist domains the viewer will load files from.
3bea139
Update readme
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module PdfjsViewer | ||
class PdfApplicationController < ActionController::Base | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,38 @@ | ||
module PdfjsViewer | ||
class ViewerController < ApplicationController | ||
class ViewerController < PdfApplicationController | ||
layout false | ||
|
||
after_action :allow_embedding_in_iframe | ||
|
||
def full | ||
end | ||
|
||
def minimal | ||
end | ||
|
||
def reduced | ||
end | ||
|
||
private | ||
|
||
def allow_embedding_in_iframe | ||
# By default Rails sends the 'X-Frame-Options: SAMEORIGIN' header with responses. | ||
# This means that the response can only be rendered on an iframe whose parent has the same | ||
# origin as the response. | ||
|
||
# We are mounting this engine under a different subdomain from the main app, so the default Rails | ||
# XFO header breaks the feature. The purpose of this method is to allow pdfs to be embedded | ||
# by a specific domain (the screendoor domain). | ||
|
||
# There are two ways to control which domains are allowed to embed documents as iframes: | ||
# X-Frame-Options and Content-Security-Policy. XFO is considered obsolete with CSP. | ||
# XFO offers the ALLOW-FROM directive, which only allows you to specify one domain. Chrome | ||
# actively ignores this directive! CSP offers frame-ancestors which lets us provide a list | ||
# of domains. Only modern browsers support CSP (read: not IE/edge) | ||
# So we will send both. | ||
|
||
response.headers['X-Frame-Options'] = "ALLOW-FROM #{::Rails.configuration.x.host_with_protocol}" | ||
response.headers['Content-Security-Policy'] = "frame-ancestors #{::Rails.configuration.x.host_with_protocol}" | ||
end | ||
end | ||
end |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be pretty cool to just include this in production and the previous line in dev/staging, but definitely not necessary. I'm not sure how we'd even do that well if this is sitting in a separate gem, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to avoid dealing with injecting configuration into this file. The less we change this file, the easier it will be to pull in upstream updates from the pdf.js repo.