Skip to content

Commit

Permalink
Security Suite Error Page and early detection
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenix128 committed Jun 1, 2017
1 parent a1c9d72 commit f5cbb6d
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 118 deletions.
88 changes: 0 additions & 88 deletions Observer/ControllerActionPredispatchObserver.php

This file was deleted.

107 changes: 107 additions & 0 deletions Plugin/AppInterfacePlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?php
/**
* MageSpecialist
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @category MSP
* @package MSP_AdminRestriction
* @copyright Copyright (c) 2017 Skeeller srl (http://www.magespecialist.it)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

namespace MSP\AdminRestriction\Plugin;

use Magento\Framework\App\State;
use Magento\Framework\AppInterface;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\App\Response\Http;
use Magento\Framework\UrlInterface;
use MSP\AdminRestriction\Api\RestrictInterface;
use MSP\SecuritySuiteCommon\Api\LogManagementInterface;
use Magento\Framework\Event\ManagerInterface as EventInterface;
use MSP\SecuritySuiteCommon\Api\UtilsInterface;

class AppInterfacePlugin
{
/**
* @var RequestInterface
*/
private $request;

/**
* @var Http
*/
private $http;

/**
* @var UrlInterface
*/
private $url;

/**
* @var State
*/
private $state;

/**
* @var EventInterface
*/
private $event;

/**
* @var RestrictInterface
*/
private $restrict;
/**
* @var UtilsInterface
*/
private $utils;


public function __construct(
RequestInterface $request,
Http $http,
UrlInterface $url,
State $state,
EventInterface $event,
RestrictInterface $restrict,
UtilsInterface $utils
) {
$this->request = $request;
$this->http = $http;
$this->url = $url;
$this->state = $state;
$this->restrict = $restrict;
$this->event = $event;
$this->utils = $utils;
}

public function aroundLaunch(AppInterface $subject, \Closure $proceed)
{
if ($this->utils->isBackendUri()) {
if (!$this->restrict->isAllowed()) {
$this->event->dispatch(LogManagementInterface::EVENT_ACTIVITY, [
'module' => 'MSP_AdminRestriction',
'message' => 'Unauthorized access attempt',
]);

$this->state->setAreaCode('frontend');
$this->http->setRedirect($this->url->getUrl('msp_security_suite/stop', [
'reason' => 'Unauthorized access attempt',
]));
return $this->http;
}
}

return $proceed();
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"require": {
"php": "~7.0.0",
"msp/common": "*",
"msp/security-suite-common": "*",
"msp/security-suite-common": ">=1.0.3",

"magento/magento-composer-installer": "*"
},
Expand Down
28 changes: 0 additions & 28 deletions etc/adminhtml/events.xml

This file was deleted.

4 changes: 4 additions & 0 deletions etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@
</argument>
</arguments>
</type>
<type name="Magento\Framework\AppInterface">
<plugin sortOrder="1" name="mSPAdminRestrictionAppInterface"
type="MSP\AdminRestriction\Plugin\AppInterfacePlugin"/>
</type>
</config>
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="MSP_AdminRestriction" setup_version="1.0.0">
<module name="MSP_AdminRestriction" setup_version="1.0.1">
<sequence>
<module name="MSP_Common"/>
<module name="MSP_SecuritySuiteCommon"/>
Expand Down

0 comments on commit f5cbb6d

Please sign in to comment.