/**
  * Replace standard admin login form with HTTP Basic authentication
  *
  * @param AbstractAction $subject
  * @param callable $proceed
  * @param RequestInterface $request
  * @return ResponseInterface
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function aroundDispatch(AbstractAction $subject, \Closure $proceed, RequestInterface $request)
 {
     $resource = isset($this->aclResources[$request->getControllerName()]) ? isset($this->aclResources[$request->getControllerName()][$request->getActionName()]) ? $this->aclResources[$request->getControllerName()][$request->getActionName()] : $this->aclResources[$request->getControllerName()] : null;
     $type = $request->getParam('type');
     $resourceType = isset($this->aclResources[$type]) ? $this->aclResources[$type] : null;
     if (!$resource || !$resourceType) {
         return parent::aroundDispatch($subject, $proceed, $request);
     }
     $session = $this->_auth->getAuthStorage();
     // Try to login using HTTP-authentication
     if (!$session->isLoggedIn()) {
         list($login, $password) = $this->httpAuthentication->getCredentials();
         try {
             $this->_auth->login($login, $password);
         } catch (AuthenticationException $e) {
             $this->logger->critical($e);
         }
     }
     // Verify if logged in and authorized
     if (!$session->isLoggedIn() || !$this->authorization->isAllowed($resource) || !$this->authorization->isAllowed($resourceType)) {
         $this->httpAuthentication->setAuthenticationFailed('RSS Feeds');
         return $this->_response;
     }
     return parent::aroundDispatch($subject, $proceed, $request);
 }
Esempio n. 2
0
 /**
  * Get wizard step by request
  *
  * @param   \Magento\Framework\App\RequestInterface $request
  * @return  \Magento\Framework\Object|bool
  */
 public function getStepByRequest(\Magento\Framework\App\RequestInterface $request)
 {
     foreach ($this->_steps as $step) {
         if ($step->getController() == $request->getControllerName() && $step->getAction() == $request->getActionName()) {
             return $step;
         }
     }
     return false;
 }
Esempio n. 3
0
 /**
  * Match controller name
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @param string $param
  * @return string
  */
 protected function matchActionPath(\Magento\Framework\App\RequestInterface $request, $param)
 {
     if ($request->getControllerName()) {
         $actionPath = $request->getControllerName();
     } elseif (!empty($param)) {
         $actionPath = $param;
     } else {
         $actionPath = $this->_defaultPath->getPart('controller');
         $request->setAlias(\Magento\Framework\Url::REWRITE_REQUEST_PATH_ALIAS, ltrim($request->getOriginalPathInfo(), '/'));
     }
     return $actionPath;
 }
Esempio n. 4
0
 /**
  * Retrieve the controller name
  *
  * @return string
  */
 protected function getController()
 {
     return $this->request->getControllerName();
 }
 /**
  * Return whether page is tax configuration
  *
  * @return bool
  */
 protected function isTaxConfigPage()
 {
     return $this->request->getModuleName() == 'admin' && $this->request->getControllerName() == 'system_config' && $this->request->getActionName() == 'edit' && $this->request->getParam('section') == 'tax';
 }
 /**
  * Return whether page is queue page
  *
  * @return bool
  */
 protected function isQueuePage()
 {
     return $this->request->getModuleName() == 'avatax' && $this->request->getControllerName() == 'queue' && $this->request->getActionName() == 'index';
 }