How to use the bless.request.bless_request.BlessSchema function in bless

To help you get started, we’ve selected a few bless examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Netflix / bless / tests / request / test_bless_request.py View on Github external
def test_validate_multiple_principals(test_input):
    BlessSchema().validate_remote_usernames(test_input)

    schema = BlessSchema()
    schema.context[USERNAME_VALIDATION_OPTION] = USERNAME_VALIDATION_OPTIONS.principal.name
    schema.context[REMOTE_USERNAMES_VALIDATION_OPTION] = USERNAME_VALIDATION_OPTIONS.principal.name
    schema.context[REMOTE_USERNAMES_BLACKLIST_OPTION] = 'balrog'
    schema.validate_remote_usernames(test_input)
github Netflix / bless / tests / request / test_bless_request.py View on Github external
def test_invalid_multiple_principals(test_input):
    with pytest.raises(ValidationError) as e:
        BlessSchema().validate_remote_usernames(test_input)
    assert str(e.value) == 'Principal contains invalid characters.'
github Netflix / bless / tests / request / test_bless_request.py View on Github external
def test_validate_multiple_principals(test_input):
    BlessSchema().validate_remote_usernames(test_input)

    schema = BlessSchema()
    schema.context[USERNAME_VALIDATION_OPTION] = USERNAME_VALIDATION_OPTIONS.principal.name
    schema.context[REMOTE_USERNAMES_VALIDATION_OPTION] = USERNAME_VALIDATION_OPTIONS.principal.name
    schema.context[REMOTE_USERNAMES_BLACKLIST_OPTION] = 'balrog'
    schema.validate_remote_usernames(test_input)
github Netflix / bless / tests / request / test_bless_request.py View on Github external
def test_invalid_user_with_default_context_of_useradd():
    with pytest.raises(ValidationError) as e:
        BlessSchema().validate_bastion_user('user#invalid')
    assert str(e.value) == 'Username contains invalid characters.'
github Netflix / bless / bless / aws_lambda / bless_lambda.py View on Github external
raise ValueError('Invalid log level: {}'.format(logging_level))

    logger = logging.getLogger()
    logger.setLevel(numeric_level)

    certificate_validity_before_seconds = config.getint(BLESS_OPTIONS_SECTION,
                                                        CERTIFICATE_VALIDITY_BEFORE_SEC_OPTION)
    certificate_validity_after_seconds = config.getint(BLESS_OPTIONS_SECTION,
                                                       CERTIFICATE_VALIDITY_AFTER_SEC_OPTION)
    entropy_minimum_bits = config.getint(BLESS_OPTIONS_SECTION, ENTROPY_MINIMUM_BITS_OPTION)
    random_seed_bytes = config.getint(BLESS_OPTIONS_SECTION, RANDOM_SEED_BYTES_OPTION)
    ca_private_key = config.getprivatekey()
    certificate_extensions = config.get(BLESS_OPTIONS_SECTION, CERTIFICATE_EXTENSIONS_OPTION)

    # Process cert request
    schema = BlessSchema(strict=True)
    schema.context[USERNAME_VALIDATION_OPTION] = config.get(BLESS_OPTIONS_SECTION, USERNAME_VALIDATION_OPTION)
    schema.context[REMOTE_USERNAMES_VALIDATION_OPTION] = config.get(BLESS_OPTIONS_SECTION,
                                                                    REMOTE_USERNAMES_VALIDATION_OPTION)
    schema.context[REMOTE_USERNAMES_BLACKLIST_OPTION] = config.get(BLESS_OPTIONS_SECTION,
                                                                   REMOTE_USERNAMES_BLACKLIST_OPTION)

    try:
        request = schema.load(event).data
    except ValidationError as e:
        return error_response('InputValidationError', str(e))

    logger.info('Bless lambda invoked by [user: {0}, bastion_ips:{1}, public_key: {2}, kmsauth_token:{3}]'.format(
        request.bastion_user,
        request.bastion_user_ip,
        request.public_key_to_sign,
        request.kmsauth_token))