Skip to content

Commit ad4138c

Browse files
nuzilengcom-Charlie
authored andcommitted
bulk auth origin
1 parent 632a7c6 commit ad4138c

File tree

27 files changed

+547
-133
lines changed

27 files changed

+547
-133
lines changed

app/code/Magento/AsynchronousOperations/Controller/Adminhtml/Bulk/Details.php

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,26 @@
55
*/
66
namespace Magento\AsynchronousOperations\Controller\Adminhtml\Bulk;
77

8+
use Magento\AsynchronousOperations\Model\AccessManager;
9+
use Magento\Framework\View\Result\PageFactory;
10+
use Magento\Backend\App\Action\Context;
11+
use Magento\Backend\App\Action;
12+
use Magento\Framework\App\Action\HttpGetActionInterface;
13+
814
/**
915
* Class View Operation Details Controller
1016
*/
11-
class Details extends \Magento\Backend\App\Action implements \Magento\Framework\App\Action\HttpGetActionInterface
17+
class Details extends Action implements HttpGetActionInterface
1218
{
1319
/**
14-
* @var \Magento\Framework\View\Result\PageFactory
20+
* @var PageFactory
1521
*/
1622
private $resultPageFactory;
1723

1824
/**
19-
* @var \Magento\AsynchronousOperations\Model\AccessValidator
25+
* @var AccessManager
2026
*/
21-
private $accessValidator;
27+
private $accessManager;
2228

2329
/**
2430
* @var string
@@ -27,19 +33,20 @@ class Details extends \Magento\Backend\App\Action implements \Magento\Framework\
2733

2834
/**
2935
* Details constructor.
30-
* @param \Magento\Backend\App\Action\Context $context
31-
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
32-
* @param \Magento\AsynchronousOperations\Model\AccessValidator $accessValidator
36+
*
37+
* @param Context $context
38+
* @param PageFactory $resultPageFactory
39+
* @param AccessManager $accessManager
3340
* @param string $menuId
3441
*/
3542
public function __construct(
36-
\Magento\Backend\App\Action\Context $context,
37-
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
38-
\Magento\AsynchronousOperations\Model\AccessValidator $accessValidator,
43+
Context $context,
44+
PageFactory $resultPageFactory,
45+
AccessManager $accessManager,
3946
$menuId = 'Magento_AsynchronousOperations::system_magento_logging_bulk_operations'
4047
) {
4148
$this->resultPageFactory = $resultPageFactory;
42-
$this->accessValidator = $accessValidator;
49+
$this->accessManager = $accessManager;
4350
$this->menuId = $menuId;
4451
parent::__construct($context);
4552
}
@@ -49,10 +56,9 @@ public function __construct(
4956
*/
5057
protected function _isAllowed()
5158
{
52-
return $this->_authorization->isAllowed('Magento_Logging::system_magento_logging_bulk_operations')
53-
&& $this->accessValidator->isAllowed($this->getRequest()->getParam('uuid'));
59+
return $this->accessManager->isAllowedForBulkUuid($this->getRequest()->getParam('uuid'));
5460
}
55-
61+
5662
/**
5763
* Bulk details action
5864
*

app/code/Magento/AsynchronousOperations/Controller/Adminhtml/Bulk/Retry.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
use Magento\Backend\App\Action\Context;
1111
use Magento\Backend\Model\View\Result\Redirect;
1212
use Magento\Backend\App\Action;
13-
use Magento\AsynchronousOperations\Model\AccessValidator;
13+
use Magento\AsynchronousOperations\Model\AccessManager;
1414
use Magento\Framework\Controller\ResultFactory;
15+
use Magento\Framework\App\Action\HttpPostActionInterface;
1516

1617
/**
1718
* Class Bulk Retry Controller
1819
*/
19-
class Retry extends Action
20+
class Retry extends Action implements HttpPostActionInterface
2021
{
2122
/**
2223
* @var BulkManagement
@@ -29,40 +30,40 @@ class Retry extends Action
2930
private $notificationManagement;
3031

3132
/**
32-
* @var \Magento\AsynchronousOperations\Model\AccessValidator
33+
* @var AccessManager
3334
*/
34-
private $accessValidator;
35+
private $accessManager;
3536

3637
/**
3738
* Retry constructor.
39+
*
3840
* @param Context $context
3941
* @param BulkManagement $bulkManagement
4042
* @param BulkNotificationManagement $notificationManagement
41-
* @param AccessValidator $accessValidator
43+
* @param AccessManager $accessManager
4244
*/
4345
public function __construct(
4446
Context $context,
4547
BulkManagement $bulkManagement,
4648
BulkNotificationManagement $notificationManagement,
47-
AccessValidator $accessValidator
49+
AccessManager $accessManager
4850
) {
4951
parent::__construct($context);
5052
$this->bulkManagement = $bulkManagement;
5153
$this->notificationManagement = $notificationManagement;
52-
$this->accessValidator = $accessValidator;
54+
$this->accessManager = $accessManager;
5355
}
5456

5557
/**
5658
* @inheritDoc
5759
*/
5860
protected function _isAllowed()
5961
{
60-
return $this->_authorization->isAllowed('Magento_Logging::system_magento_logging_bulk_operations')
61-
&& $this->accessValidator->isAllowed($this->getRequest()->getParam('uuid'));
62+
return $this->accessManager->isAllowedForBulkUuid($this->getRequest()->getParam('uuid'));
6263
}
6364

6465
/**
65-
* {@inheritdoc}
66+
* @inheritdoc
6667
*/
6768
public function execute()
6869
{

app/code/Magento/AsynchronousOperations/Controller/Adminhtml/Index/Index.php

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,40 @@
66

77
namespace Magento\AsynchronousOperations\Controller\Adminhtml\Index;
88

9-
class Index extends \Magento\Backend\App\Action
9+
use Magento\Backend\App\Action\Context;
10+
use Magento\Framework\View\Result\PageFactory;
11+
use Magento\Framework\View\Result\Page;
12+
use Magento\AsynchronousOperations\Model\AccessManager;
13+
use Magento\Backend\App\Action;
14+
use Magento\Framework\App\Action\HttpGetActionInterface;
15+
16+
class Index extends Action implements HttpGetActionInterface
1017
{
11-
/**
12-
* Authorization level of a basic admin session
13-
*
14-
* @see _isAllowed()
15-
*/
16-
const ADMIN_RESOURCE = 'Magento_Logging::system_magento_logging_bulk_operations';
18+
public const BULK_OPERATIONS_MENU_ID = "Magento_AsynchronousOperations::system_magento_logging_bulk_operations";
1719

1820
/**
19-
* @var \Magento\Framework\View\Result\PageFactory
21+
* @var PageFactory
2022
*/
2123
private $resultPageFactory;
2224

2325
/**
24-
* @var string
26+
* @var AccessManager
2527
*/
26-
private $menuId;
28+
private $accessManager;
2729

2830
/**
2931
* Details constructor.
30-
* @param \Magento\Backend\App\Action\Context $context
31-
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
32-
* @param string $menuId
32+
* @param Context $context
33+
* @param PageFactory $resultPageFactory
34+
* @param AccessManager $accessManager
3335
*/
3436
public function __construct(
35-
\Magento\Backend\App\Action\Context $context,
36-
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
37-
$menuId = 'Magento_AsynchronousOperations::system_magento_logging_bulk_operations'
37+
Context $context,
38+
PageFactory $resultPageFactory,
39+
AccessManager $accessManager
3840
) {
3941
$this->resultPageFactory = $resultPageFactory;
40-
$this->menuId = $menuId;
42+
$this->accessManager = $accessManager;
4143
parent::__construct($context);
4244
}
4345

@@ -46,19 +48,19 @@ public function __construct(
4648
*/
4749
protected function _isAllowed()
4850
{
49-
return parent::_isAllowed();
51+
return $this->accessManager->isOwnActionsAllowed();
5052
}
5153

5254
/**
5355
* Bulk list action
5456
*
55-
* @return \Magento\Framework\View\Result\Page
57+
* @return Page
5658
*/
5759
public function execute()
5860
{
5961
$resultPage = $this->resultPageFactory->create();
6062
$resultPage->initLayout();
61-
$this->_setActiveMenu($this->menuId);
63+
$this->_setActiveMenu(self::BULK_OPERATIONS_MENU_ID);
6264
$resultPage->getConfig()->getTitle()->prepend(__('Bulk Actions Log'));
6365
return $resultPage;
6466
}

app/code/Magento/AsynchronousOperations/Controller/Adminhtml/Notification/Dismiss.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,51 @@
99
use Magento\Backend\App\Action\Context;
1010
use Magento\Backend\App\Action;
1111
use Magento\Framework\Controller\ResultFactory;
12+
use Magento\AsynchronousOperations\Model\AccessManager;
13+
use Magento\Framework\App\Action\HttpGetActionInterface;
1214

1315
/**
1416
* Class Bulk Notification Dismiss Controller
1517
*/
16-
class Dismiss extends Action
18+
class Dismiss extends Action implements HttpGetActionInterface
1719
{
1820
/**
1921
* @var BulkNotificationManagement
2022
*/
2123
private $notificationManagement;
2224

25+
/**
26+
* @var AccessManager
27+
*/
28+
private $accessManager;
29+
2330
/**
2431
* Class constructor.
2532
*
2633
* @param Context $context
2734
* @param BulkNotificationManagement $notificationManagement
35+
* @param AccessManager $accessManager
2836
*/
2937
public function __construct(
3038
Context $context,
31-
BulkNotificationManagement $notificationManagement
39+
BulkNotificationManagement $notificationManagement,
40+
AccessManager $accessManager
3241
) {
3342
parent::__construct($context);
3443
$this->notificationManagement = $notificationManagement;
44+
$this->accessManager = $accessManager;
3545
}
3646

3747
/**
3848
* @inheritDoc
3949
*/
4050
protected function _isAllowed()
4151
{
42-
return $this->_authorization->isAllowed('Magento_Logging::system_magento_logging_bulk_operations');
52+
return $this->accessManager->isOwnActionsAllowed();
4353
}
4454

4555
/**
46-
* {@inheritdoc}
56+
* @inheritdoc
4757
*/
4858
public function execute()
4959
{

0 commit comments

Comments
 (0)