Method that checks the access to the restricted zone

@param string $route

@throws AccessDeniedException
@throws AdminCredentialsException
546046
public static function checkRestrictedAccess($route)
    {
        Logger::log('Checking admin zone');
        //Chequeamos si entramos en el admin
        if (!Config::getInstance()->checkTryToSaveConfig()
            && (preg_match('/^\/(admin|setup\-admin)/i', $route) || Config::getParam('restricted', false))
        ) {
            if (!self::isTest() &&
                null === Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true)) {
                throw new AdminCredentialsException();
            }
            if (!Security::getInstance()->checkAdmin()) {
                throw new AccessDeniedException();
            }
            Logger::log('Admin access granted');
        }
    }
389984
protected function accessDenied(?string $message=NULL) {
		
		$this->enqueueError(($message ? $message : $this->translator->get('ACCESS_DENIED')));
		$this->redirect(strtolower($this->name));
		
	}
947537
protected function controlAccessRestrictedArea()
    {
        if (($this->is_backend || $this->url->isAccount()) && empty($this->uid)) {
            $this->url->redirect('login', array('target' => $this->path));
        }
    }
1271894
public function execute($command, callable $next)
    {
        if ($this->authorizationChecker->isGranted('handle', $command)) {
            return $next($command);
        }

        throw new AccessDeniedException(
            sprintf('The current user is not allowed to handle command of type \'%s\'', get_class($command))
        );
    }
740089
private function checkPermission($permission)
    {
        if (!$permission)
        {
            return;
        }

        $user = $this->securityApi->getUser(true);
        if ($user instanceof Permissible && $user->hasAccess($permission))
        {
            return;
        }

        throw Unauthorized::permissionDenied($permission, $this->securityApi);
    }
196862
protected function guard(Context $context)
    {
        $this->logger->debug('kernel.guard: check user rank');

        // 401
        if($context->logic->access and $context->logic->access > Auth::rank()) {
            throw new AccessDeniedException('Access denied (#' . $context->logic->name . ': ' . $context->logic->access . ', user: ' . $context->logic->access . ')');
        }

        // set user
        if(Auth::valid()) {
            $context->user = Auth::user();
        }

        $this->logger->debug('kernel.guard: access granted (#' . $context->logic->name . ': ' . $context->logic->access . ', user: ' . $context->logic->access . ')');

        return $context;
    }
1005921
public static function post($route)
    {
        $content = self::traitPost($route);
        //
        self::addRoute($content);

        return true;
    }
811747
def check_permission_to_route
      route_provider = RouteProvider.new(self.class)

      if route_provider.verifiable_routes_list.include?(current_action)
        if logged_user.nil?
          raise UserNotLoggedInException.new(current_route, nil)
        end

        is_permitted = AccessProvider.action_permitted_for_user?(
          current_route, logged_user
        )

        is_permitted ? allow_route : deny_route
      elsif route_provider.non_verifiable_routes_list.include?(current_action)
        allow_route
      else
        deny_route
      end
    end
1312613
protected function _execute($route) {
		Permit::$executed = $this->executed = $route;

		if (empty($route['rules'])) {
			return false;
		}

		if (isset($route['rules']['deny'])) {
			return $route['rules']['deny'] == true;
		}

		if (!isset($route['rules']['auth'])) {
			return false;
		}

		if (is_bool($route['rules']['auth'])) {
			$isAuthed = $this->Session->read("{$this->settings['path']}.{$this->settings['check']}");

			if ($route['rules']['auth'] == true && !$isAuthed) {
				return true;
			}

			if ($route['rules']['auth'] == false && $isAuthed) {
				return true;
			}

			return false;
		} elseif (!is_array($route['rules']['auth'])) {
			return false;
		}

		if ($this->user == false) {
			return true;
		}

		$fieldsBehavior = 'and';
		if (!empty($route['rules']['fields_behavior'])) {
			$fieldsBehavior = strtolower($route['rules']['fields_behavior']);
		}

		if (!in_array($fieldsBehavior, array('and', 'or'))) {
			$fieldsBehavior = 'and';
		}

		$count = count(Set::flatten($route['rules']['auth']));
		foreach ($route['rules']['auth'] as $path => $condition) {
			$path = '/' . str_replace('.', '/', $path);
			$path = preg_replace('/^([\/]+)/', '/', $path);

			$check = $condition;
			$continue = false;
			$decrement = 1;
			$values = Set::extract($path, $this->user);

			// Support for OR Model-syntax
			foreach (array('or', 'OR') as $anOr) {
				if (is_array($condition) && array_key_exists($anOr, $condition)) {
					$check = $condition[$anOr];
					$continue = true;
					$decrement = count($check);
				}
			}

			if ($fieldsBehavior == 'or') {
				$check = $condition;
				$continue = true;
				$decrement = count($check);
			}

			foreach ((array)$check as $cond) {
				if (in_array($cond, (array)$values)) {
					$count -= $decrement;
					if ($continue) {
						continue 2;
					}
				}
			}
		}

		return $count !== 0;
	}
