simplegy / httplib2

Automatically exported from code.google.com/p/httplib2
0 stars 0 forks source link

Allow HTTP digest auth against Apple's Calendar Server #21

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Apple's Calendar Server uses HTTP digest auth, but doesn't set qop in the 
WWW-Authenticate 
header, and specifies algorithm=md5 in lowercase. This prevents httplib2 0.4.0 
from 
authenticating successfully.

This patch to httplib2/__init__.py fixes the problem:

         Authentication.__init__(self, credentials, host, request_uri, headers, response, content, http)
         challenge = _parse_www_authenticate(response, 'www-authenticate')
         self.challenge = challenge['digest']
-        qop = self.challenge.get('qop')
+        qop = self.challenge.get('qop', 'auth')
         self.challenge['qop'] = ('auth' in [x.strip() for x in qop.split()]) and 'auth' or None
         if self.challenge['qop'] is None:
             raise UnimplementedDigestAuthOptionError( _("Unsupported value for qop: %s." % qop))
-        self.challenge['algorithm'] = self.challenge.get('algorithm', 'MD5')
+        self.challenge['algorithm'] = self.challenge.get('algorithm', 
'MD5').upper()
         if self.challenge['algorithm'] != 'MD5':
             raise UnimplementedDigestAuthOptionError( _("Unsupported value for algorithm: %s." % 
self.challenge['algorithm']))
         self.A1 = "".join([self.credentials[0], ":", self.challenge['realm'], ":", self.credentials[1]]) 

Original issue reported on code.google.com by salma...@gmail.com on 23 Mar 2008 at 7:39

GoogleCodeExporter commented 9 years ago
Changes applied, some verification will be needed to see if this fixes the 
reported
problem.

Original comment by joe.gregorio@gmail.com on 5 Sep 2008 at 2:38