I have a store running fine with the latest version of Magento (currently 2.1.1), and I'm trying to improve security through Content Security Policy on Apache 2.4.7 (Ubuntu 14.04). I removed all <script>
tags from the content pages and created separated files.js.
On Apache's security, I have set the:
Header set Content-Security-Policy "default-src 'self'"
However, it's not working. It seems Magento itself added some <script>
tags. Example from the very first source lines:
<!doctype html >
<html lang="pt-BR">
<head>
<script>
var require = {
"baseUrl": "http://example.com/pub/static/frontend/Magento/luma/pt_BR"
};
</script>
So it seems that to have CSP configured, I'd have to enable unsafe-inline
which is not safe.
Header set Content-Security-Policy "default-src 'self' script-src 'self' 'unsafe-inline' 'unsafe-eval'".
Does anyone know how to have Magento correctly set with CSP? Thank you!