Skip to content

Commit 98457e6

Browse files
Leandro Corsinochriskacerguis
authored andcommitted
Fix valid_response on _prepare_digest_auth
1 parent cb24641 commit 98457e6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/RestController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,12 +1782,13 @@ protected function _prepare_digest_auth()
17821782
$digest = (empty($matches[1]) || empty($matches[2])) ? [] : array_combine($matches[1], $matches[2]);
17831783

17841784
// For digest authentication the library function should return already stored md5(username:restrealm:password) for that username see rest.php::auth_library_function config
1785-
if (isset($digest['username']) === false || $this->_check_login($digest['username'], true) === false) {
1785+
$username = $this->_check_login($digest['username'], true);
1786+
if (isset($digest['username']) === false || $username === false) {
17861787
$this->_force_login($unique_id);
17871788
}
17881789

17891790
$md5 = md5(strtoupper($this->request->method).':'.$digest['uri']);
1790-
$valid_response = md5($digest['username'].':'.$digest['nonce'].':'.$digest['nc'].':'.$digest['cnonce'].':'.$digest['qop'].':'.$md5);
1791+
$valid_response = md5($username.':'.$digest['nonce'].':'.$digest['nc'].':'.$digest['cnonce'].':'.$digest['qop'].':'.$md5);
17911792

17921793
// Check if the string don't compare (case-insensitive)
17931794
if (strcasecmp($digest['response'], $valid_response) !== 0) {

0 commit comments

Comments
 (0)