Skip to content

Commit

Permalink
Fix valid_response on _prepare_digest_auth
Browse files Browse the repository at this point in the history
  • Loading branch information
Leandro Corsino authored and chriskacerguis committed Apr 12, 2020
1 parent cb24641 commit 98457e6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/RestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1782,12 +1782,13 @@ protected function _prepare_digest_auth()
$digest = (empty($matches[1]) || empty($matches[2])) ? [] : array_combine($matches[1], $matches[2]);

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

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

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

0 comments on commit 98457e6

Please sign in to comment.