Skip to content
Snippets Groups Projects
Select Git revision
  • 55f656f1503c11b9ce2ca66171f899fa0b9d96e7
  • master default protected
  • hughns/rust-send-to-device
  • hughns/rtc-to-device-key-distribution
  • develop
  • rav/token_encryption_improvements
  • actions/playwright-image-updates
  • staging
  • hs/timezone-publish-to-profile
  • renovate/all-minor-patch
  • florianduros/pinned-messages/unpin-timeline-event
  • florianduros/pinned-messages/link-timeline-fix
  • renovate/major-testing-library-monorepo
  • langleyd/new_memberlist_ux
  • dbkr/token_incorrect
  • renovate/lock-file-maintenance
  • florianduros/fix/spotlight-click
  • backport-12906-to-staging
  • rav/remove_dead_package_json_stuff
  • florianduros/pinned-messages/timeline-separator
  • dbkr/threepid_medium_unsupported
  • v3.109.0
  • v3.109.0-rc.0
  • v3.108.0
  • v3.108.0-rc.0
  • v3.107.0
  • v3.106.0
  • v3.106.0-rc.1
  • v3.106.0-rc.0
  • v3.105.1
  • v3.105.0
  • v3.104.0
  • v3.104.0-rc.1
  • v3.104.0-rc.0
  • v3.103.0
  • v3.103.0-rc.1
  • v3.103.0-rc.0
  • v3.102.0
  • v3.102.0-rc.1
  • v3.102.0-rc.0
  • v3.101.0
41 results

reskindex.js

user avatar
Lukas Reschke authored
Allows to inject something into the default content policy. This is for
example useful when you're injecting Javascript code into a view belonging
to another controller and cannot modify its Content-Security-Policy itself.
Note that the adjustment is only applied to applications that use AppFramework
controllers.

To use this from your `app.php` use `\OC::$server->getContentSecurityPolicyManager()->addDefaultPolicy($policy)`,
$policy has to be of type `\OCP\AppFramework\Http\ContentSecurityPolicy`.

To test this add something like the following into an `app.php` of any enabled app:
```
$manager = \OC::$server->getContentSecurityPolicyManager();
$policy = new \OCP\AppFramework\Http\ContentSecurityPolicy(false);
$policy->addAllowedFrameDomain('asdf');
$policy->addAllowedScriptDomain('yolo.com');

$policy->allowInlineScript(false);
$manager->addDefaultPolicy($policy);
$policy = new \OCP\AppFramework\Http\ContentSecurityPolicy(false);
$policy->addAllowedFontDomain('yolo.com');
$manager->addDefaultPolicy($policy);

$policy = new \OCP\AppFramework\Http\ContentSecurityPolicy(false);
$policy->addAllowedFrameDomain('banana.com');
$manager->addDefaultPolicy($policy);
```

If you now open the files app the policy should be:

```
Content-Security-Policy:default-src 'none';script-src yolo.com 'self' 'unsafe-eval';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src yolo.com 'self';connect-src 'self';media-src 'self';frame-src asdf banana.com 'self'
```
809ff5ac
History