1
0

IProvider.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. * @since 14.0.0
  33. * @deprecated 22.0.0
  34. */
  35. public const EVENT_SUCCESS = self::class . '::success';
  36. /**
  37. * @deprecated 22.0.0
  38. */
  39. public const EVENT_FAILED = self::class . '::failed';
  40. /**
  41. * Get unique identifier of this 2FA provider
  42. *
  43. * @since 9.1.0
  44. *
  45. * @return string
  46. */
  47. public function getId(): string;
  48. /**
  49. * Get the display name for selecting the 2FA provider
  50. *
  51. * Example: "Email"
  52. *
  53. * @since 9.1.0
  54. *
  55. * @return string
  56. */
  57. public function getDisplayName(): string;
  58. /**
  59. * Get the description for selecting the 2FA provider
  60. *
  61. * Example: "Get a token via e-mail"
  62. *
  63. * @since 9.1.0
  64. *
  65. * @return string
  66. */
  67. public function getDescription(): string;
  68. /**
  69. * Get the template for rending the 2FA provider view
  70. *
  71. * @since 9.1.0
  72. *
  73. * @param IUser $user
  74. * @return Template
  75. */
  76. public function getTemplate(IUser $user): Template;
  77. /**
  78. * Verify the given challenge
  79. *
  80. * @since 9.1.0
  81. *
  82. * @param IUser $user
  83. * @param string $challenge
  84. * @return bool
  85. */
  86. public function verifyChallenge(IUser $user, string $challenge): bool;
  87. /**
  88. * Decides whether 2FA is enabled for the given user
  89. *
  90. * @since 9.1.0
  91. *
  92. * @param IUser $user
  93. * @return bool
  94. */
  95. public function isTwoFactorAuthEnabledForUser(IUser $user): bool;
  96. }