IProvider.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  6. * SPDX-License-Identifier: AGPL-3.0-only
  7. */
  8. namespace OCP\Authentication\TwoFactorAuth;
  9. use OCP\IUser;
  10. use OCP\Template;
  11. /**
  12. * @since 9.1.0
  13. */
  14. interface IProvider {
  15. /**
  16. * Get unique identifier of this 2FA provider
  17. *
  18. * @since 9.1.0
  19. *
  20. * @return string
  21. */
  22. public function getId(): string;
  23. /**
  24. * Get the display name for selecting the 2FA provider
  25. *
  26. * Example: "Email"
  27. *
  28. * @since 9.1.0
  29. *
  30. * @return string
  31. */
  32. public function getDisplayName(): string;
  33. /**
  34. * Get the description for selecting the 2FA provider
  35. *
  36. * Example: "Get a token via e-mail"
  37. *
  38. * @since 9.1.0
  39. *
  40. * @return string
  41. */
  42. public function getDescription(): string;
  43. /**
  44. * Get the template for rending the 2FA provider view
  45. *
  46. * @since 9.1.0
  47. *
  48. * @param IUser $user
  49. * @return Template
  50. */
  51. public function getTemplate(IUser $user): Template;
  52. /**
  53. * Verify the given challenge
  54. *
  55. * @since 9.1.0
  56. *
  57. * @param IUser $user
  58. * @param string $challenge
  59. * @return bool
  60. */
  61. public function verifyChallenge(IUser $user, string $challenge): bool;
  62. /**
  63. * Decides whether 2FA is enabled for the given user
  64. *
  65. * @since 9.1.0
  66. *
  67. * @param IUser $user
  68. * @return bool
  69. */
  70. public function isTwoFactorAuthEnabledForUser(IUser $user): bool;
  71. }