mikeal/request — pull request #616 by randymized (2013-08-05 01:07:18+00:00)
Title: Use www-authenticate to parse www-authenticate headers and generate auth...

I am offering a more complete implementation of RFC 2617 digest authentication, through inclusion of the www-authenticate module I recently posted. This proposed patch delegates parsing of the www-authenticate header, interpretation of its challenge and generation of the authorization header to the www-authenticate module.

Please note that I had to change the expected response in one of the tests in order to pass the basic and digest authentication tests. The principal reason is that the nonce-count is that, consistent with the rfc, nonce-count represented as a 8 "digit" hex number (00000001) rather than simply 1. Since nc is included in the request-digest calculation, its representation is significant and results in a different digest. The order of the attributes is also slightly different and the algorithm is included.

Next step, assuming you accept this request, and essential to applying request to my application, is to generate authorization headers for any number of additional requests, much as cookies are retained and applied to a series of requests. A single 401 can then provide the challenge for authenticating multiple successive requests.

Thanks for you work on request. Hopefully this addition will enhance its value.