IProvider.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016, ownCloud, Inc.
  5. *
  6. * @author Christoph Wurst <christoph@owncloud.com>
  7. *
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OCP\Authentication\TwoFactorAuth;
  24. use OCP\IUser;
  25. use OCP\Template;
  26. /**
  27. * @since 9.1.0
  28. */
  29. interface IProvider {
  30. /**
  31. * @since 14.0.0
  32. */
  33. const EVENT_SUCCESS = self::class . '::success';
  34. const EVENT_FAILED = self::class . '::failed';
  35. /**
  36. * Get unique identifier of this 2FA provider
  37. *
  38. * @since 9.1.0
  39. *
  40. * @return string
  41. */
  42. public function getId(): string;
  43. /**
  44. * Get the display name for selecting the 2FA provider
  45. *
  46. * Example: "Email"
  47. *
  48. * @since 9.1.0
  49. *
  50. * @return string
  51. */
  52. public function getDisplayName(): string;
  53. /**
  54. * Get the description for selecting the 2FA provider
  55. *
  56. * Example: "Get a token via e-mail"
  57. *
  58. * @since 9.1.0
  59. *
  60. * @return string
  61. */
  62. public function getDescription(): string;
  63. /**
  64. * Get the template for rending the 2FA provider view
  65. *
  66. * @since 9.1.0
  67. *
  68. * @param IUser $user
  69. * @return Template
  70. */
  71. public function getTemplate(IUser $user): Template;
  72. /**
  73. * Verify the given challenge
  74. *
  75. * @since 9.1.0
  76. *
  77. * @param IUser $user
  78. * @param string $challenge
  79. * @return bool
  80. */
  81. public function verifyChallenge(IUser $user, string $challenge): bool;
  82. /**
  83. * Decides whether 2FA is enabled for the given user
  84. *
  85. * @since 9.1.0
  86. *
  87. * @param IUser $user
  88. * @return bool
  89. */
  90. public function isTwoFactorAuthEnabledForUser(IUser $user): bool;
  91. }