allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [2/4] git commit: [#7732] factor out SourceForge-specific https scheme middleware
Date Fri, 03 Oct 2014 21:12:45 GMT
[#7732] factor out SourceForge-specific https scheme middleware


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

Branch: refs/heads/db/7732
Commit: cbe880ba538742f14dc0b92186c66709fb7505da
Parents: c70d486
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Fri Oct 3 20:32:38 2014 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri Oct 3 21:05:53 2014 +0000

----------------------------------------------------------------------
 Allura/allura/config/middleware.py | 24 ++++++++++--------------
 Allura/docs/extending.rst          |  4 +++-
 2 files changed, 13 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/cbe880ba/Allura/allura/config/middleware.py
----------------------------------------------------------------------
diff --git a/Allura/allura/config/middleware.py b/Allura/allura/config/middleware.py
index ab0d400..1a7beb8 100644
--- a/Allura/allura/config/middleware.py
+++ b/Allura/allura/config/middleware.py
@@ -126,9 +126,12 @@ def _make_core_app(root, global_conf, full_stack=True, **app_conf):
                                " the zarkov.host setting in your ini file."
 
     app = tg.TGApp()
+
     for mw_ep in h.iter_entry_points('allura.middleware'):
         Middleware = mw_ep.load()
-        app = Middleware(app, config)
+        if getattr(Middleware, 'when', 'inner') == 'inner':
+            app = Middleware(app, config)
+
     # Required for pylons
     app = RoutesMiddleware(app, config['routes.map'])
     # Required for sessions
@@ -165,6 +168,12 @@ def _make_core_app(root, global_conf, full_stack=True, **app_conf):
     #    streaming=true ensures they won't be cleaned up till
     #    the WSGI application's iterator is exhausted
     app = RegistryManager(app, streaming=True)
+
+    for mw_ep in h.iter_entry_points('allura.middleware'):
+        Middleware = mw_ep.load()
+        if getattr(Middleware, 'when', 'inner') == 'outer':
+            app = Middleware(app, config)
+
     # "task" wsgi would get a 2nd request to /error/document if we used this middleware
     if config.get('override_root') != 'task':
         # Converts exceptions to HTTP errors, shows traceback in debug mode
@@ -173,11 +182,6 @@ def _make_core_app(root, global_conf, full_stack=True, **app_conf):
         app = tg.error.ErrorHandler(
             app, global_conf, **config['pylons.errorware'])
 
-        # Make sure that the wsgi.scheme is set appropriately when we
-        # have the funky HTTP_X_SFINC_SSL  environ var
-        if asbool(app_conf.get('auth.method', 'local') == 'sfx'):
-            app = set_scheme_middleware(app)
-
         # Redirect some status codes to /error/document
         if asbool(config['debug']):
             app = StatusCodeRedirect(app, base_config.handle_status_codes)
@@ -187,14 +191,6 @@ def _make_core_app(root, global_conf, full_stack=True, **app_conf):
     return app
 
 
-def set_scheme_middleware(app):
-    def SchemeMiddleware(environ, start_response):
-        if asbool(environ.get('HTTP_X_SFINC_SSL', 'false')):
-            environ['wsgi.url_scheme'] = 'https'
-        return app(environ, start_response)
-    return SchemeMiddleware
-
-
 def allura_globals_middleware(app):
     def AlluraGlobalsMiddleware(environ, start_response):
         import allura.lib.security

http://git-wip-us.apache.org/repos/asf/allura/blob/cbe880ba/Allura/docs/extending.rst
----------------------------------------------------------------------
diff --git a/Allura/docs/extending.rst b/Allura/docs/extending.rst
index 59025b1..01218c3 100644
--- a/Allura/docs/extending.rst
+++ b/Allura/docs/extending.rst
@@ -37,7 +37,9 @@ 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.
+* ``[allura.middleware]`` classes, which are standard WSGI middleware.  They will receive
the ``app`` instance and a ``config`` dict as constructor parameters.
+  The middleware will be used for all requests.  By default the middleware wraps the base
app directly and other middleware wrap around it.
+  If your middleware needs to wrap around the other Allura middleware (except error handling),
set ``when = 'outer'`` on your middleware.
 
 A listing of available 3rd-party extensions is at https://forge-allura.apache.org/p/allura/wiki/Extensions/
 


Mime
View raw message