1242159
public function add( Route $route ){
		$routeId	= $route->getId();
		if( array_key_exists( $routeId, $this->routes ) ){
			throw new \DomainException( sprintf(
				'A route for pattern and method is already registered: %2$s %1$s',
				$route->getPattern(),
				$route->getMethod()
			) );
		}
		$this->routes[$routeId]	= $route;
		return $routeId;
	}
913188
private function isAllowedByRole(array $route)
    {
        if (empty($route['allow']['roles'])) {
            return true;
        }

        // @codeCoverageIgnoreStart
        // @TODO This works but not in a unit test.
        if (null === $this->auth) {
            $this->auth = Auth::getInstance();
        }

        $roles = $route['allow']['roles'];
        $pieces = explode('|', $roles);

        foreach ($pieces as $piece) {
            if ($this->auth->hasRole($piece)) {
                return true;
            }
        }

        return false;
        // @codeCoverageIgnoreEnd
    }
1352174
public function manageGlobalAction(Request $request)
    {
        $securitySettings = $this->container->getParameter('settings_manager.security');

        if (!empty($securitySettings['manage_global_settings_role']) &&
            !$this->getAuthorizationChecker()->isGranted($securitySettings['manage_global_settings_role'])
        ) {
            throw new AccessDeniedException(
                $this->container->get('translator')->trans(
                    'not_allowed_to_edit_global_settings',
                    array(),
                    'settings'
                )
            );
        }

        return $this->manage($request);
    }
531054
protected function controlRouteAccess()
    {
        if (!$this->config->get('cli_status', true)) {
            $this->errorAndExit($this->text('No access'));
        }

        $this->controlAccess('cli');

        if (isset($this->current_route['access'])) {
            $this->controlAccess($this->current_route['access']);
        }
    }
620009
public function toRoute($route)
	{
		if ($this->caller != null)
			$this->disableRender[] = $this->caller->identifier;
		$r = $this->router->getRoute($route);
		if ($r != null) {
			$this->currentRoute = $r;
			try {
				$this->execute();
			} catch (\Exception $e) {
				Logger::Log('log/error.txt', $e->getMessage());
				\decoy\base\ErrorController::$errors[] = $e->getMessage();
				$this->toRoute('error_page');
			}
		}
		$this->caller = null;
	}
647915
function isAllowed(/*iAuthResource*/ $resource = null, /*iIdentity*/ $role = null)
    {
        $role = ($role) ?: $this->identity();

        if (!is_object($resource)
            || (!$resource instanceof PermResource || !method_exists($resource, 'getRouteMatch'))
        )
            throw new \Exception('Invalid Resource Type, Can`t Check The Permissions.');

        $return = true;

        $matchedRouteName = $resource->getRouteMatch()->getMatchedRouteName();

        // Access Admin Route Need Authorized User
        if ($matchedRouteName == \yimaAdminor\Module::ADMIN_ROUTE_NAME)
            $return = $return && $role->hasAuthenticated();

        return $return;
    }
853857
public function set($route = null)
    {
        if (!isset($route)) {

            $routes = $this->getList();
            $command = array_shift($this->params);

            if (isset($this->aliases[$command])) {
                $command = $this->aliases[$command];
            }

            if (empty($routes[$command])) {
                $command = 'help';
                $this->params = array();
            }

            if (empty($routes[$command])) {
                throw new OutOfBoundsException('Unknown command');
            }

            if (isset($routes[$command]['status']) && empty($routes[$command]['status'])) {
                throw new OutOfBoundsException('Disabled command');
            }

            $route = $routes[$command];
            $route['command'] = $command;
            $route['params'] = $this->params;
        }

        $this->route = (array) $route;
        return $this;
    }
1357003
private function extractPermissionFrom(Route $route)
    {
        $parameters = $route->getAction();

        if (isset($parameters['permission']))
        {
            return $parameters['permission'];
        }

        return null;
    }