allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject git commit: [#7401] add support for custom middleware via `[allura.middleware]` entry points
Date Mon, 19 May 2014 16:32:03 GMT
Repository: allura
Updated Branches:
  refs/heads/db/7401 [created] 8eaa8f93b


[#7401] add support for custom middleware via `[allura.middleware]` entry points


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/8eaa8f93
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/8eaa8f93
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/8eaa8f93

Branch: refs/heads/db/7401
Commit: 8eaa8f93b206cab76dd7957e650c6843da96b907
Parents: 70d7649
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Mon May 19 16:31:26 2014 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Mon May 19 16:31:26 2014 +0000

----------------------------------------------------------------------
 Allura/allura/config/middleware.py | 8 +++-----
 Allura/docs/extending.rst          | 1 +
 2 files changed, 4 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/8eaa8f93/Allura/allura/config/middleware.py
----------------------------------------------------------------------
diff --git a/Allura/allura/config/middleware.py b/Allura/allura/config/middleware.py
index cface6d..be0ef26 100644
--- a/Allura/allura/config/middleware.py
+++ b/Allura/allura/config/middleware.py
@@ -125,11 +125,9 @@ def _make_core_app(root, global_conf, full_stack=True, **app_conf):
                                " the zarkov.host setting in your ini file."
 
     app = tg.TGApp()
-    if asbool(config.get('auth.method', 'local') == 'sfx'):
-        import sfx.middleware
-        d = h.config_with_prefix(config, 'auth.')
-        d.update(h.config_with_prefix(config, 'sfx.'))
-        app = sfx.middleware.SfxMiddleware(app, d)
+    for mw_ep in h.iter_entry_points('allura.middleware'):
+        Middleware = mw_ep.load()
+        app = Middleware(app, config)
     # Required for pylons
     app = RoutesMiddleware(app, config['routes.map'])
     # Required for sessions

http://git-wip-us.apache.org/repos/asf/allura/blob/8eaa8f93/Allura/docs/extending.rst
----------------------------------------------------------------------
diff --git a/Allura/docs/extending.rst b/Allura/docs/extending.rst
index 5a0170f..59025b1 100644
--- a/Allura/docs/extending.rst
+++ b/Allura/docs/extending.rst
@@ -37,6 +37,7 @@ The available extension points for Allura are:
 * :mod:`allura.lib.package_path_loader` (for overriding templates)
 * ``[allura.timers]`` functions which return a list or single :class:`timermiddleware.Timer`
which will be included in stats.log timings
 * :mod:`allura.ext.user_profile`
+* ``[allura.middleware]`` classes, which are standard WSGI middleware.  They will recieve
the ``app`` instance and a ``config`` dict as constructor parameters.  The middleware will
be used for all requests.
 
 A listing of available 3rd-party extensions is at https://forge-allura.apache.org/p/allura/wiki/Extensions/
 


Mime
View raw message