ITrustedDomainHelper.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\Security;
  8. /**
  9. * Allows checking domains and full URLs against the list of trusted domains for
  10. * this server in the config file.
  11. *
  12. * @package OCP\Security
  13. * @since 23.0.0
  14. */
  15. interface ITrustedDomainHelper {
  16. /**
  17. * Checks whether a given URL is considered as trusted from the list
  18. * of trusted domains in the server's config file. If no trusted domains
  19. * have been configured and the url is valid, returns true.
  20. *
  21. * @param string $url
  22. * @return bool
  23. * @since 23.0.0
  24. */
  25. public function isTrustedUrl(string $url): bool;
  26. /**
  27. * Checks whether a given domain is considered as trusted from the list
  28. * of trusted domains in the server's config file. If no trusted domains
  29. * have been configured, returns true.
  30. * This is used to prevent Host Header Poisoning.
  31. *
  32. * @param string $domainWithPort
  33. * @return bool
  34. * @since 23.0.0
  35. */
  36. public function isTrustedDomain(string $domainWithPort): bool;
  37. }