diff options
author | Wagner Bruna <wbruna@softwareexpress.com.br> | 2012-05-30 20:36:38 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2023-04-29 19:59:24 +0200 |
commit | b3f35b93c257e4b47edc5c90c8d4c37e0d9a2c52 (patch) | |
tree | eea9d7bb5cb1ef4741ac1e56475395f39190df8a | |
parent | cb3241fa77ff565f023428dbf6958f9c510399ad (diff) | |
download | urllib2_kerberos-b3f35b93c257e4b47edc5c90c8d4c37e0d9a2c52.tar.gz |
deal with multiple WWW-Authenticate headers
A server supporting both Negotiate and Basic authentication methods
could send both headers at once, but the get() method returns only
the last one.
-rw-r--r-- | urllib2_kerberos.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/urllib2_kerberos.py b/urllib2_kerberos.py index 2af1afb..b763f35 100644 --- a/urllib2_kerberos.py +++ b/urllib2_kerberos.py @@ -33,16 +33,17 @@ class AbstractKerberosAuthHandler: def negotiate_value(self, headers): """checks for "Negotiate" in proper auth header """ - authreq = headers.get(self.auth_header, None) + authreqs = headers.getheaders(self.auth_header) log.debug('authreqs = %s', authreqs) - if authreq: + if authreqs: rx = re.compile('(?:.*,)*\s*Negotiate\s*([^,]*),?', re.I) - mo = rx.search(authreq) - if mo: - return mo.group(1) - else: - log.debug("regex failed on: %s", authreq) + for authreq in authreqs: + mo = rx.search(authreq) + if mo: + return mo.group(1) + else: + log.debug("regex failed on: %s", authreq) else: log.debug("%s header not found", self.auth_header) |