Esempio n. 1
0
 private function sendRequest(MOXMAN_Util_Config $config)
 {
     $secretKey = $config->get("ExternalAuthenticator.secret_key");
     $authUrl = $config->get("ExternalAuthenticator.external_auth_url");
     $url = "";
     $defaultPort = 80;
     if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") {
         $url = "https://";
         $defaultPort = 443;
     }
     $url .= $_SERVER['HTTP_HOST'];
     if ($_SERVER['SERVER_PORT'] != $defaultPort) {
         $url .= ':' . $defaultPort;
     }
     $httpClient = new MOXMAN_Http_HttpClient($url);
     $httpClient->setProxy($config->get("general.http_proxy", ""));
     $authUrl = MOXMAN_Util_PathUtils::toAbsolute(dirname($_SERVER["REQUEST_URI"]) . '/plugins/ExternalAuthenticator', $authUrl);
     $request = $httpClient->createRequest($authUrl, "POST");
     $authUser = $config->get("ExternalAuthenticator.basic_auth_user");
     $authPw = $config->get("ExternalAuthenticator.basic_auth_password");
     if ($authUser && $authPw) {
         $request->setAuth($authUser, $authPw);
     }
     $cookie = isset($_SERVER["HTTP_COOKIE"]) ? $_SERVER["HTTP_COOKIE"] : "";
     if ($cookie) {
         $request->setHeader('cookie', $cookie);
     }
     $seed = hash_hmac('sha256', $cookie . uniqid() . time(), $secretKey);
     $hash = hash_hmac('sha256', $seed, $secretKey);
     $response = $request->send(array("seed" => $seed, "hash" => $hash));
     if ($response->getCode() < 200 || $response->getCode() > 399) {
         throw new MOXMAN_Exception("Did not get a proper http status code from Auth url: " . $url . $authUrl . ".", $response->getCode());
     }
     return $response->getBody();
 }
Esempio n. 2
0
 /**
  * Initializes the storage instance.
  *
  * @param MOXMAN_Util_Config $config Config instance.
  * @param int $type Storage type to use, can be any of the type constants.
  * @param string $name Name of the user/group if those types are used or an empty string.
  */
 public function initialize($config, $type, $name)
 {
     $this->config = $config;
     $this->type = $type;
     $this->name = $name;
     $this->pdo = new MOXMAN_Util_Pdo($config->get("sql.connection"), $config->get("sql.username"), $config->get("sql.password"), array(), $config->get("sql.table_prefix"));
     $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 }
Esempio n. 3
0
 /**
  * Initializes the storage instance.
  *
  * @param MOXMAN_Util_Config $config Config instance.
  * @param int $type Storage type to use, can be any of the type constants.
  * @param string $name Name of the user/group if those types are used or an empty string.
  */
 public function initialize($config, $type, $name)
 {
     $this->config = $config;
     $this->type = $type;
     $this->name = $name;
     $this->storagePath = MOXMAN_Util_PathUtils::combine($config->get("storage.path"), ($name ? $type . "." . $name : $type) . ".json");
 }
Esempio n. 4
0
 /**
  * Creates a config instance from the specified config. It will use various config options
  * for setting up a filter instance. This is a helper function.
  *
  * @param MOXMAN_Util_Config $config Config instance to get settings from.
  * @param String $prefix Prefix of subfilter for example "edit"
  * @return MOXMAN_Vfs_CombinedFileFilter Basic file filter instance based on config.
  */
 public static function createFromConfig(MOXMAN_Util_Config $config, $prefix)
 {
     $filter1 = new MOXMAN_Vfs_BasicFileFilter();
     $filter1->setIncludeDirectoryPattern($config->get('filesystem.include_directory_pattern'));
     $filter1->setExcludeDirectoryPattern($config->get('filesystem.exclude_directory_pattern'));
     $filter1->setIncludeFilePattern($config->get('filesystem.include_file_pattern'));
     $filter1->setExcludeFilePattern($config->get('filesystem.exclude_file_pattern'));
     $filter1->setIncludeExtensions($config->get('filesystem.extensions'));
     $filter1->setExcludeFiles($config->get('filesystem.local.access_file_name'));
     $filter2 = new MOXMAN_Vfs_BasicFileFilter();
     $filter2->setIncludeDirectoryPattern($config->get($prefix . '.include_directory_pattern'));
     $filter2->setExcludeDirectoryPattern($config->get($prefix . '.exclude_directory_pattern'));
     $filter2->setIncludeFilePattern($config->get($prefix . '.include_file_pattern'));
     $filter2->setExcludeFilePattern($config->get($prefix . '.exclude_file_pattern'));
     $filter2->setIncludeExtensions($config->get($prefix . '.extensions'));
     $filter2->setExcludeFiles($config->get($prefix . '.local.access_file_name'));
     $filter = new MOXMAN_Vfs_CombinedFileFilter();
     $filter->addFilter($filter1);
     $filter->addFilter($filter2);
     return $filter;
 }