TfaInterface.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. /**
  3. * MageSpecialist
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to info@magespecialist.it so we can send you a copy immediately.
  14. *
  15. * @category MSP
  16. * @package MSP_TwoFactorAuth
  17. * @copyright Copyright (c) 2017 Skeeller srl (http://www.magespecialist.it)
  18. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  19. */
  20. namespace MSP\TwoFactorAuth\Api;
  21. interface TfaInterface
  22. {
  23. const XML_PATH_ENABLED = 'msp_securitysuite_twofactorauth/general/enabled';
  24. const XML_PATH_FORCED_PROVIDERS = 'msp_securitysuite_twofactorauth/general/force_providers';
  25. /**
  26. * Return true if 2FA is enabled
  27. * @return boolean
  28. */
  29. public function isEnabled();
  30. /**
  31. * Get provider by code
  32. * @param string $providerCode
  33. * @param bool $onlyEnabled = true
  34. * @return \MSP\TwoFactorAuth\Api\ProviderInterface|null
  35. */
  36. public function getProvider($providerCode, $onlyEnabled = true);
  37. /**
  38. * Retrieve forced providers list
  39. * @return \MSP\TwoFactorAuth\Api\ProviderInterface[]
  40. */
  41. public function getForcedProviders();
  42. /**
  43. * Get a user provider
  44. * @param int $userId
  45. * @return \MSP\TwoFactorAuth\Api\ProviderInterface[]
  46. */
  47. public function getUserProviders($userId);
  48. /**
  49. * Get a list of providers
  50. * @return \MSP\TwoFactorAuth\Api\ProviderInterface[]
  51. */
  52. public function getAllProviders();
  53. /**
  54. * Get a list of providers
  55. * @param string $code
  56. * @return \MSP\TwoFactorAuth\Api\ProviderInterface
  57. */
  58. public function getProviderByCode($code);
  59. /**
  60. * Get a list of providers
  61. * @return \MSP\TwoFactorAuth\Api\ProviderInterface[]
  62. */
  63. public function getAllEnabledProviders();
  64. /**
  65. * Return a list of trusted devices for given user id
  66. * @param int $userId
  67. * @return \MSP\TwoFactorAuth\Api\Data\TrustedInterface[]
  68. */
  69. public function getTrustedDevices($userId);
  70. /**
  71. * Get allowed URLs
  72. * @return array
  73. */
  74. public function getAllowedUrls();
  75. /**
  76. * Returns a list of providers to configure/enroll
  77. * @param int $userId
  78. * @return \MSP\TwoFactorAuth\Api\ProviderInterface[]
  79. */
  80. public function getProvidersToActivate($userId);
  81. /**
  82. * Return true if a provider is allowed for a given user
  83. * @param int $userId
  84. * @param string $providerCode
  85. * @return boolean
  86. */
  87. public function getProviderIsAllowed($userId, $providerCode);
  88. /**
  89. * Get default provider code
  90. * @param int $userId
  91. * @return string
  92. */
  93. public function getDefaultProviderCode($userId);
  94. /**
  95. * Set default provider code
  96. * @param int $userId
  97. * @param string $providerCode
  98. * @return boolean
  99. */
  100. public function setDefaultProviderCode($userId, $providerCode);
  101. /**
  102. * Set providers
  103. * @param int $userId
  104. * @param string $providersCodes
  105. * @return boolean
  106. */
  107. public function setProvidersCodes($userId, $providersCodes);
  108. /**
  109. * Reset default provider code
  110. * @param int $userId
  111. * @param string $providerCode
  112. * @return boolean
  113. */
  114. public function resetProviderConfig($userId, $providerCode);
  115. }