summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-12-04 12:11:07 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-01-12 14:24:01 +0100
commitdbddbb634bcb6df346988b85cb2847e76e22e632 (patch)
tree7622e29c27a9c920bf8209466ebf01069a476160 /apps
parentcdc536c42367a1c7667a63c598f50b95956da759 (diff)
downloadnextcloud-server-dbddbb634bcb6df346988b85cb2847e76e22e632.tar.gz
nextcloud-server-dbddbb634bcb6df346988b85cb2847e76e22e632.zip
Use EventDispatcher to allow additional setup of auth backends - move federation auth to federation app
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/server.php7
-rw-r--r--apps/federation/appinfo/application.php14
-rw-r--r--apps/federation/dav/fedauth.php (renamed from apps/dav/lib/connector/fedauth.php)2
3 files changed, 21 insertions, 2 deletions
diff --git a/apps/dav/lib/server.php b/apps/dav/lib/server.php
index 8b7171c145c..93e903e6bf1 100644
--- a/apps/dav/lib/server.php
+++ b/apps/dav/lib/server.php
@@ -8,6 +8,7 @@ use OCA\DAV\Connector\Sabre\Auth;
use OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin;
use OCA\DAV\Files\CustomPropertiesBackend;
use OCP\IRequest;
+use OCP\SabrePluginEvent;
use Sabre\DAV\Auth\Plugin;
class Server {
@@ -37,8 +38,12 @@ class Server {
$this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig()));
$authPlugin = new Plugin($authBackend, 'ownCloud');
- $authPlugin->addBackend(new FedAuth(\OC::$server->getDatabaseConnection()));
$this->server->addPlugin($authPlugin);
+
+ // allow setup of additional auth backends
+ $event = new SabrePluginEvent($this->server);
+ $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event);
+
$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\DummyGetResponsePlugin());
$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger));
$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
diff --git a/apps/federation/appinfo/application.php b/apps/federation/appinfo/application.php
index 45d88548b70..f0fefb948af 100644
--- a/apps/federation/appinfo/application.php
+++ b/apps/federation/appinfo/application.php
@@ -23,6 +23,7 @@ namespace OCA\Federation\AppInfo;
use OCA\Federation\API\OCSAuthAPI;
use OCA\Federation\Controller\SettingsController;
+use OCA\Federation\DAV\FedAuth;
use OCA\Federation\DbHandler;
use OCA\Federation\Hooks;
use OCA\Federation\Middleware\AddServerMiddleware;
@@ -30,7 +31,9 @@ use OCA\Federation\TrustedServers;
use OCP\API;
use OCP\App;
use OCP\AppFramework\IAppContainer;
+use OCP\SabrePluginEvent;
use OCP\Util;
+use Sabre\DAV\Auth\Plugin;
class Application extends \OCP\AppFramework\App {
@@ -144,6 +147,17 @@ class Application extends \OCP\AppFramework\App {
$hooksManager,
'addServerHook'
);
+
+ $dispatcher = $this->getContainer()->getServer()->getEventDispatcher();
+ $dispatcher->addListener('OCA\DAV\Connector\Sabre::authInit', function($event) use($container) {
+ if ($event instanceof SabrePluginEvent) {
+ $authPlugin = $event->getServer()->getPlugin('auth');
+ if ($authPlugin instanceof Plugin) {
+ $db = $container->getServer()->getDatabaseConnection();
+ $authPlugin->addBackend(new FedAuth($db));
+ }
+ }
+ });
}
}
diff --git a/apps/dav/lib/connector/fedauth.php b/apps/federation/dav/fedauth.php
index 42a29cef3fc..ade5448d1bc 100644
--- a/apps/dav/lib/connector/fedauth.php
+++ b/apps/federation/dav/fedauth.php
@@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-namespace OCA\DAV\Connector;
+namespace OCA\Federation\DAV;
use OCA\Federation\DbHandler;
use OCP\IDBConnection;