diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-05-12 17:45:08 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-05-12 17:45:08 +0200 |
commit | ee8a7b53daaa5459f960806d6a17f8b4c2138059 (patch) | |
tree | 47b67c4bfdd563e62a905ae9c27aab81f377b91b /lib/private | |
parent | 1d18fd4e6da16895ac1ef879c7b416f555bb385d (diff) | |
parent | 3cd32dcb7c368e48a5a7bf510864c8ddd9be85e8 (diff) | |
download | nextcloud-server-ee8a7b53daaa5459f960806d6a17f8b4c2138059.tar.gz nextcloud-server-ee8a7b53daaa5459f960806d6a17f8b4c2138059.zip |
Merge pull request #8553 from owncloud/fix-8549-master
adding X-Robots-Tag to all responses of ownCloud + move addSecurityHeade...
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/response.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/private/response.php b/lib/private/response.php index 1aa5e629b8b..4905c0a787b 100644 --- a/lib/private/response.php +++ b/lib/private/response.php @@ -186,4 +186,36 @@ class OC_Response { self::setStatus(self::STATUS_NOT_FOUND); } } + + /* + * This function adds some security related headers to all requests served via base.php + * The implementation of this function has to happen here to ensure that all third-party + * components (e.g. SabreDAV) also benefit from this headers. + */ + public static function addSecurityHeaders() { + header('X-XSS-Protection: 1; mode=block'); // Enforce browser based XSS filters + header('X-Content-Type-Options: nosniff'); // Disable sniffing the content type for IE + + // iFrame Restriction Policy + $xFramePolicy = OC_Config::getValue('xframe_restriction', true); + if ($xFramePolicy) { + header('X-Frame-Options: Sameorigin'); // Disallow iFraming from other domains + } + + // Content Security Policy + // If you change the standard policy, please also change it in config.sample.php + $policy = OC_Config::getValue('custom_csp_policy', + 'default-src \'self\'; ' + . 'script-src \'self\' \'unsafe-eval\'; ' + . 'style-src \'self\' \'unsafe-inline\'; ' + . 'frame-src *; ' + . 'img-src *; ' + . 'font-src \'self\' data:; ' + . 'media-src *'); + header('Content-Security-Policy:' . $policy); + + // https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag + header('X-Robots-Tag: none'); + } + } |