From 1e870abd693088d19db023d731310a1f33f2c831 Mon Sep 17 00:00:00 2001 From: Morgan Fainberg Date: Fri, 22 Jun 2018 17:27:36 -0700 Subject: [PATCH] Don't replace the whole app just the wsgi_app backing Do not replace the entire app when wrapping with middleware. It is important to maintain all the flask-functionality on the app object and ensure any/all test client calls go through the entire stack of app and middleware. Partial-Bug: #1776504 Change-Id: I928d08e96b4c79807ad8c312ba17359c54b67fa0 --- keystone/server/flask/application.py | 6 +++--- keystone/server/flask/core.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/keystone/server/flask/application.py b/keystone/server/flask/application.py index 8cb1e0e689..4aca52ac6f 100644 --- a/keystone/server/flask/application.py +++ b/keystone/server/flask/application.py @@ -230,7 +230,7 @@ def application_factory(name='public'): rtr in ALL_API_ROUTERS]): dispatch_map['/v3/%s' % pfx] = legacy_dispatcher - application = KeystoneDispatcherMiddleware( - app, + app.wsgi_app = KeystoneDispatcherMiddleware( + app.wsgi_app, dispatch_map) - return application + return app diff --git a/keystone/server/flask/core.py b/keystone/server/flask/core.py index 4accdf3612..c7ae055e8c 100644 --- a/keystone/server/flask/core.py +++ b/keystone/server/flask/core.py @@ -122,10 +122,10 @@ def setup_app_middleware(app): # local_conf, this is all a hold-over from paste-ini and pending # reworking/removal(s) factory_func = loaded.driver.factory({}, **mw.conf) - app = factory_func(app) + app.wsgi_app = factory_func(app.wsgi_app) # Apply werkzeug speficic middleware - app = fixers.ProxyFix(app) + app.wsgi_app = fixers.ProxyFix(app.wsgi_app) return app