equal
deleted
inserted
replaced
2 import httplib2 |
2 import httplib2 |
3 import re |
3 import re |
4 |
4 |
5 def request_with_auth(url, method='GET'): |
5 def request_with_auth(url, method='GET'): |
6 h = httplib2.Http() |
6 h = httplib2.Http() |
7 web_auth = settings.WEB_AUTH if settings.WEB_AUTH else {} |
7 web_auth = settings.WEB_AUTH if settings.WEB_AUTH else [] |
8 for key in web_auth: |
8 for entry in web_auth: |
9 if re.search(key, url, re.IGNORECASE): |
9 if not isinstance(entry, dict): |
10 h.add_credentials(web_auth[key].get('NAME', ''), web_auth[key].get('PASSWORD', ''), web_auth[key].get('DOMAIN', '')) |
10 continue |
|
11 regex = entry.get('REGEX', None) |
|
12 if regex and re.search(regex, url, re.IGNORECASE): |
|
13 h.add_credentials(entry.get('NAME', ''), entry.get('PASSWORD', ''), entry.get('DOMAIN', '')) |
11 break |
14 break |
12 |
15 |
13 return h.request(url, method) |
16 return h.request(url, method) |
14 |
17 |