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

Commit 9dc2f89

Browse files
Merge branch 'master' of git://github.com/zendframework/zf2
9 parents 3357aa2 + 4009aca + ad280cb + b0d3db4 + 9b28224 + 49a871c + 4145ab4 + ff8e603 + abd0527 commit 9dc2f89

File tree

9 files changed

+24
-100
lines changed

9 files changed

+24
-100
lines changed

.travis/run-tests.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.

.travis/skipped-components

Lines changed: 0 additions & 7 deletions
This file was deleted.

.travis/tested-components

Lines changed: 0 additions & 61 deletions
This file was deleted.

src/Adapter/DbTable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ protected function _authenticateQuerySelect(DbSelect $dbSelect)
428428
$dbSelect->prepareStatement($this->_zendDb, $statement);
429429
$resultSet = new ResultSet();
430430
try {
431-
$resultSet->setDataSource($statement->execute(array($this->_credential, $this->_identity)));
431+
$resultSet->initialize($statement->execute(array($this->_credential, $this->_identity)));
432432
$resultIdentities = $resultSet->toArray();
433433
} catch (\Exception $e) {
434434
throw new Exception\RuntimeException(

src/Adapter/Http.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ public function authenticate()
348348
$getHeader = 'Authorization';
349349
}
350350

351-
$headers = $this->_request->headers();
351+
$headers = $this->_request->getHeaders();
352352
if (!$headers->has($getHeader)) {
353353
return $this->_challengeClient();
354354
}
@@ -412,7 +412,7 @@ protected function _challengeClient()
412412
$this->_response->setStatusCode($statusCode);
413413

414414
// Send a challenge in each acceptable authentication scheme
415-
$headers = $this->_response->headers();
415+
$headers = $this->_response->getHeaders();
416416
if (in_array('basic', $this->_acceptSchemes)) {
417417
$headers->addHeaderLine($headerName, $this->_basicHeader());
418418
}
@@ -496,14 +496,19 @@ protected function _basicAuth($header)
496496
return $this->_challengeClient();
497497
}
498498

499-
$password = $this->_basicResolver->resolve($creds[0], $this->_realm);
500-
if ($password &&
501-
$this->_secureStringCompare($password, $creds[1])) {
499+
$result = $this->_basicResolver->resolve($creds[0], $this->_realm, $creds[1]);
500+
501+
if ($result
502+
&& !is_array($result)
503+
&& $this->_secureStringCompare($result, $creds[1])
504+
) {
502505
$identity = array('username'=>$creds[0], 'realm'=>$this->_realm);
503506
return new Authentication\Result(Authentication\Result::SUCCESS, $identity);
504-
} else {
505-
return $this->_challengeClient();
507+
} elseif (is_array($result)) {
508+
return new Authentication\Result(Authentication\Result::SUCCESS, $result);
506509
}
510+
511+
return $this->_challengeClient();
507512
}
508513

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

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

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

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

746751
// Big surprise: IE isn't RFC 2617-compliant.
747-
$headers = $this->_request->headers();
752+
$headers = $this->_request->getHeaders();
748753
if (!$headers->has('User-Agent')) {
749754
return false;
750755
}

src/Adapter/Http/FileResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function getFile()
9999
* realm, false otherwise.
100100
* @throws Exception\ExceptionInterface
101101
*/
102-
public function resolve($username, $realm)
102+
public function resolve($username, $realm, $password = null)
103103
{
104104
if (empty($username)) {
105105
throw new Exception\InvalidArgumentException('Username is required');

src/Adapter/Http/ResolverInterface.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ interface ResolverInterface
4040
*
4141
* @param string $username Username
4242
* @param string $realm Authentication Realm
43-
* @return string|false User's shared secret, if the user is found in the
44-
* realm, false otherwise.
43+
* @param string $password Password (optional)
44+
* @return string|array|false User's shared secret as string if found in realm, or User's identity as array
45+
* if resolved, false otherwise.
4546
*/
46-
public function resolve($username, $realm);
47+
public function resolve($username, $realm, $password = null);
4748
}

test/Adapter/Http/AuthTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ protected function _doAuth($clientHeader, $scheme)
341341
$request->setUri('http://localhost/');
342342
$request->setMethod('GET');
343343
$request->setServer(new Parameters(array('HTTP_USER_AGENT' => 'PHPUnit')));
344-
$headers = $request->headers();
344+
$headers = $request->getHeaders();
345345
$headers->addHeaderLine('Authorization', $clientHeader);
346346

347347
// Select an Authentication scheme
@@ -370,7 +370,7 @@ protected function _doAuth($clientHeader, $scheme)
370370
$return = array(
371371
'result' => $result,
372372
'status' => $response->getStatusCode(),
373-
'headers' => $response->headers(),
373+
'headers' => $response->getHeaders(),
374374
);
375375
return $return;
376376
}

test/Adapter/Http/ProxyTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ public function _doAuth($clientHeader, $scheme)
361361
$return = array(
362362
'result' => $result,
363363
'status' => $response->getStatusCode(),
364-
'headers' => $response->headers(),
364+
'headers' => $response->getHeaders(),
365365
);
366366
return $return;
367367
}

0 commit comments

Comments
 (0)