public function digestAuth($realm, array $users)
    {
        if ($this->isCLIRequest()) {
            return;
        }

        if (empty($_SERVER['PHP_AUTH_DIGEST'])) {
            $this->sendAuthenticateHeader($realm);

            exit();
        }

        if (!($data = $this->httpDigestParse($_SERVER['PHP_AUTH_DIGEST'])) || !isset($users[$data['username']])) {
            $this->sendAuthenticateHeader($realm);

            exit();
        }

        $A1 = md5($data['username'] . ':' . $realm . ':' . $users[$data['username']]);
        $A2 = md5($_SERVER['REQUEST_METHOD'] . ':' . $data['uri']);

        $valid_response = md5($A1 . ':' . $data['nonce'] . ':' . $data['nc'] . ':' . $data['cnonce'] . ':' . $data['qop'] . ':' . $A2);

        if ($data['response'] != $valid_response) {
            $this->sendAuthenticateHeader($realm);

            exit();
        }
    }
public function digestAuth($realm, array $users)
    {
        if ($this->isCLIRequest()) {
            return;
        }

        if (empty($_SERVER['PHP_AUTH_DIGEST'])) {
            $this->sendAuthenticateHeader($realm);

            exit();
        }

        if (!($data = $this->httpDigestParse($_SERVER['PHP_AUTH_DIGEST'])) || !isset($users[$data['username']])) {
            $this->sendAuthenticateHeader($realm);

            exit();
        }

        $A1 = md5($data['username'] . ':' . $realm . ':' . $users[$data['username']]);
        $A2 = md5($_SERVER['REQUEST_METHOD'] . ':' . $data['uri']);

        $valid_response = md5($A1 . ':' . $data['nonce'] . ':' . $data['nc'] . ':' . $data['cnonce'] . ':' . $data['qop'] . ':' . $A2);

        if ($data['response'] != $valid_response) {
            $this->sendAuthenticateHeader($realm);

            exit();
        }
    }
public function digestAuth ( $ realm , array $ users ) { if ( $ this -> isCLIRequest ( ) ) { return ; } if ( empty ( $ _SERVER [ 'PHP_AUTH_DIGEST' ] ) ) { $ this -> sendAuthenticateHeader ( $ realm ) ; exit ( ) ; } if ( ! ( $ data = $ this -> httpDigestParse ( $ _SERVER [ 'PHP_AUTH_DIGEST' ] ) ) || ! isset ( $ users [ $ data [ 'username' ] ] ) ) { $ this -> sendAuthenticateHeader ( $ realm ) ; exit ( ) ; } $ A1 = md5 ( $ data [ 'username' ] . ':' . $ realm . ':' . $ users [ $ data [ 'username' ] ] ) ; $ A2 = md5 ( $ _SERVER [ 'REQUEST_METHOD' ] . ':' . $ data [ 'uri' ] ) ; $ valid_response = md5 ( $ A1 . ':' . $ data [ 'nonce' ] . ':' . $ data [ 'nc' ] . ':' . $ data [ 'cnonce' ] . ':' . $ data [ 'qop' ] . ':' . $ A2 ) ; if ( $ data [ 'response' ] != $ valid_response ) { $ this -> sendAuthenticateHeader ( $ realm ) ; exit ( ) ; } }
Perform digest HTTP authentication

Note: HTTP authentication is disabled, if application
runs in command-line (CLI) mode

@param string $realm
@param array $users username => password
Perform digest HTTP authentication