2018-05-22 02:52:16 -04:00
|
|
|
<?php
|
|
|
|
|
|
2019-12-03 13:57:53 -05:00
|
|
|
declare(strict_types=1);
|
2018-05-22 02:52:16 -04:00
|
|
|
|
|
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2018-05-22 02:52:16 -04:00
|
|
|
*/
|
|
|
|
|
namespace OCP\Authentication\TwoFactorAuth;
|
|
|
|
|
|
|
|
|
|
use OCP\IUser;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Nextcloud 2FA provider registry for stateful 2FA providers
|
2020-04-09 10:09:23 -04:00
|
|
|
*
|
2018-05-22 02:52:16 -04:00
|
|
|
* 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 {
|
2021-02-09 07:53:41 -05:00
|
|
|
/**
|
2024-02-14 14:48:27 -05:00
|
|
|
* @since 15.0.0
|
2021-02-09 07:53:41 -05:00
|
|
|
* @deprecated 22.0.0
|
|
|
|
|
*/
|
2020-04-10 10:54:27 -04:00
|
|
|
public const EVENT_PROVIDER_ENABLED = self::class . '::enable';
|
2021-02-09 07:53:41 -05:00
|
|
|
|
|
|
|
|
/**
|
2024-02-14 14:48:27 -05:00
|
|
|
* @since 15.0.0
|
2021-02-09 07:53:41 -05:00
|
|
|
* @deprecated 22.0.0
|
|
|
|
|
*/
|
2020-04-10 10:54:27 -04:00
|
|
|
public const EVENT_PROVIDER_DISABLED = self::class . '::disable';
|
2018-09-29 13:03:07 -04:00
|
|
|
|
2018-05-22 02:52:16 -04:00
|
|
|
/**
|
|
|
|
|
* Get a key-value map of providers and their enabled/disabled state for
|
|
|
|
|
* the given user.
|
|
|
|
|
*
|
|
|
|
|
* @since 14.0.0
|
2022-10-12 05:40:41 -04:00
|
|
|
* @return array<string, bool> where the array key is the provider ID (string) and the
|
2024-08-23 09:10:27 -04:00
|
|
|
* value is the enabled state (bool)
|
2018-05-22 02:52:16 -04:00
|
|
|
*/
|
|
|
|
|
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);
|
2018-09-10 11:02:37 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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);
|
2018-05-22 02:52:16 -04:00
|
|
|
}
|