Authorization.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Webapi;
  7. /**
  8. * Web API authorization model.
  9. *
  10. * @api
  11. * @since 100.1.0
  12. */
  13. class Authorization
  14. {
  15. /**
  16. * @var \Magento\Framework\AuthorizationInterface
  17. * @since 100.1.0
  18. */
  19. protected $authorization;
  20. /**
  21. * Initialize dependencies.
  22. *
  23. * @param \Magento\Framework\AuthorizationInterface $authorization
  24. */
  25. public function __construct(\Magento\Framework\AuthorizationInterface $authorization)
  26. {
  27. $this->authorization = $authorization;
  28. }
  29. /**
  30. * Check if all ACL resources are allowed to be accessed by current API user.
  31. *
  32. * @param string[] $aclResources
  33. * @return bool
  34. * @since 100.1.0
  35. */
  36. public function isAllowed($aclResources)
  37. {
  38. foreach ($aclResources as $resource) {
  39. if (!$this->authorization->isAllowed($resource)) {
  40. return false;
  41. }
  42. }
  43. return true;
  44. }
  45. }