/** * Check authentication. Different backends may handle * authentication in different ways. The base class implementation * checks for HTTP Authentication against the Horde auth setup. * * @return boolean Returns true if authentication is successful. * Should send appropriate "not authorized" headers * or other response codes/body if auth fails, * and take care of exiting. */ public function authorize() { $this->_logger->debug('Horde_Rpc::authorize() starting'); if (!$this->_requireAuthorization) { return true; } // @TODO: inject this $auth = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create(); $serverVars = $this->_request->getServerVars(); if (!empty($serverVars['PHP_AUTH_USER'])) { $user = $serverVars['PHP_AUTH_USER']; $pass = $serverVars['PHP_AUTH_PW']; } elseif (!empty($serverVars['Authorization'])) { $hash = str_replace('Basic ', '', $serverVars['Authorization']); $hash = base64_decode($hash); if (strpos($hash, ':') !== false) { list($user, $pass) = explode(':', $hash, 2); } } if (!isset($user) || !$auth->authenticate($user, array('password' => $pass))) { if ($this->_requestMissingAuthorization) { header('WWW-Authenticate: Basic realm="Horde RPC"'); } header('HTTP/1.0 401 Unauthorized'); echo '401 Unauthorized'; exit; } $this->_logger->debug('Horde_Rpc::authorize() exiting'); return true; }
/** * Obtain the access token. This is the token that should be persisted to * storage. * * @param Horde_Controller_Request_Http Http request object * @param string $requestSecret The token secret returned by * Twitter after the user authorizes * the application. * @return Horde_Oauth_Token * @throws Horde_Service_Twitter_Exception */ public function getAccessToken(Horde_Controller_Request_Http $request, $requestSecret = null) { if (!empty($this->_token)) { return $this->_token; } $params = $request->getGetVars(); if (empty($params['oauth_token'])) { return false; } $token = new Horde_Oauth_Token($params['oauth_token'], $requestSecret); try { return $this->oauth->getAccessToken($token, array('oauth_verifier' => $requestSecret)); } catch (Horde_Oauth_Exception $e) { throw new Horde_Service_Twitter_Exception($e->getMessage()); } }
* * See the enclosed file LICENSE for license information (BSD). If you did * did not receive this file, see http://cvs.horde.org/co.php/jonah/LICENSE. * * @author Ben Klang <*****@*****.**> */ require_once __DIR__ . '/lib/Application.php'; $jonah = Horde_Registry::appInit('jonah', array('authentication' => 'none', 'session_control' => 'readonly')); $m = new Horde_Routes_Mapper(); require JONAH_BASE . '/config/routes.php'; if (file_exists(JONAH_BASE . '/config/routes.local.php')) { include JONAH_BASE . '/config/routes.local.php'; } $templates = Horde::loadConfiguration('templates.php', 'templates', 'jonah'); // Grab, and hopefully match, the URL $request = new Horde_Controller_Request_Http(); $url = $request->getPath(); $args = $request->getGetParams(); $result = $m->match('/' . $url); $criteria = array(); // @TODO: This should be handled by controller objects, but for now just use // a switch conditional until we move to Horde_Controller switch ($result['controller']) { case 'admin': // TODO: exit; case 'feed': // Default settings $defaults = array('format' => 'html', 'feed' => $result['feed']); // Check for the format specification if ($pos = strrpos($result['feed'], '.')) {
public function create(Horde_Injector $injector) { $request = new Horde_Controller_Request_Http(); $request->setPath(isset($_SERVER['REDIRECT_URL']) ? $_SERVER['REDIRECT_URL'] : $_SERVER['REQUEST_URI']); return $request; }