Hey I am working on a new project with a different CSP. We basically want to prevent the page from being framed but want to display PDFs loaded from the same origin on the page (which are basically framed) and any external content in an iframe on our page.
However, BrowserPolicy.framing.restrictToOrigin()
uses the ALLOW
option, which seems to be not really supported and we found no option to set the x-frame-options to SAMEORIGIN
.
Edit: Does this imply, that the browser policy package needs to be updated?
The documentation on this is also not very enlightening.
We tried to solve it via
import { BrowserPolicy } from 'meteor/browser-policy'
const host = Meteor.absoluteUrl()
// never render inside iframe
BrowserPolicy.framing.disallow()
// except when on own domain
BrowserPolicy.framing.restrictToOrigin(host)
// and any external content
BrowserPolicy.content.allowFrameOrigin('*')
This all “works” (framing by others blocked, display same-orign content in frame, display external content in frame) but I still get the warning
Invalid X-Frame-Options header was found when loading “http://localhost:3000/path/to.pdf”: “ALLOW-FROM http://localhost:3000/” is not a valid directive.
I am no CSP expert yet, maybe someone can help our here?