def v3_app_factory(global_conf, **local_conf): controllers.register_version('v3') mapper = routes.Mapper() sub_routers = [] _routers = [] # NOTE(dstanek): Routers should be ordered by their frequency of use in # a live system. This is due to the routes implementation. The most # frequently used routers should appear first. router_modules = [ auth, assignment, catalog, credential, identity, policy, resource, revoke, federation, oauth1 ] if CONF.trust.enabled: router_modules.append(trust) if CONF.endpoint_policy.enabled: router_modules.append(endpoint_policy) for module in router_modules: routers_instance = module.routers.Routers() _routers.append(routers_instance) routers_instance.append_v3_routers(mapper, sub_routers) # Add in the v3 version api sub_routers.append(routers.VersionV3('public', _routers)) return wsgi.ComposingRouter(mapper, sub_routers)
def application_factory(name='public'): if name not in ('admin', 'public'): raise RuntimeError('Application name (for base_url lookup) must be ' 'either `admin` or `public`.') # NOTE(morgan): The Flask App actually dispatches nothing until we migrate # some routers to Flask-Blueprints, it is simply a placeholder. app = flask.Flask(name) # TODO(morgan): Convert Subsystems over to Flask-Native, for now, we simply # dispatch to another "application" [e.g "keystone"] # NOTE(morgan): as each router is converted to flask-native blueprint, # remove from this list. WARNING ORDER MATTERS; ordered dict used to # ensure sane ordering of the routers in the legacy-dispatch model. dispatch_map = collections.OrderedDict() # Load in Healthcheck and map it to /healthcheck hc_app = healthcheck.Healthcheck.app_factory( {}, oslo_config_project='keystone') dispatch_map['/healthcheck'] = hc_app # More legacy code to instantiate all the magic for the dispatchers. # The move to blueprints (FLASK) will allow this to be eliminated. _routers = [] sub_routers = [] mapper = routes.Mapper() for api_routers in ALL_API_ROUTERS: routers_instance = api_routers.Routers() _routers.append(routers_instance) routers_instance.append_v3_routers(mapper, sub_routers) # Add in the v3 version api sub_routers.append(version_routers.VersionV3('public', _routers)) version_controllers.register_version('v3') legacy_dispatcher = keystone_wsgi.ComposingRouter(mapper, sub_routers) for pfx in itertools.chain( *[rtr.Routers._path_prefixes for rtr in ALL_API_ROUTERS]): dispatch_map['/v3/%s' % pfx] = legacy_dispatcher # NOTE(morgan) Move the version routers to Flask Native First! It will # not work well due to how the dispatcher works unless this is first, # otherwise nothing falls through to the native flask app. dispatch_map['/v3'] = legacy_dispatcher # NOTE(morgan): The Root Version Discovery Document is special and needs # it's own mapper/router since the v3 one assumes it owns the root due # to legacy paste-isms where /v3 would be routed to APP=/v3, PATH=/ root_version_disc_mapper = routes.Mapper() root_version_disc_router = version_routers.Versions(name) root_dispatcher = keystone_wsgi.ComposingRouter(root_version_disc_mapper, [root_version_disc_router]) dispatch_map['/'] = root_dispatcher application = KeystoneDispatcherMiddleware(app, dispatch_map) return application
def v3_app_factory(global_conf, **local_conf): controllers.register_version('v3') mapper = routes.Mapper() sub_routers = [] _routers = [] # NOTE(dstanek): Routers should be ordered by their frequency of use in # a live system. This is due to the routes implementation. The most # frequently used routers should appear first. all_api_routers = [ auth_routers, assignment_routers, catalog_routers, credential_routers, identity_routers, policy_routers, resource_routers, revoke_routers, federation_routers, oauth1_routers, # TODO(morganfainberg): Remove the simple_cert router # when PKI and PKIZ tokens are removed. simple_cert_ext ] if CONF.trust.enabled: all_api_routers.append(trust_routers) if CONF.endpoint_policy.enabled: all_api_routers.append(endpoint_policy_routers) for api_routers in all_api_routers: routers_instance = api_routers.Routers() _routers.append(routers_instance) routers_instance.append_v3_routers(mapper, sub_routers) # Add in the v3 version api sub_routers.append(routers.VersionV3('public', _routers)) return wsgi.ComposingRouter(mapper, sub_routers)