Exemplo n.º 1
0
def config():
    logger.debug('Loading configuration')
    from kaptan import Kaptan
    cfg = Kaptan()
    cfg.import_config({
        'authn': {
            'cookie': {
                'secure': False,
                'session_name': 'sid',
                'id_name': 'uid',
                'max_age': 3600
            },
            'oidc': {
                'provider_protocol': 'http',
            }
        },
        'http_server': {
            'endpoints': {
                'login': {
                    'path': '/auth/login'
                },
                'registration': {
                    'path': '/auth/registration'
                }
            }
        },
        'oidc': {
            'iss': 'https://localhost:8889',
        },
    })
    return cfg
Exemplo n.º 2
0
def _load_config(cfg_path):
    """Load config from a given config file.

    Raises `ValidationError` if the config does not define a session name"""
    config = Kaptan()
    config.import_config(str(cfg_path))
    config = tmuxp.config.expand(config.configuration_data)

    if "session_name" not in config:
        raise ValidationError("No session name configured")

    return config
Exemplo n.º 3
0
class Config:
    def __init__(self):
        import os
        script_path = os.path.dirname(os.path.abspath(__file__))
        self.path_to_config = script_path + "/config.json"
        self.config = Kaptan(handler="json")

    # def write_config(self):
    #     f = open(self.path_to_config,'w')
    #     f.write(self.config.export("json"))
    #     f.close()

    def read_config(self):
        f = open(self.path_to_config, 'r')
        self.config.import_config(f.read())
        f.close()

    def __getitem__(self, item):
        self.read_config()
        return self.config.get(item)

    # overrides the . operator.
    def __getattr__(self, item):
        return self.__getitem__(item)
Exemplo n.º 4
0
def _load_config(file_path):
    cpt = Kaptan()
    return cpt.import_config(file_path)
Exemplo n.º 5
0
def _load_config(file_path):
    cpt = Kaptan()
    return cpt.import_config(file_path)