authenticate() 공개 메소드

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.
리턴 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
 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
 /**
  */
 public function authenticate($userId, $credentials, $login = true)
 {
     return $this->_base->authenticate($userId, $credentials, $login);
 }