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

Commit 4009aca

Browse files
committed
Merge branch 'feature-http-auth-improvements' of https://github.com/davidwindell/zf2 into feature/http-auth-resolover
8 parents ad280cb + b0d3db4 + 9b28224 + 49a871c + 4145ab4 + ff8e603 + abd0527 + 6fafc84 commit 4009aca

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

src/Adapter/Http.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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
/**

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
}

0 commit comments

Comments
 (0)