You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2014/10/03 22:33:45 UTC

git commit: [#7732] factor out SourceForge-specific https scheme middleware

Repository: allura
Updated Branches:
  refs/heads/db/7732 660ec3350 -> 51c6e4f24


[#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/51c6e4f2
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/51c6e4f2
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/51c6e4f2

Branch: refs/heads/db/7732
Commit: 51c6e4f2451d298d40c0a5e1170bf778ceeb0f36
Parents: 660ec33
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Oct 3 20:32:38 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Oct 3 20:32:38 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/51c6e4f2/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/51c6e4f2/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/