Beispiel #1
0
 public function setParam(Zend_Auth_Adapter_Interface $adapter)
 {
     $results = $adapter->getResultRowObject();
     $this->login = $results->login;
     $this->pass = $results->pass;
     $this->role = $results->role;
 }
 /**
  * Authenticates against the supplied adapter
  *
  * @param  Zend_Auth_Adapter_Interface $adapter
  * @return Zend_Auth_Result
  */
 public function authenticate(Zend_Auth_Adapter_Interface $adapter, $authProviderKey, $protectCode = null)
 {
     $result = $adapter->authenticate();
     if ($result->isValid()) {
         $this->getStorage()->write(array($result->getIdentity(), $authProviderKey, $protectCode));
     }
     return $result;
 }
Beispiel #3
0
 public function authenticate(Zend_Auth_Adapter_Interface $adapter)
 {
     $result = $adapter->authenticate();
     if ($result->isValid()) {
         $this->_identity = $adapter->getResultRowObject(null, 'password');
         $storage = $this->getStorage();
         $zadmin_auth = $storage->create();
         $storage->write($this->_identity);
         Zing_Cookies::createCookies(self::COOKIE_ADMIN_AUTH_KEY, $zadmin_auth, 0);
     }
     return $result;
 }
Beispiel #4
0
 /**
  * Authenticates against the supplied adapter.
  *
  * @param Zend_Auth_Adapter_Interface $adapter The adapter to use
  * @return Zend_Auth_Result
  * @see http://framework.zend.com/manual/1.12/en/zend.auth.introduction.html#zend.auth.introduction.adapters Zend_Auth_Adapter_Interface
  * @see http://framework.zend.com/manual/1.12/en/zend.auth.introduction.html#zend.auth.introduction.results Zend_Auth_Result
  */
 public function authenticate(Zend_Auth_Adapter_Interface $adapter)
 {
     // Authenticates against the supplied adapter.
     $result = $adapter->authenticate();
     /*
      * ZF-7546 - prevent multiple succesive calls from storing inconsistent
      * results.
      *
      * Ensure storage has clean state.
      */
     if ($this->hasIdentity()) {
         $this->clearIdentity();
     }
     if ($result->isValid()) {
         $this->getStorage()->write($adapter->getResultRowObject());
     }
     return $result;
 }
Beispiel #5
0
 public function reauthenticate(Zend_Auth_Adapter_Interface $adapter, $id)
 {
     $result = $adapter->reauthenticate($id);
     if ($result->isValid()) {
         require_once 'Zend/Session.php';
         Zend_Session::regenerateId();
         $user = $adapter->getResultRowObject();
         $this->getStorage()->write($user->name);
         $this->getStorage()->writeData($user);
         $this->getStorage()->writeExpires(time() + $this->_lifetime);
         $this->getStorage()->writeIpAddress($_SERVER['REMOTE_ADDR']);
         require_once 'Zend/Date.php';
         $date = new Zend_Date();
         $date->setTimezone('UTC');
         $now = $date->get(Zend_Date::ISO_8601);
         $data = array('lastLogin' => $now, 'lastRequest' => $now);
         $adapter->update($user->id, $data);
     }
     return $result;
 }
 /**
  * Get service object instance
  *
  * @param Zend_Config $config
  * @return Zend_Auth_Adapter_Interface
  */
 public function &getService(Zend_Config $config)
 {
     if (!$this->service) {
         $className = "Auth_Adapter_" . $config->class;
         switch ($config->class) {
             default:
                 $this->service = new $class();
                 break;
             case "Db":
                 try {
                     $this->service = new Zend_Auth_Adapter_DbTable(Zoo::getService('db')->getDb('slave'));
                     $this->service->setTableName('Auth_User')->setIdentityColumn('username')->setCredentialColumn('password')->setCredentialTreatment('md5(CONCAT(salt, ?)) AND status > 0');
                 } catch (Zoo_Exception_Service $e) {
                     // Revert to Basic authentication
                     $this->service = new Auth_Adapter_Basic();
                 }
         }
     }
     return $this->service;
 }
