Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setup(*args, **kwargs):
"""Set a KeystoneAuthBackend as the auth backend.
Loads keystone settings from hil.cfg.
"""
if not cfg.has_section(__name__):
logger.error('No section for [%s] in hil.cfg; authentication will '
'not work without this. Please add this section and try '
'again.', __name__)
sys.exit(1)
keystone_cfg = {}
for key in cfg.options(__name__):
keystone_cfg[key] = cfg.get(__name__, key)
# Great job with the API design Openstack!
factory = filter_factory(keystone_cfg)
app.wsgi_app = factory(app.wsgi_app)
auth.set_auth_backend(KeystoneAuthBackend())
def setup(*args, **kwargs):
"""Set a KeystoneAuthBackend as the auth backend.
Loads keystone settings from hil.cfg.
"""
if not cfg.has_section(__name__):
logger.error('No section for [%s] in hil.cfg; authentication will '
'not work without this. Please add this section and try '
'again.', __name__)
sys.exit(1)
keystone_cfg = {}
for key in cfg.options(__name__):
keystone_cfg[key] = cfg.get(__name__, key)
# Great job with the API design Openstack!
factory = filter_factory(keystone_cfg)
app.wsgi_app = factory(app.wsgi_app)
auth.set_auth_backend(KeystoneAuthBackend())
def deploy(conf, project_name):
"""Assemble the middleware pipeline leading to the placement app."""
if conf.api.auth_strategy == 'noauth2':
auth_middleware = auth.NoAuthMiddleware
else:
# Do not use 'oslo_config_project' param here as the conf
# location may have been overridden earlier in the deployment
# process with OS_PLACEMENT_CONFIG_DIR in wsgi.py.
auth_middleware = auth_token.filter_factory(
{}, oslo_config_config=conf)
# Pass in our CORS config, if any, manually as that's a)
# explicit, b) makes testing more straightfoward, c) let's
# us control the use of cors by the presence of its config.
conf.register_opts(cors.CORS_OPTS, 'cors')
if conf.cors.allowed_origin:
cors_middleware = oslo_middleware.CORS.factory(
{}, **conf.cors)
else:
cors_middleware = None
context_middleware = auth.PlacementKeystoneContext
req_id_middleware = oslo_middleware.RequestId
microversion_middleware = microversion.MicroversionMiddleware
fault_wrap = common_api.FaultWrapper
bp = ext.plugin()
app.register_blueprint(bp, url_prefix=bp.url_prefix)
for code in werkzeug_exceptions.default_exceptions:
app.register_error_handler(code, make_json_error)
if cfg.CONF.debug and not cfg.CONF.log_exchange:
LOG.debug('Logging of request/response exchange could be enabled '
'using flag --log_exchange')
if cfg.CONF.log_exchange:
app.wsgi_app = debug.Debug.factory(app.config)(app.wsgi_app)
app.wsgi_app = request_id.BlazarReqIdMiddleware(app.wsgi_app)
app.wsgi_app = request_log.RequestLog(app.wsgi_app)
app.wsgi_app = auth_token.filter_factory(app.config)(app.wsgi_app)
return app