Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of git://github.com/zendframework/zf2
Browse files Browse the repository at this point in the history
  • Loading branch information
vahid-sohrabloo committed Jul 5, 2012
9 parents 3357aa2 + 4009aca + ad280cb + b0d3db4 + 9b28224 + 49a871c + 4145ab4 + ff8e603 + abd0527 commit 9dc2f89
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 100 deletions.
14 changes: 0 additions & 14 deletions .travis/run-tests.sh

This file was deleted.

7 changes: 0 additions & 7 deletions .travis/skipped-components

This file was deleted.

61 changes: 0 additions & 61 deletions .travis/tested-components

This file was deleted.

2 changes: 1 addition & 1 deletion src/Adapter/DbTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ protected function _authenticateQuerySelect(DbSelect $dbSelect)
$dbSelect->prepareStatement($this->_zendDb, $statement);
$resultSet = new ResultSet();
try {
$resultSet->setDataSource($statement->execute(array($this->_credential, $this->_identity)));
$resultSet->initialize($statement->execute(array($this->_credential, $this->_identity)));
$resultIdentities = $resultSet->toArray();
} catch (\Exception $e) {
throw new Exception\RuntimeException(
Expand Down
25 changes: 15 additions & 10 deletions src/Adapter/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public function authenticate()
$getHeader = 'Authorization';
}

$headers = $this->_request->headers();
$headers = $this->_request->getHeaders();
if (!$headers->has($getHeader)) {
return $this->_challengeClient();
}
Expand Down Expand Up @@ -412,7 +412,7 @@ protected function _challengeClient()
$this->_response->setStatusCode($statusCode);

// Send a challenge in each acceptable authentication scheme
$headers = $this->_response->headers();
$headers = $this->_response->getHeaders();
if (in_array('basic', $this->_acceptSchemes)) {
$headers->addHeaderLine($headerName, $this->_basicHeader());
}
Expand Down Expand Up @@ -496,14 +496,19 @@ protected function _basicAuth($header)
return $this->_challengeClient();
}

$password = $this->_basicResolver->resolve($creds[0], $this->_realm);
if ($password &&
$this->_secureStringCompare($password, $creds[1])) {
$result = $this->_basicResolver->resolve($creds[0], $this->_realm, $creds[1]);

if ($result
&& !is_array($result)
&& $this->_secureStringCompare($result, $creds[1])
) {
$identity = array('username'=>$creds[0], 'realm'=>$this->_realm);
return new Authentication\Result(Authentication\Result::SUCCESS, $identity);
} else {
return $this->_challengeClient();
} elseif (is_array($result)) {
return new Authentication\Result(Authentication\Result::SUCCESS, $result);
}

return $this->_challengeClient();
}

/**
Expand Down Expand Up @@ -614,7 +619,7 @@ protected function _calcNonce()
// would be surprising if the user just logged in.
$timeout = ceil(time() / $this->_nonceTimeout) * $this->_nonceTimeout;

$nonce = hash('md5', $timeout . ':' . $this->_request->server()->get('HTTP_USER_AGENT') . ':' . __CLASS__);
$nonce = hash('md5', $timeout . ':' . $this->_request->getServer()->get('HTTP_USER_AGENT') . ':' . __CLASS__);
return $nonce;
}

Expand Down Expand Up @@ -688,7 +693,7 @@ protected function _parseDigestAuth($header)
// Section 3.2.2.5 in RFC 2617 says the authenticating server must
// verify that the URI field in the Authorization header is for the
// same resource requested in the Request Line.
$rUri = $this->_request->uri();
$rUri = $this->_request->getUri();
$cUri = UriFactory::factory($temp[1]);

// Make sure the path portion of both URIs is the same
Expand Down Expand Up @@ -744,7 +749,7 @@ protected function _parseDigestAuth($header)
if (!$ret || empty($temp[1])) {

// Big surprise: IE isn't RFC 2617-compliant.
$headers = $this->_request->headers();
$headers = $this->_request->getHeaders();
if (!$headers->has('User-Agent')) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Adapter/Http/FileResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function getFile()
* realm, false otherwise.
* @throws Exception\ExceptionInterface
*/
public function resolve($username, $realm)
public function resolve($username, $realm, $password = null)
{
if (empty($username)) {
throw new Exception\InvalidArgumentException('Username is required');
Expand Down
7 changes: 4 additions & 3 deletions src/Adapter/Http/ResolverInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ interface ResolverInterface
*
* @param string $username Username
* @param string $realm Authentication Realm
* @return string|false User's shared secret, if the user is found in the
* realm, false otherwise.
* @param string $password Password (optional)
* @return string|array|false User's shared secret as string if found in realm, or User's identity as array
* if resolved, false otherwise.
*/
public function resolve($username, $realm);
public function resolve($username, $realm, $password = null);
}
4 changes: 2 additions & 2 deletions test/Adapter/Http/AuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ protected function _doAuth($clientHeader, $scheme)
$request->setUri('http://localhost/');
$request->setMethod('GET');
$request->setServer(new Parameters(array('HTTP_USER_AGENT' => 'PHPUnit')));
$headers = $request->headers();
$headers = $request->getHeaders();
$headers->addHeaderLine('Authorization', $clientHeader);

// Select an Authentication scheme
Expand Down Expand Up @@ -370,7 +370,7 @@ protected function _doAuth($clientHeader, $scheme)
$return = array(
'result' => $result,
'status' => $response->getStatusCode(),
'headers' => $response->headers(),
'headers' => $response->getHeaders(),
);
return $return;
}
Expand Down
2 changes: 1 addition & 1 deletion test/Adapter/Http/ProxyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ public function _doAuth($clientHeader, $scheme)
$return = array(
'result' => $result,
'status' => $response->getStatusCode(),
'headers' => $response->headers(),
'headers' => $response->getHeaders(),
);
return $return;
}
Expand Down

0 comments on commit 9dc2f89

Please # to comment.