예제 #1
0
파일: auth.py 프로젝트: dbaty/Lasco
def setup_who_api_factory(config, global_settings, conf_file, dummy=None):
    if dummy is not None:
        who_api_factory = dummy
    else:
        who_api_factory = make_api_factory_with_config(
            global_settings, conf_file)
    config.registry.registerUtility(who_api_factory, IAPIFactory)
예제 #2
0
파일: auth.py 프로젝트: dbaty/Petrel
def setup_who_api_factory(global_config, conf_file, dummy=None):
    global who_api_factory
    if dummy is not None:
        who_api_factory = dummy
    else:
        who_api_factory = make_api_factory_with_config(
            global_config, conf_file)
예제 #3
0
파일: whov2.py 프로젝트: aodag/pyramid_who
 def __init__(self, config_file, identifier_id, callback=_null_callback):
     config_file = self._config_file = os.path.abspath(
         os.path.normpath(os.path.expandvars(os.path.expanduser(config_file)))
     )
     conf_dir, _ = os.path.split(config_file)
     global_conf = {"here": conf_dir}
     self._api_factory = make_api_factory_with_config(global_conf, config_file)
     self._identifier_id = identifier_id
     self._callback = callback
예제 #4
0
def main(_global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    # The next line creates a 'here' setting pointing to the directory
    # containing the repoze.who.ini file.
    # There should be a better way to do this.
    settings['here'] = os.path.dirname(settings['repoze.who.ini'])

    # Create the Pyramid config
    config = Configurator(settings=settings)
    set_cache_regions_from_settings(settings)

    # Authentication
    config.include("pyramid_whoauth")
    repoze_who_factory = make_api_factory_with_config(
        settings,
        settings['repoze.who.ini']
    )
    config.set_authentication_policy(
        WhoAuthenticationPolicy(repoze_who_factory, callback=appauth)
    )
    config.set_authorization_policy(ACLAuthorizationPolicy())
    config.set_root_factory(RootFactory)

    cw_metrics = metrics.Metrics()
    add_service(
        config,
        "metrics",
        cw_metrics.dimension_names,
        'GET'
    )
    add_service(
        config,
        "metrics/{dimension_name}",
        cw_metrics.dimension_values,
        'GET'
    )
    add_service(
        config,
        "metrics/{dimension_name}/{dimension_value}",
        cw_metrics.metrics,
        'GET'
    )

    cw_points = datapoints.Datapoints()
    add_service(
        config,
        "datapoints/{namespace}/{dimension_name}/{dimension_value}/{metric}",
        cw_points.points,
        'GET'
    )

    config.add_static_view('/', 'static', cache_max_age=3600)
    return config.make_wsgi_app()
예제 #5
0
 def __init__(self, config_file, identifier_id, callback=_null_callback):
     log.debug('__init__ : START')
     config_file = self._config_file = os.path.abspath(
         os.path.normpath(
             os.path.expandvars(os.path.expanduser(config_file))))
     conf_dir, _ = os.path.split(config_file)
     global_conf = {'here': conf_dir}
     self._api_factory = make_api_factory_with_config(
         global_conf, config_file)
     self._identifier_id = identifier_id
     self._callback = callback