TfaProviders.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * IDEALIAGroup srl
  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@idealiagroup.com so we can send you a copy immediately.
  14. *
  15. * @category MSP
  16. * @package MSP_TwoFactorAuth
  17. * @copyright Copyright (c) 2016 IDEALIAGroup srl (http://www.idealiagroup.com)
  18. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  19. */
  20. namespace MSP\TwoFactorAuth\Command;
  21. use Magento\Framework\Exception\LocalizedException;
  22. use MSP\TwoFactorAuth\Api\ProviderPoolInterface;
  23. use MSP\TwoFactorAuth\Api\UserConfigManagerInterface;
  24. use Symfony\Component\Console\Command\Command;
  25. use Symfony\Component\Console\Input\InputArgument;
  26. use Symfony\Component\Console\Input\InputInterface;
  27. use Symfony\Component\Console\Output\OutputInterface;
  28. use Magento\User\Model\UserFactory;
  29. use Magento\User\Model\ResourceModel\User;
  30. class TfaProviders extends Command
  31. {
  32. /**
  33. * @var ProviderPoolInterface
  34. */
  35. private $providerPool;
  36. public function __construct(
  37. ProviderPoolInterface $providerPool
  38. ) {
  39. parent::__construct();
  40. $this->providerPool = $providerPool;
  41. }
  42. protected function configure()
  43. {
  44. $this->setName('msp:security:tfa:providers');
  45. $this->setDescription('List all available providers');
  46. parent::configure();
  47. }
  48. /**
  49. * @SuppressWarnings("PHPMD.UnusedFormalParameter")
  50. */
  51. protected function execute(InputInterface $input, OutputInterface $output)
  52. {
  53. $providers = $this->providerPool->getProviders();
  54. foreach ($providers as $provider) {
  55. $output->writeln(sprintf("%16s: %s", $provider->getCode(), $provider->getName()));
  56. }
  57. }
  58. }