Merge pull request #18308 from nextcloud/backport/18184/stable16
[stable16] Move overwritehost check to isTrustedDomain
This commit is contained in:
commit
4d26a8f6dc
|
@ -748,9 +748,6 @@ class OC {
|
||||||
* FIXME: Should not be in here at all :see_no_evil:
|
* FIXME: Should not be in here at all :see_no_evil:
|
||||||
*/
|
*/
|
||||||
if (!OC::$CLI
|
if (!OC::$CLI
|
||||||
// overwritehost is always trusted, workaround to not have to make
|
|
||||||
// \OC\AppFramework\Http\Request::getOverwriteHost public
|
|
||||||
&& self::$server->getConfig()->getSystemValue('overwritehost') === ''
|
|
||||||
&& !\OC::$server->getTrustedDomainHelper()->isTrustedDomain($host)
|
&& !\OC::$server->getTrustedDomainHelper()->isTrustedDomain($host)
|
||||||
&& self::$server->getConfig()->getSystemValue('installed', false)
|
&& self::$server->getConfig()->getSystemValue('installed', false)
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -69,6 +69,11 @@ class TrustedDomainHelper {
|
||||||
* have been configured
|
* have been configured
|
||||||
*/
|
*/
|
||||||
public function isTrustedDomain($domainWithPort) {
|
public function isTrustedDomain($domainWithPort) {
|
||||||
|
// overwritehost is always trusted
|
||||||
|
if ($this->config->getSystemValue('overwritehost') !== '') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
$domain = $this->getDomainWithoutPort($domainWithPort);
|
$domain = $this->getDomainWithoutPort($domainWithPort);
|
||||||
|
|
||||||
// Read trusted domains from config
|
// Read trusted domains from config
|
||||||
|
|
|
@ -31,7 +31,11 @@ class TrustedDomainHelperTest extends \Test\TestCase {
|
||||||
* @param bool $result
|
* @param bool $result
|
||||||
*/
|
*/
|
||||||
public function testIsTrustedDomain($trustedDomains, $testDomain, $result) {
|
public function testIsTrustedDomain($trustedDomains, $testDomain, $result) {
|
||||||
$this->config->expects($this->once())
|
$this->config->expects($this->at(0))
|
||||||
|
->method('getSystemValue')
|
||||||
|
->with('overwritehost')
|
||||||
|
->will($this->returnValue(''));
|
||||||
|
$this->config->expects($this->at(1))
|
||||||
->method('getSystemValue')
|
->method('getSystemValue')
|
||||||
->with('trusted_domains')
|
->with('trusted_domains')
|
||||||
->will($this->returnValue($trustedDomains));
|
->will($this->returnValue($trustedDomains));
|
||||||
|
@ -108,4 +112,15 @@ class TrustedDomainHelperTest extends \Test\TestCase {
|
||||||
[$trustedHostTestList, 'bad..der.leading.host', false],
|
[$trustedHostTestList, 'bad..der.leading.host', false],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testIsTrustedDomainOverwriteHost() {
|
||||||
|
$this->config->expects($this->at(0))
|
||||||
|
->method('getSystemValue')
|
||||||
|
->with('overwritehost')
|
||||||
|
->will($this->returnValue('myproxyhost'));
|
||||||
|
|
||||||
|
$trustedDomainHelper = new TrustedDomainHelper($this->config);
|
||||||
|
$this->assertTrue($trustedDomainHelper->isTrustedDomain('myproxyhost'));
|
||||||
|
$this->assertTrue($trustedDomainHelper->isTrustedDomain('myotherhost'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue