From bf0af61147cf55cfee8a08497384888b78c28a1d Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Mon, 27 Apr 2015 13:51:53 +0200 Subject: [PATCH] fix #876 --- developer_manual/app/controllers.rst | 53 ++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/developer_manual/app/controllers.rst b/developer_manual/app/controllers.rst index 76834fa5c..f62bacb27 100644 --- a/developer_manual/app/controllers.rst +++ b/developer_manual/app/controllers.rst @@ -526,6 +526,59 @@ If you want to use a custom, lazily rendered response simply implement the inter .. note:: Because this code is rendered after several usually built in helpers, you need to take care of errors and proper HTTP caching by yourself. +Modifying the Content Securicy Policy +------------------------------------- +.. versionadded:: 8.1 + +By default ownCloud disables all resources which are not served on the same domain, forbids cross domain requests and disables inline CSS and JavaScript by setting a `Content Security Policy `_. However if an app relies on thirdparty media or other features which are forbidden by the current policy the policy can be relaxed. + +.. note:: Double check your content and edge cases before you relax the policy! Also read the `documentation provided by MDN `_ + +To relax the policy pass an instance of the ContentSecurityPolicy class to your response. The methods on the class can be chained. + +The following methods turn off security features by passing in **true** as the **$isAllowed** parameter + +* **allowInlineScript** (bool $isAllowed) +* **allowInlineStyle** (bool $isAllowed) +* **allowEvalScript** (bool $isAllowed) + +The following methods whitelist domains by passing in a domain or \* for any domain: + +* **addAllowedScriptDomain** (string $domain) +* **addAllowedStyleDomain** (string $domain) +* **addAllowedFontDomain** (string $domain) +* **addAllowedImageDomain** (string $domain) +* **addAllowedConnectDomain** (string $domain) +* **addAllowedMediaDomain** (string $domain) +* **addAllowedObjectDomain** (string $domain) +* **addAllowedFrameDomain** (string $domain) +* **addAllowedChildSrcDomain** (string $domain) + +The following policy for instance allows images, audio and videos from other domains: + + +.. code-block:: php + + addAllowedImageDomain('*'); + ->addAllowedMediaDomain('*'); + $response->setContentSecurityPolicy($csp); + } + + } + + OCS --- .. versionadded:: 8.1