Skip to content
Snippets Groups Projects
Select Git revision
  • 3522d642aa66a42399cf6a998130449eabd1a0ba
  • main default protected
  • automated-updates-main
  • release-0.14
  • 14-env
  • fix-version-3
  • automated-updates-fix-action
  • release-0.15
  • release-0.13
  • automated-updates-release-0.13
  • release-0.10
  • release-0.11
  • release-0.12
  • fix-versions-action
  • versions-fix
  • release-0.9
  • release-0.8
  • release-0.7
  • release-0.6
  • release-0.5
  • release-0.4
  • v0.15.0
  • v0.14.0
  • v0.13.0
  • v0.12.0
  • v0.11.0
  • v0.10.0
  • v0.9.0
  • v0.8.0
  • v0.7.0
  • v0.6.0
  • v0.5.0
  • v0.4.0
  • v0.3.0
  • v0.2.0
  • v0.1.0
36 results

jsonnet-snippets

  • Clone with SSH
  • Clone with HTTPS
  • 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
    Name Last commit Last update
    ..