request = $request; $this->router = $router; $this->storeManager = $storeManager; $this->authorization = $authorization; } /** * Validate request * * @throws AuthorizationException * @throws \Magento\Framework\Webapi\Exception * @return void */ public function validate() { $this->checkPermissions(); $route = $this->router->match($this->request); if ($route->isSecure() && !$this->request->isSecure()) { throw new \Magento\Framework\Webapi\Exception(__('Operation allowed only in HTTPS')); } } /** * Perform authentication and authorization. * * @throws \Magento\Framework\Exception\AuthorizationException * @return void */ private function checkPermissions() { $route = $this->router->match($this->request); if (!$this->authorization->isAllowed($route->getAclResources())) { $params = ['resources' => implode(', ', $route->getAclResources())]; throw new AuthorizationException( __(AuthorizationException::NOT_AUTHORIZED, $params) ); } } }