.. include:: ../../Includes.txt How to migrate javascript ========================= There are four different cases to check before you activate the extension. .. attention:: Before you activate the extension check you site and set the **script-src** directive correctly The goal is, that your site is able to run without the unsafe-inline and/or unsafe-eval options for script-src. 1) Your own JavaScript files: ----------------------------- These urls considered as "self" running urls. You don't need to do anything, each scripts referenced under the same domain are enabled. However, if you have a subdomain which is not the same as the domain of the page, you should enable it explicit: plugin.tx_csp.settings.additionalSources.script.1 = subdomain.your_domain.com (You can add multiple domains at once or with different indexes) 2) External JavaScript files ---------------------------- Do you reference external files like jQuery or Google Analytics? Then you need to enable these domain for the script-src directive. Sometimes -like in this case- you need to think about what these scripts are do. Like tracking codes with small images. You can use the **additionalSources** as by 1) but for these there is an other way to group the settings pro usecase. Some popular sources are added by default however you need to enable them if you are using them. - YouTube (enabled by default) - Vimeo (enabled by default) - GoogleAnalytics (disabled) - jQuery (disabled) - Google fonts (disabled) - Google maps (disabled) For the later four cases you can enable what you need with the following TypoScript constants: plugin.tx_csp.settings.presets.googleAnalytics.enabled = 1 plugin.tx_csp.settings.presets.jQuery.enabled = 1 plugin.tx_csp.settings.presets.googleFonts.enabled = 1 plugin.tx_csp.settings.presets.googleMaps.enabled = 1 *You can define your own presets. Please read the* **Typoscript / Settings** *section.* 3) Inline scripts ----------------- If you have declarations in your markup you need to change the generation of them. 3a) If you have a classic TypoScript like this: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :: page.headerData.10 = TEXT page.headerData.10 ( ) You can make two easy change to make this declaration valid for your content security policy header. - Change the TEXT to a new content object (introduced by this extension): SCRIPT - Delete the in the string, it should contain only your JavaScript code only. 4) Action declaration (f.i. onclick) or "javascript:" links. ------------------------------------------------------------ These are also blocked by the content security policy and currently it is hard to enable them one by one. It is also recommended not to write code like these but use javascript or jQuery and register eventListeners in your javascript files instead. .. attention:: If you can't resolve each of the above points then you can't use a strict CSP header without loosing functionality of your website. In this case you can still use CSP if you add: **plugin.tx_csp.settings.additionalSources.script.1 = unsafe-inline** to your TypoScript setup. However with this option the header does not really useful since a XSS attack is still possible.