Пример #1
0
def write_jaas_config_file(primary: str, task: str, krb5: object) -> str:
    output_file = "{primary}-client-jaas.config".format(primary=primary)

    LOG.info("Generating %s", output_file)

    # TODO: use kafka_client keytab path
    jaas_file_contents = [
        'KafkaClient {',
        '    com.sun.security.auth.module.Krb5LoginModule required',
        '    doNotPrompt=true',
        '    useTicketCache=true',
        '    principal=\\"{primary}@{realm}\\"'.format(primary=primary,
                                                       realm=krb5.get_realm()),
        '    useKeyTab=true',
        '    serviceName=\\"kafka\\"',
        '    keyTab=\\"/tmp/kafkaconfig/kafka-client.keytab\\"',
        '    client=true;',
        '};',
    ]

    output = sdk_cmd.create_task_text_file(task, output_file,
                                           jaas_file_contents)
    LOG.info(output)

    return output_file
Пример #2
0
def write_krb5_config_file(
    task: str,
    filename: str,
    krb5: sdk_auth.KerberosEnvironment,
) -> str:
    """
    Generate a Kerberos config file.
    """
    output_file = filename

    log.info("Generating %s", output_file)
    krb5_file_contents = [
        "[libdefaults]",
        "default_realm = {}".format(krb5.get_realm()),
        "",
        "[realms]",
        "  {realm} = {{".format(realm=krb5.get_realm()),
        "    kdc = {}".format(krb5.get_kdc_address()),
        "  }",
    ]
    log.info("%s", krb5_file_contents)

    output = sdk_cmd.create_task_text_file(task, output_file,
                                           krb5_file_contents)
    log.info(output)

    return output_file
Пример #3
0
def write_krb5_config_file(task: str, krb5: object) -> str:
    output_file = "krb5.config"

    LOG.info("Generating %s", output_file)

    try:
        # TODO: Set realm and kdc properties
        krb5_file_contents = [
            '[libdefaults]',
            'default_realm = {}'.format(krb5.get_realm()),
            '',
            '[realms]',
            '  {realm} = {{'.format(realm=krb5.get_realm()),
            '    kdc = {}'.format(krb5.get_kdc_address()),
            '  }',
        ]
        log.info("%s", krb5_file_contents)
    except Exception as e:
        log.error("%s", e)
        raise (e)

    output = sdk_cmd.create_task_text_file(task, output_file,
                                           krb5_file_contents)
    LOG.info(output)

    return output_file
Пример #4
0
def write_krb5_config_file(
    task: str,
    filename: str,
    krb5: sdk_auth.KerberosEnvironment,
) -> str:
    """
    Generate a Kerberos config file.
    """
    output_file = filename

    log.info("Generating %s", output_file)
    krb5_file_contents = [
        "[libdefaults]",
        "default_realm = {}".format(krb5.get_realm()),
        "",
        "[realms]",
        "  {realm} = {{".format(realm=krb5.get_realm()),
        "    kdc = {}".format(krb5.get_kdc_address()),
        "  }",
    ]
    log.info("%s", krb5_file_contents)

    output = sdk_cmd.create_task_text_file(task, output_file, krb5_file_contents)
    log.info(output)

    return output_file
Пример #5
0
def write_client_properties(id: str, marathon_task: str, lines: list) -> str:
    """Write a client properties file containing the specified lines"""

    output_file = "{id}-client.properties".format(id=id)

    LOG.info("Generating %s", output_file)
    output = sdk_cmd.create_task_text_file(marathon_task, output_file, lines)
    LOG.info(output)

    return output_file
Пример #6
0
def write_client_properties(id: str, task: str, lines: list) -> str:
    """Write a client properties file containing the specified lines"""

    output_file = "{id}-client.properties".format(id=id)

    LOG.info("Generating %s", output_file)
    output = sdk_cmd.create_task_text_file(task, output_file, lines)
    LOG.info(output)

    return output_file
Пример #7
0
def write_krb5_config_file(task: str, filename: str, krb5: object) -> str:
    """
    Generate a Kerberos config file.
    """
    output_file = filename

    log.info("Generating %s", output_file)
    krb5_file_contents = ['[libdefaults]',
                          'default_realm = {}'.format(krb5.get_realm()),
                          '',
                          '[realms]',
                          '  {realm} = {{'.format(realm=krb5.get_realm()),
                          '    kdc = {}'.format(krb5.get_kdc_address()),
                          '  }', ]
    log.info("%s", krb5_file_contents)

    output = sdk_cmd.create_task_text_file(task, output_file, krb5_file_contents)
    log.info(output)

    return output_file
Пример #8
0
def write_jaas_config_file(primary: str, marathon_task: str, krb5: object) -> str:
    output_file = "{primary}-client-jaas.config".format(primary=primary)

    LOG.info("Generating %s", output_file)

    # TODO: use kafka_client keytab path
    jaas_file_contents = ['KafkaClient {',
                          '    com.sun.security.auth.module.Krb5LoginModule required',
                          '    doNotPrompt=true',
                          '    useTicketCache=true',
                          '    principal=\\"{primary}@{realm}\\"'.format(primary=primary, realm=krb5.get_realm()),
                          '    useKeyTab=true',
                          '    serviceName=\\"kafka\\"',
                          '    keyTab=\\"/tmp/kafkaconfig/kafka-client.keytab\\"',
                          '    client=true;',
                          '};', ]

    output = sdk_cmd.create_task_text_file(marathon_task, output_file, jaas_file_contents)
    LOG.info(output)

    return output_file
def write_krb5_config_file(task: str, filename: str, krb5: object) -> str:
    """
    Generate a Kerberos config file.
    """
    output_file = filename

    log.info("Generating %s", output_file)
    krb5_file_contents = [
        '[libdefaults]',
        'default_realm = {}'.format(krb5.get_realm()),
        '',
        '[realms]',
        '  {realm} = {{'.format(realm=krb5.get_realm()),
        '    kdc = {}'.format(krb5.get_kdc_address()),
        '  }',
    ]
    log.info("%s", krb5_file_contents)

    output = sdk_cmd.create_task_text_file(task, output_file,
                                           krb5_file_contents)
    log.info(output)

    return output_file
Пример #10
0
def write_krb5_config_file(task: str, filename: str, krb5: object) -> str:
    """
    Generate a Kerberos config file.
    TODO(elezar): This duplicates functionality in frameworks/kafka/tests/auth.py
    """
    output_file = filename

    log.info("Generating %s", output_file)
    krb5_file_contents = [
        '[libdefaults]',
        'default_realm = {}'.format(krb5.get_realm()),
        '',
        '[realms]',
        '  {realm} = {{'.format(realm=krb5.get_realm()),
        '    kdc = {}'.format(krb5.get_kdc_address()),
        '  }',
    ]
    log.info("%s", krb5_file_contents)

    output = sdk_cmd.create_task_text_file(task, output_file,
                                           krb5_file_contents)
    log.info(output)

    return output_file