/** * Returns all auth keys for the users ignoring any given API key(s). * * @param string|array $excluded_api_keys The ignored API key(s) * @return Doctrine_Collection */ public function getAuthKeysExcluding($excluded_api_keys) { if (!is_array($excluded_api_keys)) { $excluded_api_keys = array($excluded_api_keys); } $auth_keys = sfGuardUserAuthKeyTable::getInstance()->getKeysByUserIdExcludingApiKeys($this->getIncremented(), $excluded_api_keys); return $auth_keys; }
protected function execute($arguments = array(), $options = array()) { // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'])->getConnection(); $quiet = (bool) $options['quiet']; if (!$quiet) { echo "Removing old authorization failures..."; } AuthFailureTable::getInstance()->cleanUpOldFailures(); if (!$quiet) { echo "\nRemoving expired API user authorization tokens..."; } sfGuardUserAuthKeyTable::getInstance()->cleanUpTokens(); if (!$quiet) { echo "\n"; } }
public function getGuardUser() { if ($this->user) { return $this->user; } if (self::apiIsAuthorized() && $this->getAttribute('auth_key')) { $api = ApiKeyTable::getInstance()->findOneByApiKey($this->getAttribute('api_key')); $auth_key = $this->getAttribute('auth_key'); $user_auth = sfGuardUserAuthKeyTable::getInstance()->getMostRecentValidByApiKeyIdAndAuthKey($api->getIncremented(), $auth_key); if ($user_auth instanceof sfGuardUserAuthKey) { $this->user = $user_auth->getSfGuardUser(); $this->setAuthenticated(true); $this->clearCredentials(); $this->addCredentials($this->user->getAllPermissionNames()); return $this->user; } } return null; }
/** * Signs out the user. * */ public function signOut() { $auth_key = $this->getApiAuthKey(); $this->getAttributeHolder()->removeNamespace('sfGuardSecurityUser'); $this->user = null; $this->_user_id = null; $this->clearCredentials(); $this->setAuthenticated(false); $api_key = sfConfig::get('app_web_app_api_key'); $api = ApiKeyTable::getInstance()->findOneBy('api_key', $api_key); $auth_key = sfGuardUserAuthKeyTable::getInstance()->getMostRecentValidByApiKeyIdAndAuthKey($api->getIncremented(), $auth_key); if ($auth_key) { $auth_key->delete(); } $expiration_age = sfConfig::get('app_sf_guard_plugin_remember_key_expiration_age', 15 * 24 * 3600); $remember_cookie = sfConfig::get('app_sf_guard_plugin_remember_cookie_name', 'sfRemember'); sfContext::getInstance()->getResponse()->setCookie($remember_cookie, '', time() - $expiration_age); }
/** * Tests for success at creating the object. */ public function testCreate() { $t = sfGuardUserAuthKeyTable::getInstance(); $this->assertTrue($t instanceof Doctrine_Table); }