IProvider.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. }