Merge pull request #7798 from nextcloud/backport/7796/stable23

[stable23] Add documentation about OCP\Security\ITrustedDomainHelper
This commit is contained in:
Christoph Wurst 2021-12-07 15:26:47 +01:00 committed by GitHub
commit 5064a3c0ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions

View File

@ -27,3 +27,4 @@ Digging deeper
groupware/index
web_host_metadata
status
security

View File

@ -0,0 +1,28 @@
.. _security:
========
Security
========
Trusted domain
----------------
In some cases it might be required that an app checks that a user given link is one of the current instance.
This is possible with the ``OCP\Security\ITrustedDomainHelper``:
.. code-block:: php
<?php
declare(strict_types=1);
use OCP\Security\ITrustedDomainHelper;
$helper = \OC::$server->get(ITrustedDomainHelper::class);
// Compare a full URL example given
$url = 'https://localhost/nextcloud/index.php/apps/files/';
$helper->isTrustedUrl($url);
// Compare a domain and port
$domain = 'example.tld:8443';
$helper->isTrustedDomain($domain);