Skip to content

Commit a1dd507

Browse files
author
Dale Sikkema
committed
MAGETWO-37228: abstract _isAllowed must perform authorization
1 parent cb4e6b5 commit a1dd507

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

app/code/Magento/Backend/App/AbstractAction.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ abstract class AbstractAction extends \Magento\Framework\App\Action\Action
2222
*/
2323
const SESSION_NAMESPACE = 'adminhtml';
2424

25+
/**
26+
* Authorization level of a basic admin session
27+
*/
28+
const ADMIN_RESOURCE = 'Magento_Backend::admin';
29+
2530
/**
2631
* Array of actions which can be processed without secret key validation
2732
*
@@ -76,10 +81,17 @@ abstract class AbstractAction extends \Magento\Framework\App\Action\Action
7681
*/
7782
protected $_formKeyValidator;
7883

84+
/**
85+
* Resource used to authorize access to the controller
86+
*
87+
* @var string
88+
*/
89+
protected $resource;
90+
7991
/**
8092
* @param \Magento\Backend\App\Action\Context $context
8193
*/
82-
public function __construct(Action\Context $context)
94+
public function __construct(Action\Context $context, $resource = '')
8395
{
8496
parent::__construct($context);
8597
$this->_authorization = $context->getAuthorization();
@@ -97,7 +109,7 @@ public function __construct(Action\Context $context)
97109
*/
98110
protected function _isAllowed()
99111
{
100-
return true;
112+
return $this->_authorization->isAllowed($this->resource ?: self::ADMIN_RESOURCE);
101113
}
102114

103115
/**

0 commit comments

Comments
 (0)