IProvider.php 2.0 KB

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