Merge pull request #26779 from nextcloud/backport/26765/stable20
[stable20] No longer add trusted servers on federated share creation
This commit is contained in:
commit
f369fdaf94
|
@ -34,11 +34,6 @@ return [
|
||||||
'url' => '/trusted-servers/{id}',
|
'url' => '/trusted-servers/{id}',
|
||||||
'verb' => 'DELETE'
|
'verb' => 'DELETE'
|
||||||
],
|
],
|
||||||
[
|
|
||||||
'name' => 'Settings#autoAddServers',
|
|
||||||
'url' => '/auto-add-servers',
|
|
||||||
'verb' => 'POST'
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
'ocs' => [
|
'ocs' => [
|
||||||
// old endpoints, only used by Nextcloud and ownCloud
|
// old endpoints, only used by Nextcloud and ownCloud
|
||||||
|
|
|
@ -15,7 +15,6 @@ return array(
|
||||||
'OCA\\Federation\\DAV\\FedAuth' => $baseDir . '/../lib/DAV/FedAuth.php',
|
'OCA\\Federation\\DAV\\FedAuth' => $baseDir . '/../lib/DAV/FedAuth.php',
|
||||||
'OCA\\Federation\\DbHandler' => $baseDir . '/../lib/DbHandler.php',
|
'OCA\\Federation\\DbHandler' => $baseDir . '/../lib/DbHandler.php',
|
||||||
'OCA\\Federation\\Hooks' => $baseDir . '/../lib/Hooks.php',
|
'OCA\\Federation\\Hooks' => $baseDir . '/../lib/Hooks.php',
|
||||||
'OCA\\Federation\\Listener\\FederatedShareAddedListener' => $baseDir . '/../lib/Listener/FederatedShareAddedListener.php',
|
|
||||||
'OCA\\Federation\\Listener\\SabrePluginAuthInitListener' => $baseDir . '/../lib/Listener/SabrePluginAuthInitListener.php',
|
'OCA\\Federation\\Listener\\SabrePluginAuthInitListener' => $baseDir . '/../lib/Listener/SabrePluginAuthInitListener.php',
|
||||||
'OCA\\Federation\\Middleware\\AddServerMiddleware' => $baseDir . '/../lib/Middleware/AddServerMiddleware.php',
|
'OCA\\Federation\\Middleware\\AddServerMiddleware' => $baseDir . '/../lib/Middleware/AddServerMiddleware.php',
|
||||||
'OCA\\Federation\\Migration\\Version1010Date20200630191302' => $baseDir . '/../lib/Migration/Version1010Date20200630191302.php',
|
'OCA\\Federation\\Migration\\Version1010Date20200630191302' => $baseDir . '/../lib/Migration/Version1010Date20200630191302.php',
|
||||||
|
|
|
@ -30,7 +30,6 @@ class ComposerStaticInitFederation
|
||||||
'OCA\\Federation\\DAV\\FedAuth' => __DIR__ . '/..' . '/../lib/DAV/FedAuth.php',
|
'OCA\\Federation\\DAV\\FedAuth' => __DIR__ . '/..' . '/../lib/DAV/FedAuth.php',
|
||||||
'OCA\\Federation\\DbHandler' => __DIR__ . '/..' . '/../lib/DbHandler.php',
|
'OCA\\Federation\\DbHandler' => __DIR__ . '/..' . '/../lib/DbHandler.php',
|
||||||
'OCA\\Federation\\Hooks' => __DIR__ . '/..' . '/../lib/Hooks.php',
|
'OCA\\Federation\\Hooks' => __DIR__ . '/..' . '/../lib/Hooks.php',
|
||||||
'OCA\\Federation\\Listener\\FederatedShareAddedListener' => __DIR__ . '/..' . '/../lib/Listener/FederatedShareAddedListener.php',
|
|
||||||
'OCA\\Federation\\Listener\\SabrePluginAuthInitListener' => __DIR__ . '/..' . '/../lib/Listener/SabrePluginAuthInitListener.php',
|
'OCA\\Federation\\Listener\\SabrePluginAuthInitListener' => __DIR__ . '/..' . '/../lib/Listener/SabrePluginAuthInitListener.php',
|
||||||
'OCA\\Federation\\Middleware\\AddServerMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/AddServerMiddleware.php',
|
'OCA\\Federation\\Middleware\\AddServerMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/AddServerMiddleware.php',
|
||||||
'OCA\\Federation\\Migration\\Version1010Date20200630191302' => __DIR__ . '/..' . '/../lib/Migration/Version1010Date20200630191302.php',
|
'OCA\\Federation\\Migration\\Version1010Date20200630191302' => __DIR__ . '/..' . '/../lib/Migration/Version1010Date20200630191302.php',
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function( $ ) {
|
(function( $ ) {
|
||||||
|
|
||||||
// ocFederationAddServer
|
// ocFederationAddServer
|
||||||
$.fn.ocFederationAddServer = function() {
|
$.fn.ocFederationAddServer = function() {
|
||||||
|
|
||||||
|
@ -27,14 +27,13 @@
|
||||||
========================================================================== */
|
========================================================================== */
|
||||||
|
|
||||||
var $wrapper = $(this),
|
var $wrapper = $(this),
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
$btnAddServer = $wrapper.find("#ocFederationAddServerButton"),
|
$btnAddServer = $wrapper.find("#ocFederationAddServerButton"),
|
||||||
$btnSubmit = $wrapper.find("#ocFederationSubmit"),
|
$btnSubmit = $wrapper.find("#ocFederationSubmit"),
|
||||||
|
|
||||||
// Inputs
|
// Inputs
|
||||||
$inpServerUrl = $wrapper.find("#serverUrl"),
|
$inpServerUrl = $wrapper.find("#serverUrl"),
|
||||||
$inpAutoAddServers = $wrapper.find("#autoAddServers"),
|
|
||||||
|
|
||||||
// misc
|
// misc
|
||||||
$msgBox = $wrapper.find("#ocFederationAddServer .msg"),
|
$msgBox = $wrapper.find("#ocFederationAddServer .msg"),
|
||||||
|
@ -55,17 +54,8 @@
|
||||||
$srvList.on('click', 'li > .icon-delete', function() {
|
$srvList.on('click', 'li > .icon-delete', function() {
|
||||||
var $this = $(this).parent();
|
var $this = $(this).parent();
|
||||||
var id = $this.attr('id');
|
var id = $this.attr('id');
|
||||||
|
|
||||||
removeServer( id );
|
|
||||||
});
|
|
||||||
|
|
||||||
$inpAutoAddServers.on("change", function() {
|
removeServer( id );
|
||||||
$.post(
|
|
||||||
OC.generateUrl('/apps/federation/auto-add-servers'),
|
|
||||||
{
|
|
||||||
autoAddServers: $(this).is(":checked")
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$btnSubmit.on("click", function()
|
$btnSubmit.on("click", function()
|
||||||
|
@ -94,7 +84,7 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/* private Functions
|
/* private Functions
|
||||||
========================================================================== */
|
========================================================================== */
|
||||||
|
|
||||||
|
@ -132,11 +122,11 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
})( jQuery );
|
})( jQuery );
|
||||||
|
|
||||||
window.addEventListener('DOMContentLoaded', function () {
|
window.addEventListener('DOMContentLoaded', function () {
|
||||||
|
|
||||||
$('#ocFederationSettings').ocFederationAddServer();
|
$('#ocFederationSettings').ocFederationAddServer();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -26,8 +26,6 @@
|
||||||
namespace OCA\Federation\AppInfo;
|
namespace OCA\Federation\AppInfo;
|
||||||
|
|
||||||
use OCA\DAV\Events\SabrePluginAuthInitEvent;
|
use OCA\DAV\Events\SabrePluginAuthInitEvent;
|
||||||
use OCA\FederatedFileSharing\Events\FederatedShareAddedEvent;
|
|
||||||
use OCA\Federation\Listener\FederatedShareAddedListener;
|
|
||||||
use OCA\Federation\Listener\SabrePluginAuthInitListener;
|
use OCA\Federation\Listener\SabrePluginAuthInitListener;
|
||||||
use OCA\Federation\Middleware\AddServerMiddleware;
|
use OCA\Federation\Middleware\AddServerMiddleware;
|
||||||
use OCP\AppFramework\App;
|
use OCP\AppFramework\App;
|
||||||
|
@ -47,7 +45,6 @@ class Application extends App implements IBootstrap {
|
||||||
public function register(IRegistrationContext $context): void {
|
public function register(IRegistrationContext $context): void {
|
||||||
$context->registerMiddleware(AddServerMiddleware::class);
|
$context->registerMiddleware(AddServerMiddleware::class);
|
||||||
|
|
||||||
$context->registerEventListener(FederatedShareAddedEvent::class, FederatedShareAddedListener::class);
|
|
||||||
$context->registerEventListener(SabrePluginAuthInitEvent::class, SabrePluginAuthInitListener::class);
|
$context->registerEventListener(SabrePluginAuthInitEvent::class, SabrePluginAuthInitListener::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,16 +87,6 @@ class SettingsController extends Controller {
|
||||||
return new DataResponse();
|
return new DataResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* enable/disable to automatically add servers to the list of trusted servers
|
|
||||||
* once a federated share was created and accepted successfully
|
|
||||||
*
|
|
||||||
* @param bool $autoAddServers
|
|
||||||
*/
|
|
||||||
public function autoAddServers($autoAddServers) {
|
|
||||||
$this->trustedServers->setAutoAddServers($autoAddServers);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check if the server should be added to the list of trusted servers or not
|
* check if the server should be added to the list of trusted servers or not
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,60 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @copyright Copyright (c) 2020, Morris Jobke <hey@morrisjobke.de>
|
|
||||||
*
|
|
||||||
* @author Morris Jobke <hey@morrisjobke.de>
|
|
||||||
*
|
|
||||||
* @license GNU AGPL version 3 or any later version
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace OCA\Federation\Listener;
|
|
||||||
|
|
||||||
use OCA\FederatedFileSharing\Events\FederatedShareAddedEvent;
|
|
||||||
use OCA\Federation\TrustedServers;
|
|
||||||
use OCP\EventDispatcher\Event;
|
|
||||||
use OCP\EventDispatcher\IEventListener;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Automatically add new servers to the list of trusted servers.
|
|
||||||
*
|
|
||||||
* @since 20.0.0
|
|
||||||
*/
|
|
||||||
class FederatedShareAddedListener implements IEventListener {
|
|
||||||
/** @var TrustedServers */
|
|
||||||
private $trustedServers;
|
|
||||||
|
|
||||||
public function __construct(TrustedServers $trustedServers) {
|
|
||||||
$this->trustedServers = $trustedServers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle(Event $event): void {
|
|
||||||
if (!($event instanceof FederatedShareAddedEvent)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$server = $event->getRemote();
|
|
||||||
if (
|
|
||||||
$this->trustedServers->getAutoAddServers() === true &&
|
|
||||||
$this->trustedServers->isTrustedServer($server) === false
|
|
||||||
) {
|
|
||||||
$this->trustedServers->addServer($server);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -10,13 +10,6 @@ style('federation', 'settings-admin')
|
||||||
<h2><?php p($l->t('Trusted servers')); ?></h2>
|
<h2><?php p($l->t('Trusted servers')); ?></h2>
|
||||||
<p class="settings-hint"><?php p($l->t('Federation allows you to connect with other trusted servers to exchange the user directory. For example this will be used to auto-complete external users for federated sharing. It is not necessary to add a server as trusted server in order to create a federated share.')); ?></p>
|
<p class="settings-hint"><?php p($l->t('Federation allows you to connect with other trusted servers to exchange the user directory. For example this will be used to auto-complete external users for federated sharing. It is not necessary to add a server as trusted server in order to create a federated share.')); ?></p>
|
||||||
|
|
||||||
<p>
|
|
||||||
<input id="autoAddServers" type="checkbox" class="checkbox" <?php if ($_['autoAddServers']) {
|
|
||||||
p('checked');
|
|
||||||
} ?> />
|
|
||||||
<label for="autoAddServers"><?php p($l->t('Add server automatically once a federated share was created successfully')); ?></label>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<ul id="listOfTrustedServers">
|
<ul id="listOfTrustedServers">
|
||||||
<?php foreach ($_['trustedServers'] as $trustedServer) { ?>
|
<?php foreach ($_['trustedServers'] as $trustedServer) { ?>
|
||||||
<li id="<?php p($trustedServer['id']); ?>">
|
<li id="<?php p($trustedServer['id']); ?>">
|
||||||
|
|
Loading…
Reference in New Issue