~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/http/_urllib2_wrappers.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-04-11 16:29:33 UTC
  • mfrom: (4285.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090411162933-dtrs0q12d9qvbgk6
(vila) Fix realm extraction for http basic authentication

Show diffs side-by-side

added added

removed removed

Lines of Context:
1244
1244
        auth_header = 'Basic ' + raw.encode('base64').strip()
1245
1245
        return auth_header
1246
1246
 
 
1247
    def extract_realm(self, header_value):
 
1248
        match = self.auth_regexp.search(header_value)
 
1249
        realm = None
 
1250
        if match:
 
1251
            realm = match.group(1)
 
1252
        return match, realm
 
1253
 
1247
1254
    def auth_match(self, header, auth):
1248
1255
        scheme, raw_auth = self._parse_auth_header(header)
1249
1256
        if scheme != 'basic':
1250
1257
            return False
1251
1258
 
1252
 
        match = self.auth_regexp.search(raw_auth)
 
1259
        match, realm = self.extract_realm(raw_auth)
1253
1260
        if match:
1254
 
            realm = match.groups()
1255
1261
            if scheme != 'basic':
1256
1262
                return False
1257
1263