Internally defined middleware don't use stevedore
For internally defined middleware (URL Normalizer and AuthContext) Do not use stevedore to load, apply directly. This also cleans up a lingering entry in the setup.cfg for token_auth. Test Changes: * entry points test no longer looks for url_normalize and build_auth_context Change-Id: I58d3c23ad4f70668ada4eae94a94d3f5fe750b3b Partial-Bug: #1776504
This commit is contained in:
parent
1c05f5f88d
commit
18d597f8e8
@ -27,6 +27,7 @@ oslo_i18n.enable_lazy()
|
|||||||
|
|
||||||
from keystone.common import profiler
|
from keystone.common import profiler
|
||||||
import keystone.conf
|
import keystone.conf
|
||||||
|
import keystone.middleware
|
||||||
import keystone.server
|
import keystone.server
|
||||||
from keystone.server.flask import application
|
from keystone.server.flask import application
|
||||||
|
|
||||||
@ -51,18 +52,23 @@ _APP_MIDDLEWARE = (
|
|||||||
_Middleware(namespace='keystone.server_middleware',
|
_Middleware(namespace='keystone.server_middleware',
|
||||||
ep='http_proxy_to_wsgi',
|
ep='http_proxy_to_wsgi',
|
||||||
conf={}),
|
conf={}),
|
||||||
_Middleware(namespace='keystone.server_middleware',
|
|
||||||
ep='url_normalize',
|
|
||||||
conf={}),
|
|
||||||
_Middleware(namespace='keystone.server_middleware',
|
_Middleware(namespace='keystone.server_middleware',
|
||||||
ep='osprofiler',
|
ep='osprofiler',
|
||||||
conf={}),
|
conf={}),
|
||||||
_Middleware(namespace='keystone.server_middleware',
|
_Middleware(namespace='keystone.server_middleware',
|
||||||
ep='request_id',
|
ep='request_id',
|
||||||
conf={}),
|
conf={}),
|
||||||
_Middleware(namespace='keystone.server_middleware',
|
)
|
||||||
ep='build_auth_context',
|
|
||||||
conf={}),
|
# NOTE(morgan): ORDER HERE IS IMPORTANT! Each of these middlewares are
|
||||||
|
# implemented/defined explicitly in Keystone Server. They do some level of
|
||||||
|
# lifting to ensure the request is properly handled. It is importat to note
|
||||||
|
# that these will be processed in the order of this list AND after all
|
||||||
|
# middleware defined in _APP_MIDDLEWARE. AuthContextMiddleware should always
|
||||||
|
# be the last element here as long as it is an actual Middleware.
|
||||||
|
_KEYSTONE_MIDDLEWARE = (
|
||||||
|
keystone.middleware.NormalizingFilter,
|
||||||
|
keystone.middleware.AuthContextMiddleware,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -89,6 +95,7 @@ def setup_app_middleware(app):
|
|||||||
# processes the request first.
|
# processes the request first.
|
||||||
|
|
||||||
MW = _APP_MIDDLEWARE
|
MW = _APP_MIDDLEWARE
|
||||||
|
IMW = _KEYSTONE_MIDDLEWARE
|
||||||
|
|
||||||
# Add in optional (config-based) middleware
|
# Add in optional (config-based) middleware
|
||||||
# NOTE(morgan): Each of these may need to be in a specific location
|
# NOTE(morgan): Each of these may need to be in a specific location
|
||||||
@ -99,6 +106,11 @@ def setup_app_middleware(app):
|
|||||||
ep='debug',
|
ep='debug',
|
||||||
conf={}),) + _APP_MIDDLEWARE
|
conf={}),) + _APP_MIDDLEWARE
|
||||||
|
|
||||||
|
# Apply internal-only Middleware (e.g. AuthContextMiddleware). These
|
||||||
|
# are below all externally loaded middleware in request processing.
|
||||||
|
for mw in reversed(IMW):
|
||||||
|
app.wsgi_app = mw(app.wsgi_app)
|
||||||
|
|
||||||
# Apply the middleware to the application.
|
# Apply the middleware to the application.
|
||||||
for mw in reversed(MW):
|
for mw in reversed(MW):
|
||||||
# TODO(morgan): Explore moving this to ExtensionManager, but we
|
# TODO(morgan): Explore moving this to ExtensionManager, but we
|
||||||
|
@ -20,12 +20,10 @@ class TestEntryPoints(test.TestCase):
|
|||||||
def test_entry_point_middleware(self):
|
def test_entry_point_middleware(self):
|
||||||
"""Assert that our list of expected middleware is present."""
|
"""Assert that our list of expected middleware is present."""
|
||||||
expected_names = [
|
expected_names = [
|
||||||
'build_auth_context',
|
|
||||||
'cors',
|
'cors',
|
||||||
'debug',
|
'debug',
|
||||||
'request_id',
|
'request_id',
|
||||||
'sizelimit',
|
'sizelimit',
|
||||||
'url_normalize',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
em = stevedore.ExtensionManager('keystone.server_middleware')
|
em = stevedore.ExtensionManager('keystone.server_middleware')
|
||||||
|
@ -192,8 +192,5 @@ keystone.server_middleware =
|
|||||||
sizelimit = oslo_middleware:RequestBodySizeLimiter
|
sizelimit = oslo_middleware:RequestBodySizeLimiter
|
||||||
http_proxy_to_wsgi = oslo_middleware:HTTPProxyToWSGI
|
http_proxy_to_wsgi = oslo_middleware:HTTPProxyToWSGI
|
||||||
osprofiler = osprofiler.web:WsgiMiddleware
|
osprofiler = osprofiler.web:WsgiMiddleware
|
||||||
url_normalize = keystone.middleware:NormalizingFilter
|
|
||||||
request_id = oslo_middleware:RequestId
|
request_id = oslo_middleware:RequestId
|
||||||
build_auth_context = keystone.middleware:AuthContextMiddleware
|
|
||||||
token_auth = keystone.middleware:TokenAuthMiddleware
|
|
||||||
debug = oslo_middleware:Debug
|
debug = oslo_middleware:Debug
|
||||||
|
Loading…
Reference in New Issue
Block a user