public function authenticate(MOXMAN_Auth_User $user) { $config = MOXMAN::getConfig(); $session = new CI_Session(); // Check logged in key $sessionValue = $session->userdata($config->get("CodeIgniterAuthenticator.logged_in_key", "loggedin")); if (!$sessionValue || $sessionValue === "false") { return false; } // Extend config with session prefixed sessions $sessionConfig = array(); $configPrefix = $config->get("CodeIgniterAuthenticator.config_prefix", "moxiemanager"); if ($configPrefix) { $allData = $session->all_userdata(); foreach ($allData as $key => $value) { if (strpos($key, $configPrefix) === 0) { $sessionConfig[substr($key, strlen($configPrefix) + 1)] = $value; } } } // Extend the config with the session config $config->extend($sessionConfig); // Replace ${user} with all config items $key = $config->get("CodeIgniterAuthenticator.user_key"); if ($key) { $value = $session->userdata($key); $config->replaceVariable("user", $value); $user->setName($value); } return true; }
public function authenticate(MOXMAN_Auth_User $user) { $config = MOXMAN::getConfig(); $session = MOXMAN_Http_Context::getCurrent()->getSession(); // Check logged in key $sessionValue = $session->get($config->get("SessionAuthenticator.logged_in_key"), false); if (!$sessionValue || $sessionValue === "false") { return false; } // Extend config with session prefixed sessions $sessionConfig = array(); $configPrefix = $config->get("SessionAuthenticator.config_prefix"); if ($configPrefix) { foreach ($_SESSION as $key => $value) { if (strpos($key, $configPrefix) === 0) { $sessionConfig[substr($key, strlen($configPrefix) + 1)] = $value; } } } // Extend the config with the session config $config->extend($sessionConfig); // Replace ${user} with all config items $key = $config->get("SessionAuthenticator.user_key"); if ($key && isset($_SESSION[$key])) { $config->replaceVariable("user", $session->get($key)); $user->setName($session->get($key)); } // The user is authenticated so let them though return true; }
public function authenticate(MOXMAN_Auth_User $user) { $sessionContainerName = MOXMAN::getConfig()->get("ZendAuthenticator.session_container"); if ($sessionContainerName) { $session = new Zend\Session\Container($sessionContainerName); } else { $session = new Zend\Session\Container(); } $config = MOXMAN::getConfig(); $loggedInKey = $config->get("ZendAuthenticator.logged_in_key", "loggedin"); if (isset($session->{$loggedInKey}) && ($session->{$loggedInKey} === true || strtolower($session->{$loggedInKey}) === "true")) { // Extend config with session prefixed sessions $sessionConfig = array(); $configPrefix = $config->get("ZendAuthenticator.config_prefix"); if ($configPrefix) { foreach ($session as $key => $value) { if (strpos($key, $configPrefix) === 0) { $sessionConfig[substr($key, strlen($configPrefix) + 1)] = $value; } } } // Extend the config with the session config $config->extend($sessionConfig); // Replace ${user} with all config items $key = $config->get("ZendAuthenticator.user_key"); if ($key && isset($session->{$key})) { $config->replaceVariable("user", $session->{$key}); $user->setName($session->{$key}); } return true; } return false; }
private function updateUserAndConfig($result, MOXMAN_Auth_User $user, MOXMAN_Util_Config $config) { if ($result["user"]) { $config->replaceVariable("user", $result["user"]); $user->setName($result["user"]); } $config->extend($result["config"]); }
public function authenticate(MOXMAN_Auth_User $user) { $config = MOXMAN::getConfig(); if (!isLogged()) { return false; } $s = getUsername(); $sPath = BX_DIRECTORY_PATH_ROOT . 'media/moxie/files/' . substr($s, 0, 1) . '/' . substr($s, 0, 2) . '/' . substr($s, 0, 3) . '/' . $s; bx_mkdir_r($sPath); $config->put('filesystem.rootpath', $sPath); $config->replaceVariable("user", $s); $user->setName($s); return true; }
public function login(MOXMAN_Auth_User $user) { $config = MOXMAN::getConfig(); foreach ($config->get('basicauthenticator.users') as $userItem) { if ($userItem["username"] == $user->getName() && $userItem["password"] == $user->getPassword()) { if ($user->isPersistent()) { setcookie("moxmanauth", hash("sha256", $userItem["username"] . $userItem["password"] . $config->get('general.license'))); } else { $_SESSION["moxman_authUser"] = $user->getName(); } return true; } } return false; }
public function login(MOXMAN_Auth_User $user) { $config = MOXMAN::getConfig(); foreach ($config->get('basicauthenticator.users') as $userItem) { if ($userItem["username"] == $user->getName() && $userItem["password"] == $user->getPassword()) { if ($user->isPersistent()) { $this->updateCookie($userItem); } else { $_SESSION["moxman_authUser"] = $user->getName(); } return true; } } return false; }
public function authenticate(MOXMAN_Auth_User $user) { $config = MOXMAN::getConfig(); // Load environment and session logic if (!$this->isSessionLoaded) { $kernel = new AppKernel($config->get("SymfonyAuthenticator.environment", "prod"), false); $kernel->loadClassCache(); $request = Request::createFromGlobals(); $kernel->handle($request); $this->isSessionLoaded = true; } // Get all session data $session = new Session(); $session = $session->all(); // Check logged in key $loggedInKey = $config->get("SymfonyAuthenticator.logged_in_key", "isLoggedIn"); $sessionValue = isset($session[$loggedInKey]) ? $session[$loggedInKey] : false; if (!$sessionValue || $sessionValue === "false") { return false; } // Extend config with session prefixed sessions $sessionConfig = array(); $configPrefix = $config->get("SymfonyAuthenticator.config_prefix", "moxiemanager"); if ($configPrefix) { foreach ($session as $key => $value) { if (strpos($key, $configPrefix) === 0) { $sessionConfig[substr($key, strlen($configPrefix) + 1)] = $value; } } } // Extend the config with the session config $config->extend($sessionConfig); // Replace ${user} with all config items $key = $config->get("SessionAuthenticator.user_key", "user"); if ($key && isset($session[$key])) { $config->replaceVariable("user", $session[$key]); $user->setName($session[$key]); } return true; }
public function authenticate(MOXMAN_Auth_User $user) { $config = MOXMAN::getConfig(); $configPrefix = "moxiemanager"; $authUserKey = "moxiemanager.auth.user"; // Use cached auth state valid for 5 minutes if (isset($_SESSION["moxiemanager.authtime"]) && time() - $_SESSION["moxiemanager.authtime"] < 60 * 5) { // Extend config with session prefixed sessions $sessionConfig = array(); if ($configPrefix) { foreach ($_SESSION as $key => $value) { if (strpos($key, $configPrefix) === 0) { $sessionConfig[substr($key, strlen($configPrefix) + 1)] = $value; } } } $config->extend($sessionConfig); if (isset($_SESSION[$authUserKey])) { $config->replaceVariable("user", $_SESSION[$authUserKey]); $user->setName($_SESSION[$authUserKey]); } return true; } $secretKey = $config->get("ExternalAuthenticator.secret_key"); $authUrl = $config->get("ExternalAuthenticator.external_auth_url"); if (!$secretKey || !$authUrl) { throw new MOXMAN_Exception("No key/url set for ExternalAuthenticator, check config."); } // Build url if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") { $url = "https://"; } else { $url = "http://"; } $url .= $_SERVER['HTTP_HOST']; if ($_SERVER['SERVER_PORT'] != 80) { $url .= ':' . $_SERVER['SERVER_PORT']; } $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()); } $json = json_decode($response->getBody(), true); if (!$json) { throw new MOXMAN_Exception("Did not get a proper JSON response from Auth url."); } if (isset($json["result"])) { foreach ($json["result"] as $key => $value) { $config->put($key, $value); $_SESSION["moxiemanager." . $key] = $value; } if (isset($json["result"][$authUserKey])) { $config->replaceVariable("user", $json["result"][$authUserKey]); $user->setName($json["result"][$authUserKey]); } $_SESSION["moxiemanager.authtime"] = time(); return true; } else { if (isset($json["error"])) { throw new MOXMAN_Exception($json["error"]["message"] . " - " . $json["error"]["code"]); } else { throw new MOXMAN_Exception("Generic unknown error, did not get a proper JSON response from Auth url."); } } }