1
0

IRegistry.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\Authentication\TwoFactorAuth;
  8. use OCP\IUser;
  9. /**
  10. * Nextcloud 2FA provider registry for stateful 2FA providers
  11. *
  12. * This service keeps track of which providers are currently active for a specific
  13. * user. Stateful 2FA providers (IStatefulProvider) must use this service to save
  14. * their enabled/disabled state.
  15. *
  16. * @since 14.0.0
  17. */
  18. interface IRegistry {
  19. /**
  20. * @since 15.0.0
  21. * @deprecated 22.0.0
  22. */
  23. public const EVENT_PROVIDER_ENABLED = self::class . '::enable';
  24. /**
  25. * @since 15.0.0
  26. * @deprecated 22.0.0
  27. */
  28. public const EVENT_PROVIDER_DISABLED = self::class . '::disable';
  29. /**
  30. * Get a key-value map of providers and their enabled/disabled state for
  31. * the given user.
  32. *
  33. * @since 14.0.0
  34. * @return array<string, bool> where the array key is the provider ID (string) and the
  35. * value is the enabled state (bool)
  36. */
  37. public function getProviderStates(IUser $user): array;
  38. /**
  39. * Enable the given 2FA provider for the given user
  40. *
  41. * @since 14.0.0
  42. */
  43. public function enableProviderFor(IProvider $provider, IUser $user);
  44. /**
  45. * Disable the given 2FA provider for the given user
  46. *
  47. * @since 14.0.0
  48. */
  49. public function disableProviderFor(IProvider $provider, IUser $user);
  50. /**
  51. * Cleans up all entries of the provider with the given id. This is only
  52. * necessary in edge-cases where an admin disabled and/or uninstalled a
  53. * provider app. Invoking this method will make sure outdated provider
  54. * associations are removed so that users can log in.
  55. *
  56. * @since 15.0.0
  57. *
  58. * @param string $providerId
  59. *
  60. * @return void
  61. */
  62. public function cleanUp(string $providerId);
  63. }