aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2021-04-16 14:52:59 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2021-04-20 21:01:16 +0200
commit5ee9e1f78467d1004177012978160731606f204e (patch)
tree19d94834311518bb7cad1e2669f7bb64d5225d39 /lib/private
parent46872e392183215a2bcac2e7e80937ae58e4b4ab (diff)
downloadnextcloud-server-5ee9e1f78467d1004177012978160731606f204e.tar.gz
nextcloud-server-5ee9e1f78467d1004177012978160731606f204e.zip
Move 2FA registration to IBootstrap
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/AppFramework/Bootstrap/RegistrationContext.php23
-rw-r--r--lib/private/Authentication/TwoFactorAuth/ProviderLoader.php18
2 files changed, 39 insertions, 2 deletions
diff --git a/lib/private/AppFramework/Bootstrap/RegistrationContext.php b/lib/private/AppFramework/Bootstrap/RegistrationContext.php
index 662296b8dd6..d056c088a9f 100644
--- a/lib/private/AppFramework/Bootstrap/RegistrationContext.php
+++ b/lib/private/AppFramework/Bootstrap/RegistrationContext.php
@@ -92,7 +92,10 @@ class RegistrationContext {
private $templateProviders = [];
/** @var ServiceRegistration<INotifier>[] */
- private $notifierServices;
+ private $notifierServices = [];
+
+ /** @var ServiceRegistration<\OCP\Authentication\TwoFactorAuth\IProvider>[] */
+ private $twoFactorProviders = [];
/** @var ILogger */
private $logger;
@@ -217,6 +220,13 @@ class RegistrationContext {
$notifierClass
);
}
+
+ public function registerTwoFactorProvider(string $twoFactorProviderClass): void {
+ $this->context->registerTwoFactorProvider(
+ $this->appId,
+ $twoFactorProviderClass
+ );
+ }
};
}
@@ -288,6 +298,10 @@ class RegistrationContext {
$this->notifierServices[] = new ServiceRegistration($appId, $class);
}
+ public function registerTwoFactorProvider(string $appId, string $class): void {
+ $this->twoFactorProviders[] = new ServiceRegistration($appId, $class);
+ }
+
/**
* @param App[] $apps
*/
@@ -479,4 +493,11 @@ class RegistrationContext {
public function getNotifierServices(): array {
return $this->notifierServices;
}
+
+ /**
+ * @return ServiceRegistration<\OCP\Authentication\TwoFactorAuth\IProvider>[]
+ */
+ public function getTwoFactorProviders(): array {
+ return $this->twoFactorProviders;
+ }
}
diff --git a/lib/private/Authentication/TwoFactorAuth/ProviderLoader.php b/lib/private/Authentication/TwoFactorAuth/ProviderLoader.php
index 40385d737ae..57b9413feb4 100644
--- a/lib/private/Authentication/TwoFactorAuth/ProviderLoader.php
+++ b/lib/private/Authentication/TwoFactorAuth/ProviderLoader.php
@@ -40,8 +40,12 @@ class ProviderLoader {
/** @var IAppManager */
private $appManager;
- public function __construct(IAppManager $appManager) {
+ /** @var OC\AppFramework\Bootstrap\Coordinator */
+ private $coordinator;
+
+ public function __construct(IAppManager $appManager, OC\AppFramework\Bootstrap\Coordinator $coordinator) {
$this->appManager = $appManager;
+ $this->coordinator = $coordinator;
}
/**
@@ -72,6 +76,18 @@ class ProviderLoader {
}
}
+ $registeredProviders = $this->coordinator->getRegistrationContext()->getTwoFactorProvider();
+ foreach ($registeredProviders as $provider) {
+ try {
+ $this->loadTwoFactorApp($provider->getAppId());
+ $provider = OC::$server->query($provider->getService());
+ $providers[$provider->getId()] = $provider;
+ } catch (QueryException $exc) {
+ // Provider class can not be resolved
+ throw new Exception('Could not load two-factor auth provider ' . $provider->getService());
+ }
+ }
+
return $providers;
}