--- a/src/ldt/ldt/settings.py Tue Nov 06 17:01:24 2012 +0100
+++ b/src/ldt/ldt/settings.py Tue Nov 06 17:59:59 2012 +0100
@@ -54,7 +54,7 @@
WEB_URL = getattr(settings, 'WEB_URL', '')
-WEB_AUTH = getattr(settings, 'WEB_AUTH', {})
+WEB_AUTH = getattr(settings, 'WEB_AUTH', [])
BASE_URL = getattr(settings, 'BASE_URL', '')
STATIC_URL = getattr(settings, 'STATIC_URL', '')
MEDIA_URL = getattr(settings, 'MEDIA_URL', '')
--- a/src/ldt/ldt/utils/url.py Tue Nov 06 17:01:24 2012 +0100
+++ b/src/ldt/ldt/utils/url.py Tue Nov 06 17:59:59 2012 +0100
@@ -4,10 +4,13 @@
def request_with_auth(url, method='GET'):
h = httplib2.Http()
- web_auth = settings.WEB_AUTH if settings.WEB_AUTH else {}
- for key in web_auth:
- if re.search(key, url, re.IGNORECASE):
- h.add_credentials(web_auth[key].get('NAME', ''), web_auth[key].get('PASSWORD', ''), web_auth[key].get('DOMAIN', ''))
+ web_auth = settings.WEB_AUTH if settings.WEB_AUTH else []
+ for entry in web_auth:
+ if not isinstance(entry, dict):
+ continue
+ regex = entry.get('REGEX', None)
+ if regex and re.search(regex, url, re.IGNORECASE):
+ h.add_credentials(entry.get('NAME', ''), entry.get('PASSWORD', ''), entry.get('DOMAIN', ''))
break
return h.request(url, method)
--- a/web/ldtplatform/config.py.tmpl Tue Nov 06 17:01:24 2012 +0100
+++ b/web/ldtplatform/config.py.tmpl Tue Nov 06 17:59:59 2012 +0100
@@ -7,6 +7,7 @@
BASE_DIR = '%(base_dir)s'
BASE_URL = '%(base_url)s'
WEB_URL = '%(web_url)s'
+WEB_AUTH = [] # example [{'REGEX': 'localhost/~ymh/platform', 'NAME': 'ymh', 'PASSWORD': 'ymh'}]
STATIC_URL = BASE_URL + 'static/site/'