2017-03-31 10:16:22 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @copyright Copyright (c) 2017 Roger Szabo <roger.szabo@web.de>
|
|
|
|
*
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
|
2020-04-29 12:57:22 +03:00
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2017-03-31 10:16:22 +03:00
|
|
|
* @author Roger Szabo <roger.szabo@web.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
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2017-03-31 10:16:22 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCA\User_LDAP\AppInfo;
|
|
|
|
|
2020-07-16 18:08:03 +03:00
|
|
|
use Closure;
|
2019-02-13 02:14:56 +03:00
|
|
|
use OCA\Files_External\Service\BackendService;
|
2017-03-31 10:16:22 +03:00
|
|
|
use OCA\User_LDAP\Controller\RenewPasswordController;
|
2020-07-14 05:47:54 +03:00
|
|
|
use OCA\User_LDAP\Group_Proxy;
|
|
|
|
use OCA\User_LDAP\GroupPluginManager;
|
2019-02-13 02:14:56 +03:00
|
|
|
use OCA\User_LDAP\Handler\ExtStorageConfigHandler;
|
2020-07-14 05:47:54 +03:00
|
|
|
use OCA\User_LDAP\Helper;
|
2018-12-17 02:31:27 +03:00
|
|
|
use OCA\User_LDAP\ILDAPWrapper;
|
|
|
|
use OCA\User_LDAP\LDAP;
|
2020-07-14 05:47:54 +03:00
|
|
|
use OCA\User_LDAP\Notification\Notifier;
|
|
|
|
use OCA\User_LDAP\User_Proxy;
|
|
|
|
use OCA\User_LDAP\UserPluginManager;
|
2017-03-31 10:16:22 +03:00
|
|
|
use OCP\AppFramework\App;
|
2020-07-14 05:47:54 +03:00
|
|
|
use OCP\AppFramework\Bootstrap\IBootContext;
|
|
|
|
use OCP\AppFramework\Bootstrap\IBootstrap;
|
|
|
|
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
2020-07-21 15:36:40 +03:00
|
|
|
use OCP\AppFramework\IAppContainer;
|
2020-07-16 18:08:03 +03:00
|
|
|
use OCP\IConfig;
|
|
|
|
use OCP\IGroupManager;
|
2018-01-26 01:16:13 +03:00
|
|
|
use OCP\IL10N;
|
2020-07-16 11:37:45 +03:00
|
|
|
use OCP\IServerContainer;
|
2020-07-16 18:08:03 +03:00
|
|
|
use OCP\IUserSession;
|
|
|
|
use OCP\Notification\IManager as INotificationManager;
|
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
2017-03-31 10:16:22 +03:00
|
|
|
|
2020-07-14 05:47:54 +03:00
|
|
|
class Application extends App implements IBootstrap {
|
2020-04-09 14:53:40 +03:00
|
|
|
public function __construct() {
|
2017-03-31 10:16:22 +03:00
|
|
|
parent::__construct('user_ldap');
|
|
|
|
$container = $this->getContainer();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Controller
|
|
|
|
*/
|
2020-07-21 15:36:40 +03:00
|
|
|
$container->registerService('RenewPasswordController', function (IAppContainer $appContainer) {
|
2020-07-16 11:37:45 +03:00
|
|
|
/** @var IServerContainer $server */
|
2020-07-21 15:36:40 +03:00
|
|
|
$server = $appContainer->get(IServerContainer::class);
|
2017-03-31 10:16:22 +03:00
|
|
|
|
|
|
|
return new RenewPasswordController(
|
2020-07-21 15:36:40 +03:00
|
|
|
$appContainer->get('AppName'),
|
2017-03-31 10:16:22 +03:00
|
|
|
$server->getRequest(),
|
2020-07-21 15:36:40 +03:00
|
|
|
$appContainer->get('UserManager'),
|
2017-03-31 10:16:22 +03:00
|
|
|
$server->getConfig(),
|
2020-07-21 15:36:40 +03:00
|
|
|
$appContainer->get(IL10N::class),
|
|
|
|
$appContainer->get('Session'),
|
2017-03-31 10:16:22 +03:00
|
|
|
$server->getURLGenerator()
|
|
|
|
);
|
|
|
|
});
|
2018-12-17 02:31:27 +03:00
|
|
|
|
|
|
|
$container->registerService(ILDAPWrapper::class, function () {
|
|
|
|
return new LDAP();
|
|
|
|
});
|
2017-03-31 10:16:22 +03:00
|
|
|
}
|
2019-02-13 02:14:56 +03:00
|
|
|
|
2020-07-14 05:47:54 +03:00
|
|
|
public function register(IRegistrationContext $context): void {
|
|
|
|
}
|
|
|
|
|
|
|
|
public function boot(IBootContext $context): void {
|
2020-07-16 18:08:03 +03:00
|
|
|
$context->injectFn(function (IConfig $config,
|
|
|
|
INotificationManager $notificationManager,
|
|
|
|
IUserSession $userSession,
|
2020-07-21 15:36:40 +03:00
|
|
|
IAppContainer $appContainer,
|
2020-07-16 18:08:03 +03:00
|
|
|
EventDispatcherInterface $dispatcher,
|
|
|
|
IGroupManager $groupManager) {
|
|
|
|
$helper = new Helper($config);
|
|
|
|
$configPrefixes = $helper->getServerConfigurationPrefixes(true);
|
|
|
|
if (count($configPrefixes) > 0) {
|
|
|
|
$ldapWrapper = new LDAP();
|
|
|
|
|
|
|
|
$notificationManager->registerNotifierService(Notifier::class);
|
|
|
|
|
2020-07-21 15:36:40 +03:00
|
|
|
$userPluginManager = $appContainer->get(UserPluginManager::class);
|
|
|
|
$groupPluginManager = $appContainer->get(GroupPluginManager::class);
|
2020-07-16 18:08:03 +03:00
|
|
|
|
|
|
|
$userBackend = new User_Proxy(
|
|
|
|
$configPrefixes, $ldapWrapper, $config, $notificationManager, $userSession, $userPluginManager
|
|
|
|
);
|
|
|
|
$groupBackend = new Group_Proxy($configPrefixes, $ldapWrapper, $groupPluginManager);
|
|
|
|
// register user backend
|
|
|
|
\OC_User::useBackend($userBackend);
|
|
|
|
|
|
|
|
// Hook to allow plugins to work on registered backends
|
|
|
|
$dispatcher->dispatch('OCA\\User_LDAP\\User\\User::postLDAPBackendAdded');
|
|
|
|
|
|
|
|
$groupManager->addBackend($groupBackend);
|
|
|
|
}
|
|
|
|
});
|
2020-07-14 05:47:54 +03:00
|
|
|
|
2020-07-16 18:08:03 +03:00
|
|
|
$context->injectFn(Closure::fromCallable([$this, 'registerBackendDependents']));
|
2020-07-14 05:47:54 +03:00
|
|
|
|
|
|
|
\OCP\Util::connectHook(
|
|
|
|
'\OCA\Files_Sharing\API\Server2Server',
|
|
|
|
'preLoginNameUsedAsUserName',
|
|
|
|
'\OCA\User_LDAP\Helper',
|
|
|
|
'loginName2UserName'
|
|
|
|
);
|
|
|
|
}
|
2019-02-13 02:14:56 +03:00
|
|
|
|
2020-07-21 15:36:40 +03:00
|
|
|
private function registerBackendDependents(IAppContainer $appContainer, EventDispatcherInterface $dispatcher) {
|
2020-07-16 18:08:03 +03:00
|
|
|
$dispatcher->addListener(
|
2019-02-13 02:14:56 +03:00
|
|
|
'OCA\\Files_External::loadAdditionalBackends',
|
2020-07-14 05:47:54 +03:00
|
|
|
function () use ($appContainer) {
|
2020-07-16 11:37:45 +03:00
|
|
|
$storagesBackendService = $appContainer->get(BackendService::class);
|
2020-07-14 05:47:54 +03:00
|
|
|
$storagesBackendService->registerConfigHandler('home', function () use ($appContainer) {
|
2020-07-16 11:37:45 +03:00
|
|
|
return $appContainer->get(ExtStorageConfigHandler::class);
|
2019-02-13 02:14:56 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2017-03-31 10:16:22 +03:00
|
|
|
}
|