Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -760,9 +760,6 @@ public static function init() {
* FIXME: Should not be in here at all :see_no_evil:
*/
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)
&& self::$server->getConfig()->getSystemValue('installed', false)
) {
Expand Down
5 changes: 5 additions & 0 deletions lib/private/Security/TrustedDomainHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ private function getDomainWithoutPort($host) {
* have been configured
*/
public function isTrustedDomain($domainWithPort) {
// overwritehost is always trusted
if ($this->config->getSystemValue('overwritehost') !== '') {
return true;
}

$domain = $this->getDomainWithoutPort($domainWithPort);

// Read trusted domains from config
Expand Down
17 changes: 16 additions & 1 deletion tests/lib/Security/TrustedDomainHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ protected function setUp(): void {
* @param bool $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')
->with('trusted_domains')
->will($this->returnValue($trustedDomains));
Expand Down Expand Up @@ -113,4 +117,15 @@ public function trustedDomainDataProvider() {
[$trustedHostTestList, 'LOWERCASE.DOMAIN', true],
];
}

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'));
}
}