diff --git a/core/templates/untrustedDomain.php b/core/templates/untrustedDomain.php index 297220c92b..1443c41282 100644 --- a/core/templates/untrustedDomain.php +++ b/core/templates/untrustedDomain.php @@ -6,12 +6,8 @@

t('Please contact your administrator. If you are an administrator, edit the "trusted_domains" setting in config/config.php like the example in config.sample.php.')); ?>

+

- t('Depending on your configuration, this button could also work to trust the domain:')); ?> -

-

- - t('Add "%s" as trusted domain', array($_['domain']))); ?> - + t('Further information how to configure this can be found in the %sdocumentation%s.', ['', ''])); ?>

diff --git a/lib/base.php b/lib/base.php index fa2f5011f1..f3e2e734d0 100644 --- a/lib/base.php +++ b/lib/base.php @@ -778,7 +778,7 @@ class OC { OC_Response::setStatus(\OC_Response::STATUS_BAD_REQUEST); header('Status: 400 Bad Request'); - \OC::$server->getLogger()->warning( + \OC::$server->getLogger()->info( 'Trusted domain error. "{remoteAddress}" tried to access using "{host}" as host.', [ 'app' => 'core', @@ -788,7 +788,7 @@ class OC { ); $tmpl = new OCP\Template('core', 'untrustedDomain', 'guest'); - $tmpl->assign('domain', $host); + $tmpl->assign('docUrl', \OC::$server->getURLGenerator()->linkToDocs('admin-trusted-domains')); $tmpl->printPage(); exit(); diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 99023096bc..c24b1832ec 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -898,7 +898,6 @@ return array( 'OC\\Settings\\Controller\\LogSettingsController' => $baseDir . '/settings/Controller/LogSettingsController.php', 'OC\\Settings\\Controller\\MailSettingsController' => $baseDir . '/settings/Controller/MailSettingsController.php', 'OC\\Settings\\Controller\\PersonalSettingsController' => $baseDir . '/settings/Controller/PersonalSettingsController.php', - 'OC\\Settings\\Controller\\SecuritySettingsController' => $baseDir . '/settings/Controller/SecuritySettingsController.php', 'OC\\Settings\\Controller\\UsersController' => $baseDir . '/settings/Controller/UsersController.php', 'OC\\Settings\\Hooks' => $baseDir . '/settings/Hooks.php', 'OC\\Settings\\Mailer\\NewUserMailHelper' => $baseDir . '/settings/Mailer/NewUserMailHelper.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 33533569e9..b4af81e36c 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -928,7 +928,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Settings\\Controller\\LogSettingsController' => __DIR__ . '/../../..' . '/settings/Controller/LogSettingsController.php', 'OC\\Settings\\Controller\\MailSettingsController' => __DIR__ . '/../../..' . '/settings/Controller/MailSettingsController.php', 'OC\\Settings\\Controller\\PersonalSettingsController' => __DIR__ . '/../../..' . '/settings/Controller/PersonalSettingsController.php', - 'OC\\Settings\\Controller\\SecuritySettingsController' => __DIR__ . '/../../..' . '/settings/Controller/SecuritySettingsController.php', 'OC\\Settings\\Controller\\UsersController' => __DIR__ . '/../../..' . '/settings/Controller/UsersController.php', 'OC\\Settings\\Hooks' => __DIR__ . '/../../..' . '/settings/Hooks.php', 'OC\\Settings\\Mailer\\NewUserMailHelper' => __DIR__ . '/../../..' . '/settings/Mailer/NewUserMailHelper.php', diff --git a/settings/Controller/SecuritySettingsController.php b/settings/Controller/SecuritySettingsController.php deleted file mode 100644 index bda86dff84..0000000000 --- a/settings/Controller/SecuritySettingsController.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @author Morris Jobke - * @author Roeland Jago Douma - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see - * - */ - -namespace OC\Settings\Controller; - -use \OCP\AppFramework\Controller; -use OCP\IRequest; -use OCP\IConfig; - -/** - * @package OC\Settings\Controller - */ -class SecuritySettingsController extends Controller { - /** @var \OCP\IConfig */ - private $config; - - /** - * @param string $appName - * @param IRequest $request - * @param IConfig $config - */ - public function __construct($appName, - IRequest $request, - IConfig $config) { - parent::__construct($appName, $request); - $this->config = $config; - } - - /** - * @return array - */ - protected function returnSuccess() { - return array( - 'status' => 'success' - ); - } - - /** - * Add a new trusted domain - * @param string $newTrustedDomain The newly to add trusted domain - * @return array - */ - public function trustedDomains($newTrustedDomain) { - $trustedDomains = $this->config->getSystemValue('trusted_domains', []); - $trustedDomains[] = $newTrustedDomain; - $this->config->setSystemValue('trusted_domains', $trustedDomains); - - return $this->returnSuccess(); - } - -} diff --git a/settings/js/admin.js b/settings/js/admin.js index f637cb6459..650bc84930 100644 --- a/settings/js/admin.js +++ b/settings/js/admin.js @@ -1,29 +1,4 @@ $(document).ready(function(){ - var params = OC.Util.History.parseUrlQuery(); - - // Hack to add a trusted domain - if (params.trustDomain) { - var potentialDomain = params.trustDomain; - potentialDomain = encodeURI(escapeHTML(potentialDomain)); - potentialDomain = '' + potentialDomain + ''; - - OC.dialogs.confirmHtml(t('settings', 'Are you really sure you want add {domain} as trusted domain?', { - domain: potentialDomain - }, undefined, {escape: false}), - t('settings', 'Add trusted domain'), function(answer) { - if(answer) { - $.ajax({ - type: 'POST', - url: OC.generateUrl('settings/admin/security/trustedDomains'), - data: { newTrustedDomain: params.trustDomain } - }).done(function() { - window.location.replace(OC.generateUrl('settings/admin')); - }); - } - }); - } - - $('#excludedGroups').each(function (index, element) { OC.Settings.setupGroupsSelect($(element)); $(element).change(function(ev) { diff --git a/settings/routes.php b/settings/routes.php index df49f0af85..9a89d7353e 100644 --- a/settings/routes.php +++ b/settings/routes.php @@ -50,7 +50,6 @@ $application->registerRoutes($this, [ ['name' => 'AppSettings#listCategories', 'url' => '/settings/apps/categories', 'verb' => 'GET'], ['name' => 'AppSettings#viewApps', 'url' => '/settings/apps', 'verb' => 'GET'], ['name' => 'AppSettings#listApps', 'url' => '/settings/apps/list', 'verb' => 'GET'], - ['name' => 'SecuritySettings#trustedDomains', 'url' => '/settings/admin/security/trustedDomains', 'verb' => 'POST'], ['name' => 'Users#setDisplayName', 'url' => '/settings/users/{username}/displayName', 'verb' => 'POST'], ['name' => 'Users#setEMailAddress', 'url' => '/settings/users/{id}/mailAddress', 'verb' => 'PUT'], ['name' => 'Users#setUserSettings', 'url' => '/settings/users/{username}/settings', 'verb' => 'PUT'], diff --git a/tests/Settings/ApplicationTest.php b/tests/Settings/ApplicationTest.php index 8346f668d9..31391a8fac 100644 --- a/tests/Settings/ApplicationTest.php +++ b/tests/Settings/ApplicationTest.php @@ -33,7 +33,6 @@ use OC\Settings\Controller\CheckSetupController; use OC\Settings\Controller\GroupsController; use OC\Settings\Controller\LogSettingsController; use OC\Settings\Controller\MailSettingsController; -use OC\Settings\Controller\SecuritySettingsController; use OC\Settings\Controller\UsersController; use OC\Settings\Middleware\SubadminMiddleware; use OCP\AppFramework\Controller; @@ -76,7 +75,6 @@ class ApplicationTest extends TestCase { [GroupsController::class, Controller::class], [LogSettingsController::class, Controller::class], [MailSettingsController::class, Controller::class], - [SecuritySettingsController::class, Controller::class], [UsersController::class, Controller::class], [SubadminMiddleware::class, Middleware::class], diff --git a/tests/Settings/Controller/SecuritySettingsControllerTest.php b/tests/Settings/Controller/SecuritySettingsControllerTest.php deleted file mode 100644 index 75d580d9f8..0000000000 --- a/tests/Settings/Controller/SecuritySettingsControllerTest.php +++ /dev/null @@ -1,72 +0,0 @@ -config = $this->createMock(IConfig::class); - $this->securitySettingsController = new SecuritySettingsController( - 'settings', - $this->createMock(IRequest::class), - $this->config - ); - } - - public function testTrustedDomainsWithExistingValues() { - $this->config - ->expects($this->once()) - ->method('setSystemValue') - ->with('trusted_domains', array('owncloud.org', 'owncloud.com', 'newdomain.com')); - $this->config - ->expects($this->once()) - ->method('getSystemValue') - ->with('trusted_domains') - ->will($this->returnValue(array('owncloud.org', 'owncloud.com'))); - - $response = $this->securitySettingsController->trustedDomains('newdomain.com'); - $expectedResponse = array('status' => 'success'); - - $this->assertSame($expectedResponse, $response); - } - - public function testTrustedDomainsEmpty() { - $this->config - ->expects($this->once()) - ->method('setSystemValue') - ->with('trusted_domains', array('newdomain.com')); - $this->config - ->expects($this->once()) - ->method('getSystemValue') - ->with($this->equalTo('trusted_domains'), $this->equalTo([])) - ->willReturn([]); - - $response = $this->securitySettingsController->trustedDomains('newdomain.com'); - $expectedResponse = array('status' => 'success'); - - $this->assertSame($expectedResponse, $response); - } -}