summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/composer/composer/autoload_classmap.php1
-rw-r--r--lib/composer/composer/autoload_static.php1
-rw-r--r--lib/private/Authentication/TwoFactorAuth/Registry.php16
-rw-r--r--lib/private/legacy/helper.php15
-rw-r--r--lib/public/Authentication/TwoFactorAuth/IRegistry.php4
-rw-r--r--lib/public/Authentication/TwoFactorAuth/RegistryEvent.php62
6 files changed, 84 insertions, 15 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index c35dfe4b3ab..d77cc6797fc 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -74,6 +74,7 @@ return array(
'OCP\\Authentication\\TwoFactorAuth\\IProvider' => $baseDir . '/lib/public/Authentication/TwoFactorAuth/IProvider.php',
'OCP\\Authentication\\TwoFactorAuth\\IProvidesCustomCSP' => $baseDir . '/lib/public/Authentication/TwoFactorAuth/IProvidesCustomCSP.php',
'OCP\\Authentication\\TwoFactorAuth\\IRegistry' => $baseDir . '/lib/public/Authentication/TwoFactorAuth/IRegistry.php',
+ 'OCP\\Authentication\\TwoFactorAuth\\RegistryEvent' => $baseDir . '/lib/public/Authentication/TwoFactorAuth/RegistryEvent.php',
'OCP\\Authentication\\TwoFactorAuth\\TwoFactorException' => $baseDir . '/lib/public/Authentication/TwoFactorAuth/TwoFactorException.php',
'OCP\\AutoloadNotAllowedException' => $baseDir . '/lib/public/AutoloadNotAllowedException.php',
'OCP\\BackgroundJob' => $baseDir . '/lib/public/BackgroundJob.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index acffc1c842b..06899d408ec 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -104,6 +104,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OCP\\Authentication\\TwoFactorAuth\\IProvider' => __DIR__ . '/../../..' . '/lib/public/Authentication/TwoFactorAuth/IProvider.php',
'OCP\\Authentication\\TwoFactorAuth\\IProvidesCustomCSP' => __DIR__ . '/../../..' . '/lib/public/Authentication/TwoFactorAuth/IProvidesCustomCSP.php',
'OCP\\Authentication\\TwoFactorAuth\\IRegistry' => __DIR__ . '/../../..' . '/lib/public/Authentication/TwoFactorAuth/IRegistry.php',
+ 'OCP\\Authentication\\TwoFactorAuth\\RegistryEvent' => __DIR__ . '/../../..' . '/lib/public/Authentication/TwoFactorAuth/RegistryEvent.php',
'OCP\\Authentication\\TwoFactorAuth\\TwoFactorException' => __DIR__ . '/../../..' . '/lib/public/Authentication/TwoFactorAuth/TwoFactorException.php',
'OCP\\AutoloadNotAllowedException' => __DIR__ . '/../../..' . '/lib/public/AutoloadNotAllowedException.php',
'OCP\\BackgroundJob' => __DIR__ . '/../../..' . '/lib/public/BackgroundJob.php',
diff --git a/lib/private/Authentication/TwoFactorAuth/Registry.php b/lib/private/Authentication/TwoFactorAuth/Registry.php
index 2fc90e5d6d9..2f905441953 100644
--- a/lib/private/Authentication/TwoFactorAuth/Registry.php
+++ b/lib/private/Authentication/TwoFactorAuth/Registry.php
@@ -29,15 +29,23 @@ namespace OC\Authentication\TwoFactorAuth;
use OC\Authentication\TwoFactorAuth\Db\ProviderUserAssignmentDao;
use OCP\Authentication\TwoFactorAuth\IProvider;
use OCP\Authentication\TwoFactorAuth\IRegistry;
+use OCP\Authentication\TwoFactorAuth\RegistryEvent;
use OCP\IUser;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+use Symfony\Component\EventDispatcher\GenericEvent;
class Registry implements IRegistry {
/** @var ProviderUserAssignmentDao */
private $assignmentDao;
- public function __construct(ProviderUserAssignmentDao $assignmentDao) {
+ /** @var EventDispatcherInterface */
+ private $dispatcher;
+
+ public function __construct(ProviderUserAssignmentDao $assignmentDao,
+ EventDispatcherInterface $dispatcher) {
$this->assignmentDao = $assignmentDao;
+ $this->dispatcher = $dispatcher;
}
public function getProviderStates(IUser $user): array {
@@ -46,10 +54,16 @@ class Registry implements IRegistry {
public function enableProviderFor(IProvider $provider, IUser $user) {
$this->assignmentDao->persist($provider->getId(), $user->getUID(), 1);
+
+ $event = new RegistryEvent($provider, $user);
+ $this->dispatcher->dispatch(self::EVENT_PROVIDER_ENABLED, $event);
}
public function disableProviderFor(IProvider $provider, IUser $user) {
$this->assignmentDao->persist($provider->getId(), $user->getUID(), 0);
+
+ $event = new RegistryEvent($provider, $user);
+ $this->dispatcher->dispatch(self::EVENT_PROVIDER_DISABLED, $event);
}
public function cleanUp(string $providerId) {
diff --git a/lib/private/legacy/helper.php b/lib/private/legacy/helper.php
index 8373c191dce..5a05e147c2b 100644
--- a/lib/private/legacy/helper.php
+++ b/lib/private/legacy/helper.php
@@ -505,20 +505,7 @@ class OC_Helper {
if (self::is_function_enabled('exec')) {
$exeSniffer = new ExecutableFinder();
// Returns null if nothing is found
- $result = $exeSniffer->find($program);
- if (empty($result)) {
- $paths = getenv('PATH');
- if (empty($paths)) {
- $paths = '/usr/local/bin /usr/bin /opt/bin /bin';
- } else {
- $paths = str_replace(':',' ',getenv('PATH'));
- }
- $command = 'find ' . $paths . ' -name ' . escapeshellarg($program) . ' 2> /dev/null';
- exec($command, $output, $returnCode);
- if (count($output) > 0) {
- $result = escapeshellcmd($output[0]);
- }
- }
+ $result = $exeSniffer->find($program, null, ['/usr/local/sbin', '/usr/local/bin', '/usr/sbin', '/usr/bin', '/sbin', '/bin', '/opt/bin']);
}
// store the value for 5 minutes
$memcache->set($program, $result, 300);
diff --git a/lib/public/Authentication/TwoFactorAuth/IRegistry.php b/lib/public/Authentication/TwoFactorAuth/IRegistry.php
index 5d97c57bcf2..c033ad91245 100644
--- a/lib/public/Authentication/TwoFactorAuth/IRegistry.php
+++ b/lib/public/Authentication/TwoFactorAuth/IRegistry.php
@@ -39,6 +39,10 @@ use OCP\IUser;
*/
interface IRegistry {
+
+ const EVENT_PROVIDER_ENABLED = self::class . '::enable';
+ const EVENT_PROVIDER_DISABLED = self::class . '::disable';
+
/**
* Get a key-value map of providers and their enabled/disabled state for
* the given user.
diff --git a/lib/public/Authentication/TwoFactorAuth/RegistryEvent.php b/lib/public/Authentication/TwoFactorAuth/RegistryEvent.php
new file mode 100644
index 00000000000..9a005c9cd5d
--- /dev/null
+++ b/lib/public/Authentication/TwoFactorAuth/RegistryEvent.php
@@ -0,0 +1,62 @@
+<?php
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2018, Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @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 OCP\Authentication\TwoFactorAuth;
+
+use OCP\IUser;
+use Symfony\Component\EventDispatcher\Event;
+
+/**
+ * @since 15.0.0
+ */
+class RegistryEvent extends Event {
+
+ /** @var IProvider */
+ private $provider;
+
+ /** @IUser */
+ private $user;
+
+ /**
+ * @since 15.0.0
+ */
+ public function __construct(IProvider $provider, IUser $user) {
+ $this->provider = $provider;
+ $this->user = $user;
+ }
+
+ /**
+ * @since 15.0.0
+ */
+ public function getProvider(): IProvider {
+ return $this->provider;
+ }
+
+ /**
+ * @since 15.0.0
+ */
+ public function getUser(): IUser {
+ return $this->user;
+ }
+}