[Kimchi-devel] [PATCH 19/38] Dynamically add authed URLs to plugin conf
Lucio Correia
luciojhc at linux.vnet.ibm.com
Thu May 21 21:33:32 UTC 2015
---
plugins/kimchi/kimchi.conf | 1 +
src/wok/server.py | 21 +++++++++++++++++++++
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/plugins/kimchi/kimchi.conf b/plugins/kimchi/kimchi.conf
index 07ade54..449b1cd 100644
--- a/plugins/kimchi/kimchi.conf
+++ b/plugins/kimchi/kimchi.conf
@@ -2,6 +2,7 @@
enable = True
plugin_class = "KimchiRoot"
uri = "/plugins/kimchi"
+extra_auth_api_class = "control.sub_nodes"
[/]
tools.trailing_slash.on = False
diff --git a/src/wok/server.py b/src/wok/server.py
index 711c24f..7a75a9f 100644
--- a/src/wok/server.py
+++ b/src/wok/server.py
@@ -150,6 +150,8 @@ class Server(object):
plugin_class = ('plugins.%s.%s' %
(plugin_name,
plugin_config['wok']['plugin_class']))
+ extra_auth = plugin_config['wok'].get('extra_auth_api_class',
+ None)
script_name = plugin_config['wok']['uri']
del plugin_config['wok']
@@ -163,6 +165,25 @@ class Server(object):
cherrypy.log.error_log.error("Failed to import plugin %s" %
plugin_class)
continue
+
+ # dynamically add tools.wokauth.on = True to extra plugin APIs
+ if extra_auth:
+ try:
+ authed_apis = import_class(('plugins.%s.%s' % (plugin_name,
+ extra_auth)))
+ except ImportError:
+ cherrypy.log.error_log.error("Failed to import subnodes "
+ "for plugin %s" % plugin_class)
+ continue
+
+ urlSubNodes = {}
+ for ident, node in authed_apis.items():
+ if node.url_auth:
+ ident = "/%s" % ident
+ urlSubNodes[ident] = {'tools.wokauth.on': True}
+
+ plugin_config.update(urlSubNodes)
+
cherrypy.tree.mount(plugin_app, script_name, plugin_config)
def start(self):
--
1.7.1
More information about the Kimchi-devel
mailing list