Esempio n. 1
0
def wsgi_app(inner_app_v2=None,
             fake_auth=True,
             fake_auth_context=None,
             use_no_auth=False,
             ext_mgr=None):
    if not inner_app_v2:
        inner_app_v2 = router.APIRouter(ext_mgr)

    if fake_auth:
        if fake_auth_context is not None:
            ctxt = fake_auth_context
        else:
            ctxt = context.RequestContext('fake', 'fake', auth_token=True)
        api_v2 = fault.FaultWrapper(auth.InjectContext(ctxt, inner_app_v2))
    elif use_no_auth:
        api_v2 = fault.FaultWrapper(
            auth.NoAuthMiddleware(limits.RateLimitingMiddleware(inner_app_v2)))
    else:
        api_v2 = fault.FaultWrapper(
            auth.AuthMiddleware(limits.RateLimitingMiddleware(inner_app_v2)))

    mapper = urlmap.URLMap()
    mapper['/v2'] = api_v2
    mapper['/'] = fault.FaultWrapper(versions.Versions())
    return mapper
Esempio n. 2
0
def wsgi_app(inner_app_v2=None,
             fake_auth=True,
             fake_auth_context=None,
             use_no_auth=False,
             ext_mgr=None,
             inner_app_v3=None):

    if not inner_app_v3:
        inner_app_v3 = router_v3.APIRouter(ext_mgr)

    if fake_auth:
        if fake_auth_context is not None:
            ctxt = fake_auth_context
        else:
            ctxt = context.RequestContext(fake.USER_ID,
                                          fake.PROJECT_ID,
                                          auth_token=True)
        api_v3 = fault.FaultWrapper(auth.InjectContext(ctxt, inner_app_v3))
    elif use_no_auth:
        api_v3 = fault.FaultWrapper(
            auth.NoAuthMiddleware(limits.RateLimitingMiddleware(inner_app_v3)))
    else:
        api_v3 = fault.FaultWrapper(
            auth.AuthMiddleware(limits.RateLimitingMiddleware(inner_app_v3)))

    mapper = urlmap.URLMap()
    mapper['/v3'] = api_v3
    mapper['/'] = fault.FaultWrapper(versions.VersionsController())
    return mapper