/** * @return LoginProviderEntity * @throws \Nette\InvalidStateException * @throws \Nette\InvalidArgumentException */ protected function createLoginProviderEntity() { $type = $this->getOpauthType(); $params = array('path' => $this->getCallbackUrl(), 'callback_url' => $this->getCallbackUrl(), 'Strategy' => array($type => $this->getConfig())); Debugger::$maxLen = 10000; $this->opauth = new Opauth($params, FALSE); $this->opauth->strategy = Strings::lower($type); $response = null; switch ($this->opauth->env['callback_transport']) { case 'session': $response = $_SESSION['opauth']; unset($_SESSION['opauth']); break; case 'post': $response = unserialize(base64_decode($_POST['opauth'])); break; case 'get': $response = unserialize(base64_decode($_GET['opauth'])); break; default: throw new InvalidArgumentException("Unsupported callback transport."); break; } if ($response === NULL) { if (isset($_GET['_opauth_action'])) { $action = explode('/', $_GET['_opauth_action']); $this->opauth->action = $action[1]; } $this->opauth->run(); } if (array_key_exists('error', $response)) { throw new InvalidStateException($response['error']['message']); } if (empty($response['auth']) || empty($response['timestamp']) || empty($response['signature']) || empty($response['auth']['provider']) || empty($response['auth']['uid'])) { throw new InvalidStateException('Invalid auth response: Missing key auth response components'); } elseif (!$this->opauth->validate(sha1(print_r($response['auth'], true)), $response['timestamp'], $response['signature'], $reason)) { throw new InvalidStateException('Invalid auth response: ' . $reason); } $ret = new LoginProviderEntity($response['auth']['uid'], static::getType()); $this->fillLoginEntity($ret, $response['auth']['raw']); return $ret; }
* * Copyright (c) 2006, 2011 Patrik Votoček (http://patrik.votocek.cz) * * This source file is subject to the GNU Lesser General Public License. For more information please see http://nella-project.org */ use Nette\Diagnostics\Debugger; // Load and init Nette Framework if (!defined('NETTE')) { require_once __DIR__ . "/../Nette/loader.php"; } // Set debug options Debugger::$strictMode = TRUE; Debugger::$maxLen = 4096; /** * Load and configure Nella Framework */ define('NELLA_FRAMEWORK', TRUE); define('NELLA_FRAMEWORK_DIR', __DIR__); define('NELLA_FRAMEWORK_VERSION_ID', 20000); // v2.0.0 require_once __DIR__ . "/SplClassLoader.php"; Nella\SplClassLoader::getInstance(array( 'Nella' => NELLA_FRAMEWORK_DIR, 'Doctrine' => __DIR__ . "/../Doctrine", 'Symfony' => __DIR__ . "/../Symfony", ))->register();