From 1b1a1f811508e757418acf2b809a03d63faeabda Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Mon, 14 Jul 2014 19:12:30 -0700 Subject: [PATCH] proxy: add 'proxy_coll_select' config which will require a proxy-auth to select a collection for proxy mode. Otherwise, defaults to first available collection, though proxy-auth can still be sent to specify different collection --- config.yaml | 4 ++++ pywb/framework/proxy.py | 13 +++++++++---- pywb/webapp/pywb_init.py | 4 +++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/config.yaml b/config.yaml index 534eb4ff..91051b81 100644 --- a/config.yaml +++ b/config.yaml @@ -91,6 +91,10 @@ static_routes: # Enable simple http proxy mode enable_http_proxy: true +# additional options for routing +routing_options: + proxy_coll_select: false + # enable cdx server api for querying cdx directly (experimental) enable_cdx_api: true diff --git a/pywb/framework/proxy.py b/pywb/framework/proxy.py index faf6b72e..21bb65b5 100644 --- a/pywb/framework/proxy.py +++ b/pywb/framework/proxy.py @@ -49,9 +49,15 @@ class ProxyRouter(object): self.error_view = kwargs.get('error_view') - self.auth_msg = kwargs.get('auth_msg', + routing_options = kwargs.get('routing_options') + if not routing_options: + routing_options = {} + + self.auth_msg = routing_options.get('auth_msg', 'Please enter name of a collection to use for proxy mode') + self.proxy_coll_select = routing_options.get('proxy_coll_select', False) + def __call__(self, env): url = env['REL_REQUEST_URI'] @@ -76,7 +82,6 @@ class ProxyRouter(object): for r in self.routes: matcher, c = r.is_handling(proxy_coll) - print r.regex.pattern if matcher: route = r coll = c @@ -85,8 +90,8 @@ class ProxyRouter(object): if not route: return self.proxy_auth_coll_response() - print 'COLL ', coll - + elif self.proxy_coll_select: + return self.proxy_auth_coll_response() else: route = self.routes[0] coll = self.routes[0].regex.pattern diff --git a/pywb/webapp/pywb_init.py b/pywb/webapp/pywb_init.py index 3ec39dfc..b3ff1448 100644 --- a/pywb/webapp/pywb_init.py +++ b/pywb/webapp/pywb_init.py @@ -237,5 +237,7 @@ def create_wb_router(passed_config={}): 'Home Page'), error_view=J2TemplateView.create_template(config.get('error_html'), - 'Error Page') + 'Error Page'), + + routing_options=config.get('routing_options') )