Пример #1
0
def get_test_tool_conf(tool_conf_cls=None, tool_conf_extended=False):
    tc = TOOL_CONFIG_ONE_ISSUES_MANY_CLIENTS if tool_conf_extended else TOOL_CONFIG
    tool_conf = tool_conf_cls(tc) if tool_conf_cls else ToolConfDict(tc)
    for iss, iss_conf in tc.items():
        if isinstance(iss_conf, list):
            for iss_conf_item in iss_conf:
                tool_conf.set_private_key(iss, PRIVATE_KEY, client_id=iss_conf_item['client_id'])
                tool_conf.set_public_key(iss, PUBLIC_KEY, client_id=iss_conf_item['client_id'])
        else:
            tool_conf.set_private_key(iss, PRIVATE_KEY)
            tool_conf.set_public_key(iss, PUBLIC_KEY)
    return tool_conf
Пример #2
0
def get_tool_conf():
    lti_config = settings.LTI_CONFIG

    try:
        config = ToolConfDict(lti_config)
    except Exception as error:
        return error

    # There should be one key per platform
    # and the name relay on platforms generic domain not institution specific
    platform_domain = list(lti_config.keys())[0]
    platform_config = lti_config[platform_domain][0]
    client_id = platform_config['client_id']

    try:
        with open(platform_config.get(
                'private_key_file', '/secrets/private.key'),
                'r') as private_key_file:
            config.set_private_key(
                platform_domain, private_key_file.read(), client_id)

        with open(platform_config.get(
                'public_key_file', '/secrets/public.key'),
                'r') as public_key_file:
            config.set_public_key(
                platform_domain, public_key_file.read(), client_id)

    except OSError as error:
        return error

    return config
def get_tool_conf():
    lti_config = settings.LTI_CONFIG
    try:
        tool_config = ToolConfDict(lti_config)
    except Exception as e:
        return e
    # There should be one key per platform and the name relay on platforms generic domain not institution specific
    platform_domain = list(lti_config.keys())[0]
    client_id = lti_config[platform_domain][0]['client_id']
    private_key_file_path = lti_config[platform_domain][0]['private_key_file']
    public_key_file_path = lti_config[platform_domain][0]['public_key_file']
    public_key = public_key_file_path if public_key_file_path else '/secret/public.key'
    private_key = private_key_file_path if private_key_file_path else '/secret/private.key'
    try:
        private_key_content = open(private_key, 'r').read()
        public_key_content = open(public_key, 'r').read()
    except OSError as e:
        return e
    tool_config.set_public_key(platform_domain,
                               public_key_content,
                               client_id=client_id)
    tool_config.set_private_key(platform_domain,
                                private_key_content,
                                client_id=client_id)
    return tool_config
Пример #4
0
def get_test_tool_conf():
    tool_conf = ToolConfDict(TOOL_CONFIG)
    for iss in TOOL_CONFIG:
        tool_conf.set_private_key(iss, PRIVATE_KEY)
    return tool_conf
Пример #5
0
def get_test_tool_conf(tool_conf_cls=None):
    tool_conf = tool_conf_cls(TOOL_CONFIG) if tool_conf_cls else ToolConfDict(
        TOOL_CONFIG)
    for iss in TOOL_CONFIG:
        tool_conf.set_private_key(iss, PRIVATE_KEY)
    return tool_conf