Testing/CI/ACL
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MageSail\Magesail\Controller\Adminhtml\About;
|
||||
@@ -11,7 +12,7 @@ use Magento\Framework\Controller\ResultInterface;
|
||||
|
||||
class Index extends Action implements HttpGetActionInterface
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'MageSail_Magesail::tunnel';
|
||||
public const ADMIN_RESOURCE = 'MageSail_Magesail::tunnel_view';
|
||||
|
||||
public function __construct(Context $context)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MageSail\Magesail\Controller\Adminhtml\Howto;
|
||||
@@ -11,7 +12,7 @@ use Magento\Framework\Controller\ResultInterface;
|
||||
|
||||
class Index extends Action implements HttpGetActionInterface
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'MageSail_Magesail::tunnel';
|
||||
public const ADMIN_RESOURCE = 'MageSail_Magesail::tunnel_view';
|
||||
|
||||
public function __construct(Context $context)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MageSail\Magesail\Controller\Adminhtml\Nginx;
|
||||
@@ -50,7 +51,7 @@ class Map extends Action
|
||||
}
|
||||
|
||||
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
|
||||
$resultPage->setActiveMenu('MageSail_Magesail::config');
|
||||
$resultPage->setActiveMenu('MageSail_Magesail::nginx_map');
|
||||
$resultPage->getConfig()->getTitle()->prepend(__('NGINX Global Map'));
|
||||
return $resultPage;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MageSail\Magesail\Controller\Adminhtml\Settings;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MageSail\Magesail\Controller\Adminhtml\Tunnel;
|
||||
@@ -42,7 +43,7 @@ class Index extends Action
|
||||
}
|
||||
|
||||
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
|
||||
$resultPage->setActiveMenu('MageSail_Magesail::tunnel');
|
||||
$resultPage->setActiveMenu('MageSail_Magesail::tunnel_index');
|
||||
$resultPage->getConfig()->getTitle()->prepend(__('Holesail Tunnel'));
|
||||
return $resultPage;
|
||||
}
|
||||
@@ -66,6 +67,14 @@ class Index extends Action
|
||||
|
||||
private function handleStart(bool $wantJson)
|
||||
{
|
||||
if (!$this->isAllowedTunnelManage()) {
|
||||
$msg = (string) __('You are not allowed to manage tunnels.');
|
||||
if ($wantJson) {
|
||||
return $this->jsonPayload(false, $msg);
|
||||
}
|
||||
$this->messageManager->addErrorMessage($msg);
|
||||
return $this->_redirect('*/*/index');
|
||||
}
|
||||
$tunnelId = trim((string) $this->getRequest()->getParam('tunnel_id', ''));
|
||||
if ($tunnelId !== '') {
|
||||
return $this->handleStartExisting($tunnelId, $wantJson);
|
||||
@@ -100,6 +109,14 @@ class Index extends Action
|
||||
'already_running' => (string) __('Tunnel is already running.'),
|
||||
'invalid_port' => (string) __('Invalid local port for this tunnel.'),
|
||||
'could_not_create_var_dir' => (string) __('Could not create var directory for tunnel state.'),
|
||||
'script_not_found' => (string) __(
|
||||
'start-server.js was not found. Set Scripts directory in Configuration (expected: %1).',
|
||||
$result['detail'] ?? ''
|
||||
),
|
||||
'node_modules_missing' => (string) __(
|
||||
'Run npm install in the scripts directory (missing node_modules under %1).',
|
||||
$result['detail'] ?? ''
|
||||
),
|
||||
'pid_capture_failed' => (string) __('Failed to capture PID: %1', $result['detail'] ?? ''),
|
||||
default => (string) __('Error starting tunnel: %1', $result['error'] ?? 'unknown'),
|
||||
};
|
||||
@@ -225,6 +242,14 @@ class Index extends Action
|
||||
|
||||
private function handleStop(bool $wantJson)
|
||||
{
|
||||
if (!$this->isAllowedTunnelManage()) {
|
||||
$msg = (string) __('You are not allowed to manage tunnels.');
|
||||
if ($wantJson) {
|
||||
return $this->jsonPayload(false, $msg);
|
||||
}
|
||||
$this->messageManager->addErrorMessage($msg);
|
||||
return $this->_redirect('*/*/index');
|
||||
}
|
||||
$tunnelId = trim((string) $this->getRequest()->getParam('tunnel_id', ''));
|
||||
if ($tunnelId === '') {
|
||||
if ($wantJson) {
|
||||
@@ -260,6 +285,14 @@ class Index extends Action
|
||||
|
||||
private function handleDelete(bool $wantJson)
|
||||
{
|
||||
if (!$this->isAllowedTunnelManage()) {
|
||||
$msg = (string) __('You are not allowed to manage tunnels.');
|
||||
if ($wantJson) {
|
||||
return $this->jsonPayload(false, $msg);
|
||||
}
|
||||
$this->messageManager->addErrorMessage($msg);
|
||||
return $this->_redirect('*/*/index');
|
||||
}
|
||||
$tunnelId = trim((string) $this->getRequest()->getParam('tunnel_id', ''));
|
||||
if ($tunnelId === '') {
|
||||
if ($wantJson) {
|
||||
@@ -292,6 +325,19 @@ class Index extends Action
|
||||
|
||||
protected function _isAllowed()
|
||||
{
|
||||
return $this->_authorization->isAllowed('MageSail_Magesail::tunnel');
|
||||
return $this->isAllowedTunnelUi();
|
||||
}
|
||||
|
||||
private function isAllowedTunnelUi(): bool
|
||||
{
|
||||
return $this->_authorization->isAllowed('MageSail_Magesail::tunnel')
|
||||
|| $this->_authorization->isAllowed('MageSail_Magesail::tunnel_view')
|
||||
|| $this->_authorization->isAllowed('MageSail_Magesail::tunnel_manage');
|
||||
}
|
||||
|
||||
private function isAllowedTunnelManage(): bool
|
||||
{
|
||||
return $this->_authorization->isAllowed('MageSail_Magesail::tunnel')
|
||||
|| $this->_authorization->isAllowed('MageSail_Magesail::tunnel_manage');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MageSail\Magesail\Controller\Adminhtml\Tunnel;
|
||||
@@ -57,6 +58,8 @@ class Logtail extends Action
|
||||
|
||||
protected function _isAllowed()
|
||||
{
|
||||
return $this->_authorization->isAllowed('MageSail_Magesail::tunnel');
|
||||
return $this->_authorization->isAllowed('MageSail_Magesail::tunnel')
|
||||
|| $this->_authorization->isAllowed('MageSail_Magesail::tunnel_view')
|
||||
|| $this->_authorization->isAllowed('MageSail_Magesail::tunnel_manage');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MageSail\Magesail\Controller\Adminhtml\Tunnel;
|
||||
@@ -33,6 +34,8 @@ class Status extends Action
|
||||
|
||||
protected function _isAllowed()
|
||||
{
|
||||
return $this->_authorization->isAllowed('MageSail_Magesail::tunnel');
|
||||
return $this->_authorization->isAllowed('MageSail_Magesail::tunnel')
|
||||
|| $this->_authorization->isAllowed('MageSail_Magesail::tunnel_view')
|
||||
|| $this->_authorization->isAllowed('MageSail_Magesail::tunnel_manage');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user