.. include:: /Includes.rst.txt .. _configuration-csp: ======================= Content Security Policy ======================= The extension declares the Content Security Policy sources its editing surface needs, in :file:`Configuration/ContentSecurityPolicies.php`. TYPO3 collects that file automatically from every installed package — there is nothing to register, enable or copy. Everything it asks for is the site's **own origin**. The extension loads no script, no stylesheet, no font and no image from anywhere else, and it requests no source expression that weakens a policy. .. contents:: :local: :depth: 1 Whether the policy applies at all ================================= Frontend Content Security Policy is **switched off by default** in TYPO3 v13 and v14. On an installation that has not enabled it, this file is collected and has no effect, and the editing surface behaves as if it were not there. There are two independent ways a site turns it on, and neither is implied by the other. .. code-block:: php :caption: config/system/additional.php // Send the policy as an enforcing header: $GLOBALS['TYPO3_CONF_VARS']['SYS']['features']['security.frontend.enforceContentSecurityPolicy'] = true; // Or only observe it, and collect violation reports: $GLOBALS['TYPO3_CONF_VARS']['SYS']['features']['security.frontend.reportContentSecurityPolicy'] = true; .. code-block:: yaml :caption: config/sites//csp.yaml enforce: true The :file:`csp.yaml` route needs **no feature flag**. A site can therefore have the policy active while both flags are `false`, which is why "the feature is off" is not a safe assumption when debugging a blocked resource. What the extension declares =========================== Four directives, each granting :code:`'self'` and nothing else: .. list-table:: :header-rows: 1 * - Directive - Needed for * - :code:`script-src 'self'` - The editing module, an ES module resolved through the TYPO3 import map. No inline script is emitted by this extension. * - :code:`style-src 'self'` - The one :html:`` the plugin adds. The component's own styles never reach this directive — see below. * - :code:`connect-src 'self'` - The :code:`fetch()` calls to the editing endpoints, at relative URLs built on the server. * - :code:`img-src 'self'` - Stored profile images, served by the file abstraction layer from this origin. All four use the :php:`Extend` mutation mode, which inherits whatever the ancestor directive already permits before appending. What they cost on a default installation ======================================== Close to nothing, and this was measured rather than argued: the same page was rendered with the file and without it, and the emitted header differed by one directive. All four descend from :code:`default-src`. With the :code:`default-src 'self'` that TYPO3 itself declares for the frontend, each of them resolves to exactly :code:`'self'` — and TYPO3 then removes a directive whose source set is identical to its ancestor's. Three of the four disappear that way. The fourth, :code:`style-src`, survives only because the reporting token :code:`'report-sample'` is appended to declared directives and not to :code:`default-src`, so the two sets differ by a token that grants nothing. .. note:: What the declaration buys is the case where that stops being true. A site that **narrows** :code:`default-src` — to :code:`'none'`, or to a specific host — applies its own mutations after the ones packages declare. All four then stop being identical to their ancestor and survive into the header, and the editing surface keeps working instead of failing with console errors and no explanation. What is deliberately not requested ================================== Each of these was checked against the shipped assets. None is omitted by oversight, and none should be added without establishing that it is needed. .. list-table:: :header-rows: 1 * - Not requested - Why it is not needed * - :code:`style-src 'unsafe-inline'` - The component installs its styles through :js:`adoptedStyleSheets`, which produces no :html:`