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

FAQ bug: polymer fails CSP because of inline script tags not XHR. #301

Closed
johnjbarton opened this issue Oct 1, 2013 · 3 comments
Closed

Comments

@johnjbarton
Copy link

http://www.polymer-project.org/faq.html#csp

"This is because the HTML Imports polyfill uses XHR to do its magic. "

Same-origin policy and XHR: http://en.wikipedia.org/wiki/Same_origin_policy

CSP:https://developer.mozilla.org/en-US/docs/Security/CSP

Polymer fails CSP because (at least) it uses inline script tags to simulate module loading.

@sjmiles
Copy link
Contributor

sjmiles commented Oct 1, 2013

Only the debug version of polymer using inline script tags. Minified polymer (polymer.min.js) does not.

However, the HTML Imports polyfill can execute strings as JavaScript, which requires CSP sandboxing mode, which then disables XHR.

IIRC this is why the FAQ ultimately blames XHR, obviously the reality is more nuanced.

CSP can be satisfied without sandboxing using: (1) polymer.min.js, (2) 100% external JavaScript in elements.

Various Polymer elements use inline script tags, but if custom build your own elements, you can externalize the JS and avoid CSP.

As it's a bad idea to custom build all elements, the vulcanizer tool has been provided which can walk an application's dependency tree and produce concatenated, CSP-friendly source.

@sjmiles
Copy link
Contributor

sjmiles commented Oct 1, 2013

@ebidel

It's not a big deal, but ideally issues related to the documentation, faq, or home page should be made against the docs repository.

@ebidel
Copy link
Contributor

ebidel commented Oct 1, 2013

Fixed in Polymer/old-docs-site@bb7af18

@ebidel ebidel closed this as completed Oct 1, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants