def start_plugin(config): register_middleware(BOTTOM, SparqlEndpointMiddleware) if config.has_section('sparql') and config.has_option( 'sparql', 'full_dataset'): warn( "sparql.full_dataset option is deprecared. Use scope parameter instead." )
def start_plugin(_config): """I get the configuration values from the main kTBS configuration. .. note:: This function is called automatically by the kTBS. It is called once when the kTBS starts, not at each request. """ registered_oauth_flows = { 'oauth_github': github_flow, 'oauth_claco': claco_flow } def section_dict(section_name): """Convert a configuration section to a Python dictionary""" if _config.has_section(section_name): return { opt_key: opt_value for opt_key, opt_value in _config.items(section_name) } else: return None global OAUTH_CONFIG, IP_WHITELIST, ADMIN_CREDENTIALS_HASH, SESSION_CONFIG, ENABLE_BEAKER try: ENABLE_BEAKER = _config.getboolean('authx', 'enable_beaker') except NoOptionError: # if we didn't set the `enable_beaker` option in the config, we set it to true by default ENABLE_BEAKER = True authx_config = section_dict('authx') # Session management session_config_keys = filter(lambda k: k.startswith('beaker.session.'), authx_config) SESSION_CONFIG = {k: authx_config[k] for k in session_config_keys} # Identity provider management ip_name = authx_config['oauth_flow'] OAUTH_CONFIG = section_dict(ip_name) OAUTH_CONFIG['flow'] = registered_oauth_flows[ip_name] # Admin credentials management admin_auth_config = section_dict('authx_admin') if admin_auth_config: IP_WHITELIST = admin_auth_config['ip_whitelist'].split(' ') ADMIN_CREDENTIALS_HASH = standard_b64encode( admin_auth_config['login'] + ':' + admin_auth_config['password']) register_middleware(SESSION, AuthSessionMiddleware) # We register two functions to call (in order) at each request register_pre_processor(AUTHENTICATION, preproc_authentication) register_pre_processor(AUTHORIZATION, preproc_authorization)
def start_plugin(config): #pylint: disable=W0603 global ALLOW_ORIGIN deprecated_allow_origin = config.get('server', 'cors-allow-origin') if deprecated_allow_origin: LOG.warning("configuration server.cors-allow-origin is deprecated; " "use cors.allow-origin instead") ALLOW_ORIGIN = deprecated_allow_origin.split(" ") allow_origin = config.get('cors', 'allow-origin') if allow_origin: ALLOW_ORIGIN = allow_origin.split(" ") register_middleware(TOP, CorsMiddleware)
def start_plugin(_config): """I get the configuration values from the main kTBS configuration. .. note:: This function is called automatically by the kTBS. It is called once when the kTBS starts, not at each request. """ registered_oauth_flows = {'oauth_github': github_flow, 'oauth_claco': claco_flow} def section_dict(section_name): """Convert a configuration section to a Python dictionary""" if _config.has_section(section_name): return {opt_key: opt_value for opt_key, opt_value in _config.items(section_name)} else: return None global OAUTH_CONFIG, IP_WHITELIST, ADMIN_CREDENTIALS_HASH, SESSION_CONFIG, ENABLE_BEAKER try: ENABLE_BEAKER = _config.getboolean('authx', 'enable_beaker') except NoOptionError: # if we didn't set the `enable_beaker` option in the config, we set it to true by default ENABLE_BEAKER = True authx_config = section_dict('authx') # Session management session_config_keys = filter(lambda k: k.startswith('beaker.session.'), authx_config) SESSION_CONFIG = {k: authx_config[k] for k in session_config_keys} # Identity provider management ip_name = authx_config['oauth_flow'] OAUTH_CONFIG = section_dict(ip_name) OAUTH_CONFIG['flow'] = registered_oauth_flows[ip_name] # Admin credentials management admin_auth_config = section_dict('authx_admin') if admin_auth_config: IP_WHITELIST = admin_auth_config['ip_whitelist'].split(' ') ADMIN_CREDENTIALS_HASH = standard_b64encode(admin_auth_config['login'] + ':' + admin_auth_config['password']) register_middleware(SESSION, AuthSessionMiddleware) # We register two functions to call (in order) at each request register_pre_processor(AUTHENTICATION, preproc_authentication) register_pre_processor(AUTHORIZATION, preproc_authorization)
def start_plugin(config): register_middleware(TOP, ProfilerMiddleware) if config.has_section('profiler') and config.has_option( 'profiler', 'directory'): ProfilerMiddleware.DIRECTORY = config.get('profiler', 'directory')
def start_plugin(config): if config.has_section('sparql') and config.has_option( 'sparql', 'update_endpoints'): SparqlEndpointMiddleware.UPDATE = config.getboolean( 'sparql', 'update_endpoints') register_middleware(BOTTOM, SparqlEndpointMiddleware)
def start_plugin(config): if config.has_section('profiler') and config.has_option('profiler', 'directory'): ProfilerMiddleware.DIRECTORY = config.get('profiler', 'directory') register_middleware(TOP, ProfilerMiddleware)
def start_plugin(config): register_middleware(BOTTOM, SparqlEndpointMiddleware) if config.has_section('sparql') and config.has_option('sparql', 'full_dataset'): warn("sparql.full_dataset option is deprecared. Use scope parameter instead.")
def start_plugin(config): if config.has_section('sparql') and config.has_option('sparql', 'update_endpoints'): SparqlEndpointMiddleware.UPDATE = config.getboolean('sparql', 'update_endpoints') register_middleware(BOTTOM, SparqlEndpointMiddleware)