IContentSecurityPolicyManager.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  6. * SPDX-License-Identifier: AGPL-3.0-only
  7. */
  8. namespace OCP\Security;
  9. use OCP\AppFramework\Http\EmptyContentSecurityPolicy;
  10. /**
  11. * Used for Content Security Policy manipulations
  12. *
  13. * @since 9.0.0
  14. * @deprecated 17.0.0 listen to the AddContentSecurityPolicyEvent to add a policy
  15. */
  16. interface IContentSecurityPolicyManager {
  17. /**
  18. * Allows to inject something into the default content policy. This is for
  19. * example useful when you're injecting Javascript code into a view belonging
  20. * to another controller and cannot modify its Content-Security-Policy itself.
  21. * Note that the adjustment is only applied to applications that use AppFramework
  22. * controllers.
  23. *
  24. * To use this from your `app.php` use `\OC::$server->getContentSecurityPolicyManager()->addDefaultPolicy($policy)`,
  25. * $policy has to be of type `\OCP\AppFramework\Http\ContentSecurityPolicy`.
  26. *
  27. * WARNING: Using this API incorrectly may make the instance more insecure.
  28. * Do think twice before adding whitelisting resources. Please do also note
  29. * that it is not possible to use the `disallowXYZ` functions.
  30. *
  31. * @param EmptyContentSecurityPolicy $policy
  32. * @since 9.0.0
  33. * @deprecated 17.0.0 listen to the AddContentSecurityPolicyEvent to add a policy
  34. */
  35. public function addDefaultPolicy(EmptyContentSecurityPolicy $policy);
  36. }