/** * Method to authenticate * * @param string $username * @param string $password * @return int */ public function authenticate($username, $password) { parent::authenticate($username, $password); $table = $this->table; $this->result = 0; $this->user = $table::findBy([$this->usernameField => $this->username]); if (null !== $this->password && isset($this->user->{$this->passwordField}) && null !== $this->user->{$this->passwordField}) { $this->result = (int) $this->verify($this->password, $this->user->{$this->passwordField}); } return $this->result; }
/** * Method to authenticate * * @param string $username * @param string $password * @return int */ public function authenticate($username, $password) { parent::authenticate($username, $password); $lines = file($this->filename); $hash = null; $this->result = 0; foreach ($lines as $line) { $line = trim($line); $user = explode($this->delimiter, $line); if (isset($user[0]) && $user[0] == $this->username) { if (null !== $this->realm && count($user) == 3) { if ($this->username == $user[0] && $user[1] == $this->realm) { $hash = $user[2]; break; } } else { if (count($user) == 2) { if ($this->username == $user[0]) { $hash = $user[1]; break; } } } } } if (null !== $this->password && null !== $hash) { $this->result = (int) $this->verify($this->password, $hash); } return $this->result; }
/** * Method to authenticate * * @param string $username * @param string $password * @return int */ public function authenticate($username, $password) { parent::authenticate($username, $password); $this->generateRequest(); $context = ['http' => ['method' => $this->method, 'header' => null]]; switch ($this->type) { case 'Basic': $context['http']['header'] = 'Authorization: Basic ' . base64_encode($this->username . ':' . $this->password); break; case 'Digest': $a1 = md5($this->username . ':' . $this->scheme['realm'] . ':' . $this->password); $a2 = md5($this->method . ':' . $this->relativeUri); $r = md5($a1 . ':' . $this->scheme['nonce'] . ':' . $a2); $context['http']['header'] = 'Authorization: Digest username="******", realm="' . $this->scheme['realm'] . '", nonce="' . $this->scheme['nonce'] . '", uri="' . $this->relativeUri . '", response="' . $r . '"'; break; } $this->sendRequest($context); $this->result = (int) ($this->code == 200); return $this->result; }
/** * Method to authenticate * * @param string $username * @param string $password * @return int */ public function authenticate($username, $password) { parent::authenticate($username, $password); $this->result = (int) @ldap_bind($this->resource, $this->username, $this->password); return $this->result; }