示例#1
0
def azure():
    if not check_config_file(['idp']):
        configure_azure()
    auth_image = image.get_image('azure')

    with open(CLI_ROOT + '/.env', 'w') as file:
        file.write('NONE=')
        file.close()

    envs = {}
    while True:
        idp_file = get_idp_file()
        try:
            envs = {
                'AZURE_TENANT_ID': idp_file['azure']['azure_tenant_id'],
                'AZURE_APP_ID_URI': idp_file['azure']['azure_app_id_uri']
            }
        except KeyError:
            click.echo(
                '\nYou do not have any Azure IDP configured, starting configuration.\n'
            )
            configure_azure()
        except Exception:
            click.echo(click.style('ERROR ', fg='red') + 'Unexpected error.\n')
            raise

        if not envs == {}:
            break

    credentials_volume = CLI_ROOT + '/.env:/work/.env'
    container.create(image=auth_image,
                     volumes=[credentials_volume],
                     environment=envs)

    shutil.move(CLI_ROOT + '/.env', CLI_ROOT + '/secrets')
示例#2
0
def gsuite(auth_image=None):
    if not check_config_file(['idp']):
        configure_gsuite()
    auth_image = image.get_image('gsuite')

    with open(CLI_ROOT + '/.env', 'w') as file:
        file.write('NONE=')
        file.close()

    envs = {}
    while True:
        try:
            idp_file = get_idp_file()
            envs = {
                'GOOGLE_IDP_ID': idp_file['gsuite']['google_idp_id'],
                'GOOGLE_SP_ID': idp_file['gsuite']['google_sp_id']
            }
        except KeyError:
            click.echo(
                '\nYou do not have any GSuite IDP configured, starting configuration.\n'
            )
            configure_gsuite()
        except Exception:
            click.echo(click.style('ERROR ', fg='red') + 'Unexpected error.\n')
            raise

        if not envs == {}:
            break

    credentials_volume = CLI_ROOT + ':/work'
    container.create(image=auth_image,
                     volumes=[credentials_volume],
                     environment=envs)

    shutil.move(CLI_ROOT + '/.env', CLI_ROOT + '/secrets')
示例#3
0
def configure_gsuite():
    answers = prompt(GSUITE_QUESTIONS, style=style)
    if not bool(answers):
        raise SystemExit
    idp_file = get_idp_file()
    idp_file['gsuite'] = {
        'google_idp_id': answers['GOOGLE_IDP_ID'],
        'google_sp_id': answers['GOOGLE_SP_ID']
    }

    write_config(idp_file, '/idp')
    click.echo('\n')
示例#4
0
def configure_okta():
    answers = prompt(OKTA_QUESTIONS, style=style)
    if not bool(answers):
        raise SystemExit
    idp_file = get_idp_file()
    idp_file['okta'] = {
        'okta_org': answers['OKTA_ORG'],
        'okta_aws_app_url': answers['OKTA_AWS_APP_URL'],
        'okta_aws_default_region': answers['OKTA_AWS_DEFAULT_REGION']
    }

    write_config(idp_file, '/idp')
    click.echo('\n')
示例#5
0
def configure_azure():
    answers = prompt(AZURE_QUESTIONS, style=style)
    if not bool(answers):
        raise SystemExit

    idp_file = get_idp_file()
    idp_file['azure'] = {
        'AZURE_TENANT_ID': answers['AZURE_TENANT_ID'],
        'AZURE_APP_ID_URI': answers['AZURE_APP_ID_URI']
    }

    write_config(idp_file, '/idp')
    click.echo('\n')
示例#6
0
def okta():
    if not check_config_file(['idp']):
        configure_okta()
    auth_image = image.get_image('okta')
    credentials_volume = CLI_ROOT + ':/work'

    idp_file = get_idp_file()
    envs = {
        'OKTA_ORG': idp_file['okta']['okta_org'],
        'OKTA_AWS_APP_URL': idp_file['okta']['okta_aws_app_url'],
        'OKTA_AWS_DEFAULT_REGION': idp_file['okta']['okta_aws_default_region']
    }

    container.create(image=auth_image,
                     volumes=[credentials_volume],
                     environment=envs)

    shutil.move(CLI_ROOT + '/.env', CLI_ROOT + '/secrets')