[Inteproxy-commits] r111 - in trunk: . inteproxy test
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Feb 14 17:22:24 CET 2008
Author: bh
Date: 2008-02-14 17:22:24 +0100 (Thu, 14 Feb 2008)
New Revision: 111
Modified:
trunk/ChangeLog
trunk/demo.cfg
trunk/inteproxy/transcoder.py
trunk/test/test_transcoder_map.py
Log:
Implement http basic auth
* inteproxy/transcoder.py (BasicAuthTranscoder): New class to
handle HTTP basic authentication
(create_transcoder_map): Register BasicAuthTranscoder
* test/test_transcoder_map.py (TestTranscoderMap.test_lookup)
(TestTranscoderMap.test_get_transcoder_http_proxy)
(TestTranscoderMap.test_get_transcoder_inteproxy_style): Add Basic
Authorization tests
* demo.cfg: Add note about basicauth class
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-02-14 14:06:08 UTC (rev 110)
+++ trunk/ChangeLog 2008-02-14 16:22:24 UTC (rev 111)
@@ -1,5 +1,20 @@
2008-02-14 Bernhard Herzog <bh at intevation.de>
+ Implement http basic auth
+
+ * inteproxy/transcoder.py (BasicAuthTranscoder): New class to
+ handle HTTP basic authentication
+ (create_transcoder_map): Register BasicAuthTranscoder
+
+ * test/test_transcoder_map.py (TestTranscoderMap.test_lookup)
+ (TestTranscoderMap.test_get_transcoder_http_proxy)
+ (TestTranscoderMap.test_get_transcoder_inteproxy_style): Add Basic
+ Authorization tests
+
+ * demo.cfg: Add note about basicauth class
+
+2008-02-14 Bernhard Herzog <bh at intevation.de>
+
Make the transcoders more flexible in what they can change in a
request
Modified: trunk/demo.cfg
===================================================================
--- trunk/demo.cfg 2008-02-14 14:06:08 UTC (rev 110)
+++ trunk/demo.cfg 2008-02-14 16:22:24 UTC (rev 111)
@@ -28,4 +28,7 @@
#
# owsproxy The remote host is an OWSProxy requiring authentication
# and https
+#
+# basicauth HTTP Basic Authorization over https
+#
class=owsproxy
Modified: trunk/inteproxy/transcoder.py
===================================================================
--- trunk/inteproxy/transcoder.py 2008-02-14 14:06:08 UTC (rev 110)
+++ trunk/inteproxy/transcoder.py 2008-02-14 16:22:24 UTC (rev 111)
@@ -7,6 +7,7 @@
"""Classes to modify HTTP requests."""
+import base64
import urlparse
from urllib import quote_plus
from StringIO import StringIO
@@ -153,6 +154,19 @@
"text/xml")
+class BasicAuthTranscoder(HTTPSTranscoder):
+
+ """Transcoder for requests that use HTTP Basic Authentication"""
+
+ def convert_request(self, request):
+ """Asks the user for credentials and adds a Basic Authorization header
+ """
+ user, password = self.get_password()
+ if user is not None:
+ basicauth = "Basic " + base64.b64encode(user + ":" + password)
+ request.headers["Authorization"] = basicauth
+
+
class TranscoderMap(object):
"""Manages the host specific transcoder settings"""
@@ -254,5 +268,6 @@
return TranscoderMap([
("identity", IdentityTranscoder, IdentityTranscoder),
("owsproxy", OWSProxyGETTranscoder, OWSProxyPOSTTranscoder),
+ ("basicauth", BasicAuthTranscoder, BasicAuthTranscoder),
])
transcoder_map = create_transcoder_map()
Modified: trunk/test/test_transcoder_map.py
===================================================================
--- trunk/test/test_transcoder_map.py 2008-02-14 14:06:08 UTC (rev 110)
+++ trunk/test/test_transcoder_map.py 2008-02-14 16:22:24 UTC (rev 111)
@@ -1,4 +1,4 @@
-# Copyright (C) 2007 by Intevation GmbH
+# Copyright (C) 2007, 2008 by Intevation GmbH
# Authors:
# Bernhard Herzog <bh at intevation.de>
#
@@ -12,7 +12,8 @@
import support
from inteproxy.transcoder import create_transcoder_map, \
- OWSProxyGETTranscoder, OWSProxyPOSTTranscoder, IdentityTranscoder
+ OWSProxyGETTranscoder, OWSProxyPOSTTranscoder, BasicAuthTranscoder, \
+ IdentityTranscoder
class TestTranscoderMap(unittest.TestCase, support.FileTestMixin):
@@ -26,7 +27,7 @@
[example.com]
host=example.com
path=/foo
-class=owsproxy
+class=basicauth
"""
#
@@ -50,9 +51,9 @@
IdentityTranscoder),
("GET", "example.com", "/foo",
- OWSProxyGETTranscoder),
+ BasicAuthTranscoder),
("POST", "example.com", "/foo",
- OWSProxyPOSTTranscoder),
+ BasicAuthTranscoder),
# Example for a non-WMS request sent by deejump
("GET", "schemas.opengeospatial.net",
@@ -80,8 +81,8 @@
("POST", "http://inteproxy-demo.intevation.org/cgi-bin/frida",
IdentityTranscoder),
- ("GET", "http://example.com/foo", OWSProxyGETTranscoder),
- ("POST", "http://example.com/foo", OWSProxyPOSTTranscoder),
+ ("GET", "http://example.com/foo", BasicAuthTranscoder),
+ ("POST", "http://example.com/foo", BasicAuthTranscoder),
# Example for a non-WMS request sent by deejump
("GET",
@@ -111,8 +112,8 @@
("POST", "/inteproxy-demo.intevation.org/cgi-bin/frida",
IdentityTranscoder),
- ("GET", "/example.com/foo", OWSProxyGETTranscoder),
- ("POST", "/example.com/foo", OWSProxyPOSTTranscoder),
+ ("GET", "/example.com/foo", BasicAuthTranscoder),
+ ("POST", "/example.com/foo", BasicAuthTranscoder),
]
for method, url, expectedcls in test_cases:
More information about the Inteproxy-commits
mailing list