IProvider.php 1.9 KB

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