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

Commit 9b3620e

Browse files
committed
Merge branch 'feature/42' into develop
Close #42
2 parents 832fe58 + 55959bd commit 9b3620e

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ All notable changes to this project will be documented in this file, in reverse
1010

1111
### Changed
1212

13-
- Nothing.
13+
- [#42](https://github.com/zendframework/zend-authentication/pull/42) Changes authentication using Basic scheme
14+
to re-challenge the client when credentials in Authorization header can not be base64 decoded.
1415

1516
### Deprecated
1617

src/Adapter/Http.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ protected function _basicAuth($header)
484484
$auth = substr($header, strlen('Basic '));
485485
$auth = base64_decode($auth);
486486
if (! $auth) {
487-
throw new Exception\RuntimeException('Unable to base64_decode Authorization header value');
487+
return $this->challengeClient();
488488
}
489489

490490
// See ZF-1253. Validate the credentials the same way the digest

test/Adapter/Http/AuthTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,21 @@ public function testBasicAuthBadPassword()
215215
$this->_checkUnauthorized($data, $basic);
216216
}
217217

218+
public function testBasicAuthTokenIsNotBase64()
219+
{
220+
// Attempt Basic Authentication with a valid username, but invalid
221+
// password
222+
223+
// The expected Basic Www-Authenticate header value
224+
$basic = [
225+
'type' => 'Basic ',
226+
'realm' => 'realm="' . $this->_basicConfig['realm'] . '"',
227+
];
228+
229+
$data = $this->_doAuth('Basic', 'basic');
230+
$this->_checkUnauthorized($data, $basic);
231+
}
232+
218233
public function testDigestAuthValidCreds()
219234
{
220235
// Attempt Digest Authentication with a valid username and password

0 commit comments

Comments
 (0)