'Finds the user and checks their API key.
Should return either ``True`` if allowed, ``False`` if not or an
``HttpResponse`` if you need something custom.'

def is_authenticated(self, request, **kwargs):

    try:
        self.get_authorization_data(request)
    except ValueError:
        return self._unauthorized()
    digest_response = python_digest.parse_digest_credentials(request.META[u'HTTP_AUTHORIZATION'])
    if (not python_digest.validate_nonce(digest_response.nonce, settings.SECRET_KEY)):
        return self._unauthorized()
    user = self.get_user(digest_response.username)
    api_key = self.get_key(user)
    if ((user is False) or (api_key is False)):
        return self._unauthorized()
    expected = python_digest.calculate_request_digest(request.method, python_digest.calculate_partial_digest(digest_response.username, self.realm, api_key), digest_response)
    if (not (digest_response.response == expected)):
        return self._unauthorized()
    if (not self.check_active(user)):
        return False
    request.user = user
    return True
