authenticate() public method

Finds out if a set of login credentials are valid, and if requested, mark the user as logged in in the current session.
public authenticate ( string $userId, array $credentials, boolean $login = true ) : boolean
$userId string The userId to check.
$credentials array The credentials to check.
$login boolean Whether to log the user in. If false, we'll only test the credentials and won't modify the current session. Defaults to true.
return boolean Whether or not the credentials are valid.
コード例 #1
0
ファイル: Driver.php プロジェクト: Gomez/horde
 /**
  * Authenticate to Horde
  *
  * @param string $username  The username to authenticate as (as passed by
  *                          the device).
  * @param string $password  The password
  * @param string $domain    The user domain (unused in this driver).
  *
  * @return mixed  Boolean true on success, boolean false on credential
  *                failure or Horde_ActiveSync::AUTH_REASON_*
  *                constant on policy failure.
  */
 public function authenticate($username, $password, $domain = null)
 {
     global $injector, $conf;
     $this->_logger->info(sprintf('[%s] Horde_Core_ActiveSync_Driver::authenticate() attempt for %s', $this->_pid, $username));
     // First try transparent/X509. Happens for authtype == 'cert' || 'basic_cert'
     if ($conf['activesync']['auth']['type'] != 'basic') {
         if (!$this->_auth->transparent()) {
             $injector->getInstance('Horde_Log_Logger')->notice(sprintf('Login failed ActiveSync client certificate for user %s.', $username));
             return false;
         }
         if ($username != $GLOBALS['registry']->getAuth()) {
             $injector->getInstance('Horde_Log_Logger')->notice(sprintf('Access granted based on transparent authentication of user %s, but ActiveSync client is requesting access for %s.', $GLOBALS['registry']->getAuth(), $username));
             $GLOBALS['registry']->clearAuth();
             return false;
         }
         $this->_logger->info(sprintf('Access granted based on transparent authentication for %s. Client certificate name: %s', $GLOBALS['registry']->getAuth(), $username));
     }
     // Now check Basic. Happens for authtype == 'basic' || 'basic_cert'
     if ($conf['activesync']['auth']['type'] != 'cert' && !$this->_auth->authenticate($username, array('password' => $password))) {
         $injector->getInstance('Horde_Log_Logger')->notice(sprintf('Login failed from ActiveSync client for user %s.', $username));
         return false;
     }
     // Get the username from the registry so we capture it after any
     // hooks were run on it.
     $username = $GLOBALS['registry']->getAuth();
     $perms = $injector->getInstance('Horde_Perms');
     if ($perms->exists('horde:activesync')) {
         // Check permissions to ActiveSync
         if (!$this->_getPolicyValue('activesync', $perms->getPermissions('horde:activesync', $username))) {
             $this->_logger->info(sprintf("Access denied for user %s per policy settings.", $username));
             return Horde_ActiveSync::AUTH_REASON_USER_DENIED;
         }
     }
     return parent::authenticate($username, $password, $domain);
 }
コード例 #2
0
ファイル: Application.php プロジェクト: Gomez/horde
 /**
  * Finds out if a set of login credentials are valid, and if requested,
  * mark the user as logged in in the current session.
  *
  * @param string $userId      The user ID to check.
  * @param array $credentials  The credentials to check.
  * @param boolean $login      Whether to log the user in. If false, we'll
  *                            only test the credentials and won't modify
  *                            the current session. Defaults to true.
  *
  * @return boolean  Whether or not the credentials are valid.
  */
 public function authenticate($userId, $credentials, $login = true)
 {
     try {
         list($userId, $credentials) = $this->runHook(trim($userId), $credentials, 'preauthenticate', 'authenticate');
     } catch (Horde_Auth_Exception $e) {
         return false;
     }
     if ($this->_base) {
         if (!$this->_base->authenticate($userId, $credentials, $login)) {
             return false;
         }
     } elseif (!parent::authenticate($userId, $credentials, $login)) {
         return false;
     }
     /* Remember the user's mode choice, if applicable. */
     if (!empty($credentials['mode'])) {
         $this->_view = $credentials['mode'];
     }
     return $this->_setAuth();
 }
コード例 #3
0
ファイル: Auth.php プロジェクト: horde/horde
 /**
  * Validates a username and password
  *
  * This method should return true or false depending on if login
  * succeeded.
  *
  * @param string $username
  * @param string $password
  * @return bool
  */
 protected function validateUserPass($username, $password)
 {
     return $this->_auth->authenticate($username, array('password' => $password));
 }
コード例 #4
0
ファイル: Scenario.php プロジェクト: raz0rsdge/horde
 public function authenticate(Horde_Auth_Base $auth, $username = '******', $password = '******')
 {
     $this->assertTrue($auth->authenticate($username, array('password' => $password)));
     $params = array('driver' => 'Mock', 'username' => $username, 'password' => $password);
     return $this->prepareEmptyKolabStorage($params);
 }
コード例 #5
0
ファイル: UsernameHook.php プロジェクト: horde/horde
 /**
  */
 public function authenticate($userId, $credentials, $login = true)
 {
     return $this->_base->authenticate($userId, $credentials, $login);
 }