public function setAuthMode($mode)
    {
        if (!class_exists($mode)) {
            throw new \Exception(sprintf(
                "Class %s doesn't exists",
                $mode
            ));
        }

        $this->authMode = $mode;

        $authClass = is_string($mode) ? new $mode() : $mode;
        if (!$authClass instanceof SecurityInterface) {
            throw new \Exception(sprintf(
                'Auth mode must be intstance of %s',
                SecurityInterface::class
            ));
            exit;
        }

        $this->security = $authClass;
        $this->authMode = get_class($this->security);

        if ($this->authDir) {
            $this->security->setPath($this->authDir);
        }
    }