Merge pull request #10584 from owncloud/simple-wizard-trusted-domains

Add a trusted domain wizard
remotes/origin/fix-10825
Thomas Müller 2014-08-22 17:12:17 +07:00
commit a77d468d35
7 changed files with 58 additions and 12 deletions

@ -611,6 +611,10 @@ label.infield {
margin-left: -200px !important;
}
.error-wide .button {
color: black !important;
}
/* Fixes for log in page, TODO should be removed some time */
#body-login .update,
#body-login .error {

@ -0,0 +1,19 @@
<?php /** @var $_ array */ ?>
<ul class="error-wide">
<li class='error'>
<?php p($l->t('You are accessing the server from an untrusted domain.')); ?><br/>
<p class='hint'>
<?php p($l->t('Please contact your administrator. If you are an administrator of this instance, configure the "trusted_domain" setting in config/config.php. An example configuration is provided in config/config.sample.php.')); ?>
<br/>
<?php p($l->t('Depending on your configuration, as an administrator you might also be able to use the button below to trust this domain.')); ?>
<br/><br/>
<p style="text-align:center;">
<a href="<?php print_unescaped(OC_Helper::makeURLAbsolute(\OCP\Util::linkToRoute('settings_admin'))); ?>?trustDomain=<?php p($_['domain']); ?>" class="button">
<?php p($l->t('Add "%s" as trusted domain', array($_['domain']))); ?>
</a>
</p>
</p>
</li>
</ul>

@ -689,10 +689,9 @@ class OC {
) {
header('HTTP/1.1 400 Bad Request');
header('Status: 400 Bad Request');
OC_Template::printErrorPage(
$l->t('You are accessing the server from an untrusted domain.'),
$l->t('Please contact your administrator. If you are an administrator of this instance, configure the "trusted_domain" setting in config/config.php. An example configuration is provided in config/config.sample.php.')
);
$tmpl = new OCP\Template('core', 'untrustedDomain', 'guest');
$tmpl->assign('domain', $_SERVER['SERVER_NAME']);
$tmpl->printPage();
return;
}

@ -18,11 +18,10 @@ class AllConfig implements \OCP\IConfig {
*
* @param string $key the key of the value, under which will be saved
* @param mixed $value the value that should be stored
* @todo need a use case for this
*/
// public function setSystemValue($key, $value) {
// \OCP\Config::setSystemValue($key, $value);
// }
public function setSystemValue($key, $value) {
\OCP\Config::setSystemValue($key, $value);
}
/**
* Looks up a system wide defined value

@ -39,9 +39,8 @@ interface IConfig {
*
* @param string $key the key of the value, under which will be saved
* @param mixed $value the value that should be stored
* @todo need a use case for this
*/
// public function setSystemValue($key, $value);
public function setSystemValue($key, $value);
/**
* Looks up a system wide defined value

@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2013, Lukas Reschke <lukas@statuscode.ch>
* Copyright (c) 2013-2014, Lukas Reschke <lukas@owncloud.com>
* This file is licensed under the Affero General Public License version 3 or later.
* See the COPYING-README file.
*/
@ -8,6 +8,14 @@
OC_Util::checkAdminUser();
OCP\JSON::callCheck();
OC_Config::setValue( 'forcessl', filter_var($_POST['enforceHTTPS'], FILTER_VALIDATE_BOOLEAN));
if(isset($_POST['enforceHTTPS'])) {
\OC::$server->getConfig()->setSystemValue('forcessl', filter_var($_POST['enforceHTTPS'], FILTER_VALIDATE_BOOLEAN));
}
if(isset($_POST['trustedDomain'])) {
$trustedDomains = \OC::$server->getConfig()->getSystemValue('trusted_domains');
$trustedDomains[] = $_POST['trustedDomain'];
\OC::$server->getConfig()->setSystemValue('trusted_domains', $trustedDomains);
}
echo 'true';

@ -38,6 +38,24 @@ var SharingGroupList = {
};
$(document).ready(function(){
var params = OC.Util.History.parseUrlQuery();
// Hack to add a trusted domain
if (params.trustDomain) {
OC.dialogs.confirm(t('core', 'Are you really sure you want add "{domain}" as trusted domain?', {domain: params.trustDomain}),
t('core', 'Add trusted domain'), function(answer) {
if(answer) {
$.ajax({
type: 'POST',
url: OC.generateUrl('settings/ajax/setsecurity.php'),
data: { trustedDomain: params.trustDomain }
}).done(function() {
window.location.replace(OC.generateUrl('settings/admin'));
});
}
});
}
$('select#excludedGroups[multiple]').each(function (index, element) {
SharingGroupList.applyMultipleSelect($(element));