public function setAuthDir($dir)
    {
        if (!file_exists($dir)) {
            throw new \Exception('Auth directory is not exists!');
        }

        if (!is_dir($dir)) {
            throw new \Exception('Auth directory is not exists!');
        }

        if ($this->security && $this->security->getKey()) {
            throw new \Exception('Auth directory must be set before key sets!');
        }

        $this->authDir = $dir;
        $this->security->setPath($dir);
    }