Backport old digest auth to 1.7

A prior pull request that made it into 1.8. This pull request merges it into the 1.7.x branch.