Beispiel #7
0
 /**
  * Authenticates against the supplied adapter
  *
  * @param  string $username
  * @param  string $password
  * @return Zend_Auth_Result
  */
 public function authenticate($username, $password)
 {
     // Get a reference to the singleton instance of Zend_Auth
     $this->_auth = Zend_Auth::getInstance();
     // Set the storage interface
     $this->_auth->setStorage(new Glo_Auth_Storage_Session('Glo_Auth'));
     // Set the identity on the adapter
     $this->_adapter->setIdentity($username);
     // Set the credential on the adapter
     $this->_adapter->setCredential($password);
     // Attempt authentication, saving the result
     $result = $this->_auth->authenticate($this->_adapter);
     if (!$result->isValid()) {
         // Authentication failed
         throw new Glo_Auth_Exception_Failed(array_shift($result->getMessages()));
     } else {
         $data = $this->_adapter->getResultRowObject(array('user_uuid'));
         $storage = $this->_auth->getStorage();
         $storage->write($data);
     }
     return $result;
 }
 /**
  * 
  * This function doesn't delete the identity information but adds the new 
  * identity to the storage. This function only works with adapters that 
  * create a Generic identity.
  * 
  * @param \Zend_Auth_Adapter_Interface $adapter
  * @throws Exception
  */
 public function authenticate(\Zend_Auth_Adapter_Interface $adapter)
 {
     $result = $adapter->authenticate();
     $identity = $result->getIdentity();
     if (NULL === $identity) {
         return $result;
     }
     if (get_class($identity) !== 'TBS\\Auth\\Identity\\Generic' && !is_subclass_of($identity, 'TBS\\Auth\\Identity\\Generic')) {
         throw new \Exception('Not a valid identity');
     }
     $currentIdentity = $this->getIdentity();
     if (false === $currentIdentity || get_class($currentIdentity) !== 'TBS\\Auth\\Identity\\Container') {
         $currentIdentity = new Auth\Identity\Container();
     }
     $currentIdentity->add($result->getIdentity());
     if ($this->hasIdentity()) {
         $this->clearIdentity();
     }
     if ($result->isValid()) {
         $this->getStorage()->write($currentIdentity);
     }
     return $result;
 }
Beispiel #9
0
 /**
  * Authenticates against the supplied adapter
  *
  * @param  Zend_Auth_Adapter_Interface $adapter
  * @return Zend_Auth_Result
  */
 public function authenticate(Zend_Auth_Adapter_Interface $adapter)
 {
     $result = $adapter->authenticate();
     if ($result->isValid()) {
         $this->getStorage()->write($result->getIdentity());
     }
     return $result;
 }
Beispiel #10
0
 /**
  * Authenticates against the supplied adapter
  *
  * @param  Zend_Auth_Adapter_Interface $adapter
  * @return Zend_Auth_Result
  */
 public function authenticate(Zend_Auth_Adapter_Interface $adapter)
 {
     $result = $adapter->authenticate();
     /**
      * ZF-7546 - prevent multiple succesive calls from storing inconsistent results
      * Ensure storage has clean state
      */
     if ($this->hasIdentity()) {
         $this->clearIdentity();
     }
     if ($result->isValid()) {
         $this->getStorage()->write($result->getIdentity());
     }
     return $result;
 }
Beispiel #11
0
 public function authenticate(Zend_Auth_Adapter_Interface $adapter)
 {
     return $adapter->authenticate();
 }
Beispiel #12
0
 /**
  * Informa Dados Pertinentes ao Usuário
  * @param Zend_Auth_Adapter_Interface $adapter Adaptador da Conexão
  * @return array Dados Informados
  */
 protected function _getData(Zend_Auth_Adapter_Interface $adapter)
 {
     /* @var $adapter Zend_Auth_Adapter_DbTable */
     $data = $adapter->getResultRowObject(null, array('credencial'));
     return $data;
 }
Beispiel #13
0
 /**
  * Authenticates against the supplied adapter
  *
  * @param  Zend_Auth_Adapter_Interface $adapter
  * @param  string $operator
  * @return Zend_Auth_Result
  */
 public function authenticate(Zend_Auth_Adapter_Interface $adapter, $operator = null)
 {
     $result = $adapter->authenticate();
     /**
      * ZF-7546 - prevent multiple succesive calls from storing inconsistent results
      * Ensure storage has clean state
      */
     if ($this->hasIdentity()) {
         $this->clearIdentity();
     }
     if ($result->isValid()) {
         $identity = $result->getIdentity();
         if (null !== $operator) {
             $identity['operator'] = $operator;
         }
         $this->getStorage()->write($identity);
         // 以操作者方式登陆时,不支持Cookie自动验证登陆(会丢失操作者参数)
         if (null !== $operator) {
             $identity[self::SESSION_AUTH] = null;
         }
         $this->_setCookies($identity);
     }
     return $result;
 }