nextcloud/core
Lukas Reschke 9e6634814e
Add support for CSP nonces
CSP nonces are a feature available with CSP v2. Basically instead of saying "JS resources from the same domain are ok to be served" we now say "Ressources from everywhere are allowed as long as they add a `nonce` attribute to the script tag with the right nonce.

At the moment the nonce is basically just a `<?php p(base64_encode($_['requesttoken'])) ?>`, we have to decode the requesttoken since `:` is not an allowed value in the nonce. So if somebody does on their own include JS files (instead of using the `addScript` public API, they now must also include that attribute.)

IE does currently not implement CSP v2, thus there is a whitelist included that delivers the new CSP v2 policy to newer browsers. Check http://caniuse.com/#feat=contentsecuritypolicy2 for the current browser support list. An alternative approach would be to just add `'unsafe-inline'` as well as `'unsafe-inline'` is ignored by CSPv2 when a nonce is set. But this would make this security feature unusable at all in IE. Not worth it at the moment IMO.

Implementing this offers the following advantages:

1. **Security:** As we host resources from the same domain by design we don't have to worry about 'self' anymore being in the whitelist
2. **Performance:** We can move oc.js again to inline JS. This makes the loading way quicker as we don't have to load on every load of a new web page a blocking dynamically non-cached JavaScript file.

If you want to toy with CSP see also https://csp-evaluator.withgoogle.com/

Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
2016-10-24 12:27:50 +02:00
..
Command Remove removed --dry-run command from occ help (#26352) 2016-10-21 16:38:37 +02:00
Controller Check the mimetype before reading the content and catch exception 2016-10-18 16:22:20 +02:00
Middleware prevent infinite redirect loops if the there is no 2fa provider to pass 2016-08-24 10:49:23 +02:00
ajax Check if the file isReadable() before sending a (cached) preview 2016-08-29 10:58:57 +02:00
css Merge pull request #1768 from nextcloud/more-filepicker 2016-10-20 14:46:57 +02:00
doc changed to nextcloud 2016-06-22 08:20:23 +02:00
fonts move font back from Light to Regular for body text on normal-res screens, fix #18954 2015-11-10 16:12:42 +01:00
img Use proper image 2016-10-21 21:42:40 +02:00
js Fix zxcvbn path in setup page (#26359) 2016-10-21 09:51:33 +02:00
l10n [tx-robot] updated from transifex 2016-10-18 00:06:51 +00:00
search Fix bold no results search text 2016-10-11 15:06:25 +02:00
skeleton ownCloud -> Nextcloud 2016-07-28 15:47:04 +02:00
templates Add support for CSP nonces 2016-10-24 12:27:50 +02:00
vendor fix .gitignore and include zxcvbn.js 2016-10-21 10:19:18 +02:00
Application.php Clean up core/Application a bit more 2016-10-05 16:36:49 +02:00
register_command.php Fixing ctor call 2016-10-19 00:15:01 +02:00
routes.php Remove unused endpoint 2016-09-30 10:21:08 +02:00
shipped.json add 2fa backup codes app 2016-09-05 08:51:13 +02:00
strings.php Update with robin 2016-07-21 18:13:58 +02:00