aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/Authentication/TwoFactorAuth
diff options
context:
space:
mode:
Diffstat (limited to 'lib/public/Authentication/TwoFactorAuth')
-rw-r--r--lib/public/Authentication/TwoFactorAuth/ALoginSetupController.php17
-rw-r--r--lib/public/Authentication/TwoFactorAuth/IActivatableAtLogin.php25
-rw-r--r--lib/public/Authentication/TwoFactorAuth/IActivatableByAdmin.php31
-rw-r--r--lib/public/Authentication/TwoFactorAuth/IDeactivatableByAdmin.php31
-rw-r--r--lib/public/Authentication/TwoFactorAuth/ILoginSetupProvider.php22
-rw-r--r--lib/public/Authentication/TwoFactorAuth/IPersonalProviderSettings.php25
-rw-r--r--lib/public/Authentication/TwoFactorAuth/IProvider.php77
-rw-r--r--lib/public/Authentication/TwoFactorAuth/IProvidesCustomCSP.php23
-rw-r--r--lib/public/Authentication/TwoFactorAuth/IProvidesIcons.php35
-rw-r--r--lib/public/Authentication/TwoFactorAuth/IProvidesPersonalSettings.php29
-rw-r--r--lib/public/Authentication/TwoFactorAuth/IRegistry.php72
-rw-r--r--lib/public/Authentication/TwoFactorAuth/RegistryEvent.php47
-rw-r--r--lib/public/Authentication/TwoFactorAuth/TwoFactorException.php23
-rw-r--r--lib/public/Authentication/TwoFactorAuth/TwoFactorProviderChallengeFailed.php41
-rw-r--r--lib/public/Authentication/TwoFactorAuth/TwoFactorProviderChallengePassed.php41
-rw-r--r--lib/public/Authentication/TwoFactorAuth/TwoFactorProviderDisabled.php36
-rw-r--r--lib/public/Authentication/TwoFactorAuth/TwoFactorProviderForUserDisabled.php49
-rw-r--r--lib/public/Authentication/TwoFactorAuth/TwoFactorProviderForUserEnabled.php49
-rw-r--r--lib/public/Authentication/TwoFactorAuth/TwoFactorProviderForUserRegistered.php41
-rw-r--r--lib/public/Authentication/TwoFactorAuth/TwoFactorProviderForUserUnregistered.php41
-rw-r--r--lib/public/Authentication/TwoFactorAuth/TwoFactorProviderUserDeleted.php41
21 files changed, 796 insertions, 0 deletions
diff --git a/lib/public/Authentication/TwoFactorAuth/ALoginSetupController.php b/lib/public/Authentication/TwoFactorAuth/ALoginSetupController.php
new file mode 100644
index 00000000000..f298ccbc64b
--- /dev/null
+++ b/lib/public/Authentication/TwoFactorAuth/ALoginSetupController.php
@@ -0,0 +1,17 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Authentication\TwoFactorAuth;
+
+use OCP\AppFramework\Controller;
+
+/**
+ * @since 17.0.0
+ */
+abstract class ALoginSetupController extends Controller {
+}
diff --git a/lib/public/Authentication/TwoFactorAuth/IActivatableAtLogin.php b/lib/public/Authentication/TwoFactorAuth/IActivatableAtLogin.php
new file mode 100644
index 00000000000..176b593afb7
--- /dev/null
+++ b/lib/public/Authentication/TwoFactorAuth/IActivatableAtLogin.php
@@ -0,0 +1,25 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Authentication\TwoFactorAuth;
+
+use OCP\IUser;
+
+/**
+ * @since 17.0.0
+ */
+interface IActivatableAtLogin extends IProvider {
+ /**
+ * @param IUser $user
+ *
+ * @return ILoginSetupProvider
+ *
+ * @since 17.0.0
+ */
+ public function getLoginSetup(IUser $user): ILoginSetupProvider;
+}
diff --git a/lib/public/Authentication/TwoFactorAuth/IActivatableByAdmin.php b/lib/public/Authentication/TwoFactorAuth/IActivatableByAdmin.php
new file mode 100644
index 00000000000..fffb154b174
--- /dev/null
+++ b/lib/public/Authentication/TwoFactorAuth/IActivatableByAdmin.php
@@ -0,0 +1,31 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Authentication\TwoFactorAuth;
+
+use OCP\IUser;
+
+/**
+ * Marks a 2FA provider as activatable by the administrator. This means that an
+ * admin can activate this provider without user interaction. The provider,
+ * therefore, must not require any user-provided configuration.
+ *
+ * @since 15.0.0
+ */
+interface IActivatableByAdmin extends IProvider {
+ /**
+ * Enable this provider for the given user.
+ *
+ * @param IUser $user the user to activate this provider for
+ *
+ * @return void
+ *
+ * @since 15.0.0
+ */
+ public function enableFor(IUser $user);
+}
diff --git a/lib/public/Authentication/TwoFactorAuth/IDeactivatableByAdmin.php b/lib/public/Authentication/TwoFactorAuth/IDeactivatableByAdmin.php
new file mode 100644
index 00000000000..e6cf91ac6a3
--- /dev/null
+++ b/lib/public/Authentication/TwoFactorAuth/IDeactivatableByAdmin.php
@@ -0,0 +1,31 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Authentication\TwoFactorAuth;
+
+use OCP\IUser;
+
+/**
+ * Marks a 2FA provider as activale by the administrator. This means that an
+ * admin can activate this provider without user interaction. The provider,
+ * therefore, must not require any user-provided configuration.
+ *
+ * @since 15.0.0
+ */
+interface IDeactivatableByAdmin extends IProvider {
+ /**
+ * Disable this provider for the given user.
+ *
+ * @param IUser $user the user to deactivate this provider for
+ *
+ * @return void
+ *
+ * @since 15.0.0
+ */
+ public function disableFor(IUser $user);
+}
diff --git a/lib/public/Authentication/TwoFactorAuth/ILoginSetupProvider.php b/lib/public/Authentication/TwoFactorAuth/ILoginSetupProvider.php
new file mode 100644
index 00000000000..32ede4f385c
--- /dev/null
+++ b/lib/public/Authentication/TwoFactorAuth/ILoginSetupProvider.php
@@ -0,0 +1,22 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Authentication\TwoFactorAuth;
+
+use OCP\Template\ITemplate;
+
+/**
+ * @since 17.0.0
+ */
+interface ILoginSetupProvider {
+ /**
+ * @since 17.0.0
+ * @since 32.0.0 Broader return type ITemplate instead of \OCP\Template
+ */
+ public function getBody(): ITemplate;
+}
diff --git a/lib/public/Authentication/TwoFactorAuth/IPersonalProviderSettings.php b/lib/public/Authentication/TwoFactorAuth/IPersonalProviderSettings.php
new file mode 100644
index 00000000000..3cf7946272e
--- /dev/null
+++ b/lib/public/Authentication/TwoFactorAuth/IPersonalProviderSettings.php
@@ -0,0 +1,25 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\Authentication\TwoFactorAuth;
+
+use OCP\Template\ITemplate;
+
+/**
+ * Interface IPersonalProviderSettings
+ *
+ * @since 15.0.0
+ */
+interface IPersonalProviderSettings {
+ /**
+ * @since 15.0.0
+ * @since 32.0.0 Broader return type ITemplate instead of \OCP\Template
+ */
+ public function getBody(): ITemplate;
+}
diff --git a/lib/public/Authentication/TwoFactorAuth/IProvider.php b/lib/public/Authentication/TwoFactorAuth/IProvider.php
new file mode 100644
index 00000000000..27c4121f4ac
--- /dev/null
+++ b/lib/public/Authentication/TwoFactorAuth/IProvider.php
@@ -0,0 +1,77 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+namespace OCP\Authentication\TwoFactorAuth;
+
+use OCP\IUser;
+use OCP\Template\ITemplate;
+
+/**
+ * @since 9.1.0
+ */
+interface IProvider {
+ /**
+ * Get unique identifier of this 2FA provider
+ *
+ * @since 9.1.0
+ *
+ * @return string
+ */
+ public function getId(): string;
+
+ /**
+ * Get the display name for selecting the 2FA provider
+ *
+ * Example: "Email"
+ *
+ * @since 9.1.0
+ *
+ * @return string
+ */
+ public function getDisplayName(): string;
+
+ /**
+ * Get the description for selecting the 2FA provider
+ *
+ * Example: "Get a token via e-mail"
+ *
+ * @since 9.1.0
+ *
+ * @return string
+ */
+ public function getDescription(): string;
+
+ /**
+ * Get the template for rending the 2FA provider view
+ *
+ * @since 9.1.0
+ * @since 32.0.0 Broader return type ITemplate instead of \OCP\Template.
+ */
+ public function getTemplate(IUser $user): ITemplate;
+
+ /**
+ * Verify the given challenge
+ *
+ * @since 9.1.0
+ *
+ * @param IUser $user
+ * @param string $challenge
+ * @return bool
+ */
+ public function verifyChallenge(IUser $user, string $challenge): bool;
+
+ /**
+ * Decides whether 2FA is enabled for the given user
+ *
+ * @since 9.1.0
+ *
+ * @param IUser $user
+ * @return bool
+ */
+ public function isTwoFactorAuthEnabledForUser(IUser $user): bool;
+}
diff --git a/lib/public/Authentication/TwoFactorAuth/IProvidesCustomCSP.php b/lib/public/Authentication/TwoFactorAuth/IProvidesCustomCSP.php
new file mode 100644
index 00000000000..8dd0a1dd205
--- /dev/null
+++ b/lib/public/Authentication/TwoFactorAuth/IProvidesCustomCSP.php
@@ -0,0 +1,23 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Authentication\TwoFactorAuth;
+
+use OCP\AppFramework\Http\ContentSecurityPolicy;
+
+/**
+ * @since 13.0.0
+ */
+interface IProvidesCustomCSP {
+ /**
+ * @return ContentSecurityPolicy
+ *
+ * @since 13.0.0
+ */
+ public function getCSP(): ContentSecurityPolicy;
+}
diff --git a/lib/public/Authentication/TwoFactorAuth/IProvidesIcons.php b/lib/public/Authentication/TwoFactorAuth/IProvidesIcons.php
new file mode 100644
index 00000000000..b19926cab03
--- /dev/null
+++ b/lib/public/Authentication/TwoFactorAuth/IProvidesIcons.php
@@ -0,0 +1,35 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Authentication\TwoFactorAuth;
+
+/**
+ * Interface for two-factor providers that provide dark and light provider
+ * icons
+ *
+ * @since 15.0.0
+ */
+interface IProvidesIcons extends IProvider {
+ /**
+ * Get the path to the light (white) icon of this provider
+ *
+ * @return String
+ *
+ * @since 15.0.0
+ */
+ public function getLightIcon(): String;
+
+ /**
+ * Get the path to the dark (black) icon of this provider
+ *
+ * @return String
+ *
+ * @since 15.0.0
+ */
+ public function getDarkIcon(): String;
+}
diff --git a/lib/public/Authentication/TwoFactorAuth/IProvidesPersonalSettings.php b/lib/public/Authentication/TwoFactorAuth/IProvidesPersonalSettings.php
new file mode 100644
index 00000000000..4c922318950
--- /dev/null
+++ b/lib/public/Authentication/TwoFactorAuth/IProvidesPersonalSettings.php
@@ -0,0 +1,29 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Authentication\TwoFactorAuth;
+
+use OCP\IUser;
+
+/**
+ * Interface for admins that have personal settings. These settings will be shown in the
+ * security sections. Some information like the display name of the provider is read
+ * from the provider directly.
+ *
+ * @since 15.0.0
+ */
+interface IProvidesPersonalSettings extends IProvider {
+ /**
+ * @param IUser $user
+ *
+ * @return IPersonalProviderSettings
+ *
+ * @since 15.0.0
+ */
+ public function getPersonalSettings(IUser $user): IPersonalProviderSettings;
+}
diff --git a/lib/public/Authentication/TwoFactorAuth/IRegistry.php b/lib/public/Authentication/TwoFactorAuth/IRegistry.php
new file mode 100644
index 00000000000..6817f1763cf
--- /dev/null
+++ b/lib/public/Authentication/TwoFactorAuth/IRegistry.php
@@ -0,0 +1,72 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Authentication\TwoFactorAuth;
+
+use OCP\IUser;
+
+/**
+ * Nextcloud 2FA provider registry for stateful 2FA providers
+ *
+ * This service keeps track of which providers are currently active for a specific
+ * user. Stateful 2FA providers (IStatefulProvider) must use this service to save
+ * their enabled/disabled state.
+ *
+ * @since 14.0.0
+ */
+interface IRegistry {
+ /**
+ * @since 15.0.0
+ * @deprecated 22.0.0
+ */
+ public const EVENT_PROVIDER_ENABLED = self::class . '::enable';
+
+ /**
+ * @since 15.0.0
+ * @deprecated 22.0.0
+ */
+ public const EVENT_PROVIDER_DISABLED = self::class . '::disable';
+
+ /**
+ * Get a key-value map of providers and their enabled/disabled state for
+ * the given user.
+ *
+ * @since 14.0.0
+ * @return array<string, bool> where the array key is the provider ID (string) and the
+ * value is the enabled state (bool)
+ */
+ public function getProviderStates(IUser $user): array;
+
+ /**
+ * Enable the given 2FA provider for the given user
+ *
+ * @since 14.0.0
+ */
+ public function enableProviderFor(IProvider $provider, IUser $user);
+
+ /**
+ * Disable the given 2FA provider for the given user
+ *
+ * @since 14.0.0
+ */
+ public function disableProviderFor(IProvider $provider, IUser $user);
+
+ /**
+ * Cleans up all entries of the provider with the given id. This is only
+ * necessary in edge-cases where an admin disabled and/or uninstalled a
+ * provider app. Invoking this method will make sure outdated provider
+ * associations are removed so that users can log in.
+ *
+ * @since 15.0.0
+ *
+ * @param string $providerId
+ *
+ * @return void
+ */
+ public function cleanUp(string $providerId);
+}
diff --git a/lib/public/Authentication/TwoFactorAuth/RegistryEvent.php b/lib/public/Authentication/TwoFactorAuth/RegistryEvent.php
new file mode 100644
index 00000000000..d498f51316f
--- /dev/null
+++ b/lib/public/Authentication/TwoFactorAuth/RegistryEvent.php
@@ -0,0 +1,47 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Authentication\TwoFactorAuth;
+
+use OCP\EventDispatcher\Event;
+use OCP\IUser;
+
+/**
+ * @since 15.0.0
+ * @deprecated 28.0.0 Use TwoFactorProviderForUserRegistered or TwoFactorProviderForUserUnregistered instead
+ * @see \OCP\Authentication\TwoFactorAuth\TwoFactorProviderForUserRegistered
+ * @see \OCP\Authentication\TwoFactorAuth\TwoFactorProviderForUserUnregistered
+ */
+class RegistryEvent extends Event {
+ private IProvider $provider;
+
+ private IUser $user;
+
+ /**
+ * @since 15.0.0
+ */
+ public function __construct(IProvider $provider, IUser $user) {
+ parent::__construct();
+ $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;
+ }
+}
diff --git a/lib/public/Authentication/TwoFactorAuth/TwoFactorException.php b/lib/public/Authentication/TwoFactorAuth/TwoFactorException.php
new file mode 100644
index 00000000000..4a8d265b9ce
--- /dev/null
+++ b/lib/public/Authentication/TwoFactorAuth/TwoFactorException.php
@@ -0,0 +1,23 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2016 ownCloud GmbH.
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+namespace OCP\Authentication\TwoFactorAuth;
+
+use Exception;
+
+/**
+ * Two Factor Authentication failed
+ *
+ * It defines an Exception a 2FA app can
+ * throw in case of an error. The 2FA Controller will catch this exception and
+ * display this error.
+ *
+ * @since 12
+ */
+class TwoFactorException extends Exception {
+}
diff --git a/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderChallengeFailed.php b/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderChallengeFailed.php
new file mode 100644
index 00000000000..42ca855df35
--- /dev/null
+++ b/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderChallengeFailed.php
@@ -0,0 +1,41 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Authentication\TwoFactorAuth;
+
+use OCP\EventDispatcher\Event;
+use OCP\IUser;
+
+/**
+ * @since 28.0.0
+ */
+class TwoFactorProviderChallengeFailed extends Event {
+ /**
+ * @since 28.0.0
+ */
+ public function __construct(
+ private IUser $user,
+ private IProvider $provider,
+ ) {
+ parent::__construct();
+ }
+
+ /**
+ * @since 28.0.0
+ */
+ public function getUser(): IUser {
+ return $this->user;
+ }
+
+ /**
+ * @since 28.0.0
+ */
+ public function getProvider(): IProvider {
+ return $this->provider;
+ }
+}
diff --git a/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderChallengePassed.php b/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderChallengePassed.php
new file mode 100644
index 00000000000..396fbf9e9a5
--- /dev/null
+++ b/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderChallengePassed.php
@@ -0,0 +1,41 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Authentication\TwoFactorAuth;
+
+use OCP\EventDispatcher\Event;
+use OCP\IUser;
+
+/**
+ * @since 28.0.0
+ */
+class TwoFactorProviderChallengePassed extends Event {
+ /**
+ * @since 28.0.0
+ */
+ public function __construct(
+ private IUser $user,
+ private IProvider $provider,
+ ) {
+ parent::__construct();
+ }
+
+ /**
+ * @since 28.0.0
+ */
+ public function getUser(): IUser {
+ return $this->user;
+ }
+
+ /**
+ * @since 28.0.0
+ */
+ public function getProvider(): IProvider {
+ return $this->provider;
+ }
+}
diff --git a/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderDisabled.php b/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderDisabled.php
new file mode 100644
index 00000000000..48690cb9e2a
--- /dev/null
+++ b/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderDisabled.php
@@ -0,0 +1,36 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Authentication\TwoFactorAuth;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * @since 20.0.0
+ * @deprecated 28.0.0 Use \OCP\Authentication\TwoFactorAuth\TwoFactorProviderUserDeleted instead
+ * @see \OCP\Authentication\TwoFactorAuth\TwoFactorProviderUserDeleted
+ */
+final class TwoFactorProviderDisabled extends Event {
+ /** @var string */
+ private $providerId;
+
+ /**
+ * @since 20.0.0
+ */
+ public function __construct(string $providerId) {
+ parent::__construct();
+ $this->providerId = $providerId;
+ }
+
+ /**
+ * @since 20.0.0
+ */
+ public function getProviderId(): string {
+ return $this->providerId;
+ }
+}
diff --git a/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderForUserDisabled.php b/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderForUserDisabled.php
new file mode 100644
index 00000000000..002ac079e06
--- /dev/null
+++ b/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderForUserDisabled.php
@@ -0,0 +1,49 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Authentication\TwoFactorAuth;
+
+use OCP\EventDispatcher\Event;
+use OCP\IUser;
+
+/**
+ * @since 22.0.0
+ * @deprecated 28.0.0 Use \OCP\Authentication\TwoFactorAuth\TwoFactorProviderChallengeFailed instead
+ * @see \OCP\Authentication\TwoFactorAuth\TwoFactorProviderChallengeFailed
+ */
+class TwoFactorProviderForUserDisabled extends Event {
+ /** @var IProvider */
+ private $provider;
+
+ /** @var IUser */
+ private $user;
+
+ /**
+ * @since 22.0.0
+ */
+ public function __construct(IUser $user, IProvider $provider) {
+ $this->user = $user;
+ $this->provider = $provider;
+ }
+
+ /**
+ * @return IUser
+ * @since 22.0.0
+ */
+ public function getUser(): IUser {
+ return $this->user;
+ }
+
+ /**
+ * @return IProvider
+ * @since 22.0.0
+ */
+ public function getProvider(): IProvider {
+ return $this->provider;
+ }
+}
diff --git a/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderForUserEnabled.php b/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderForUserEnabled.php
new file mode 100644
index 00000000000..9172358cd16
--- /dev/null
+++ b/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderForUserEnabled.php
@@ -0,0 +1,49 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Authentication\TwoFactorAuth;
+
+use OCP\EventDispatcher\Event;
+use OCP\IUser;
+
+/**
+ * @since 22.0.0
+ * @deprecated 28.0.0 Use \OCP\Authentication\TwoFactorAuth\TwoFactorProviderChallengePassed instead
+ * @see \OCP\Authentication\TwoFactorAuth\TwoFactorProviderChallengePassed
+ */
+class TwoFactorProviderForUserEnabled extends Event {
+ /** @var IProvider */
+ private $provider;
+
+ /** @var IUser */
+ private $user;
+
+ /**
+ * @since 22.0.0
+ */
+ public function __construct(IUser $user, IProvider $provider) {
+ $this->user = $user;
+ $this->provider = $provider;
+ }
+
+ /**
+ * @return IUser
+ * @since 22.0.0
+ */
+ public function getUser(): IUser {
+ return $this->user;
+ }
+
+ /**
+ * @return IProvider
+ * @since 22.0.0
+ */
+ public function getProvider(): IProvider {
+ return $this->provider;
+ }
+}
diff --git a/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderForUserRegistered.php b/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderForUserRegistered.php
new file mode 100644
index 00000000000..ed51cee99c8
--- /dev/null
+++ b/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderForUserRegistered.php
@@ -0,0 +1,41 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Authentication\TwoFactorAuth;
+
+use OCP\EventDispatcher\Event;
+use OCP\IUser;
+
+/**
+ * @since 28.0.0
+ */
+class TwoFactorProviderForUserRegistered extends Event {
+ /**
+ * @since 28.0.0
+ */
+ public function __construct(
+ private IUser $user,
+ private IProvider $provider,
+ ) {
+ parent::__construct();
+ }
+
+ /**
+ * @since 28.0.0
+ */
+ public function getProvider(): IProvider {
+ return $this->provider;
+ }
+
+ /**
+ * @since 28.0.0
+ */
+ public function getUser(): IUser {
+ return $this->user;
+ }
+}
diff --git a/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderForUserUnregistered.php b/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderForUserUnregistered.php
new file mode 100644
index 00000000000..1c488a04cdf
--- /dev/null
+++ b/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderForUserUnregistered.php
@@ -0,0 +1,41 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Authentication\TwoFactorAuth;
+
+use OCP\EventDispatcher\Event;
+use OCP\IUser;
+
+/**
+ * @since 28.0.0
+ */
+class TwoFactorProviderForUserUnregistered extends Event {
+ /**
+ * @since 28.0.0
+ */
+ public function __construct(
+ private IUser $user,
+ private IProvider $provider,
+ ) {
+ parent::__construct();
+ }
+
+ /**
+ * @since 28.0.0
+ */
+ public function getProvider(): IProvider {
+ return $this->provider;
+ }
+
+ /**
+ * @since 28.0.0
+ */
+ public function getUser(): IUser {
+ return $this->user;
+ }
+}
diff --git a/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderUserDeleted.php b/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderUserDeleted.php
new file mode 100644
index 00000000000..e99c91b8464
--- /dev/null
+++ b/lib/public/Authentication/TwoFactorAuth/TwoFactorProviderUserDeleted.php
@@ -0,0 +1,41 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Authentication\TwoFactorAuth;
+
+use OCP\EventDispatcher\Event;
+use OCP\IUser;
+
+/**
+ * @since 28.0.0
+ */
+final class TwoFactorProviderUserDeleted extends Event {
+ /**
+ * @since 28.0.0
+ */
+ public function __construct(
+ private IUser $user,
+ private string $providerId,
+ ) {
+ parent::__construct();
+ }
+
+ /**
+ * @since 28.0.0
+ */
+ public function getUser(): IUser {
+ return $this->user;
+ }
+
+ /**
+ * @since 28.0.0
+ */
+ public function getProviderId(): string {
+ return $this->providerId;
+ }
+}