Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for token_bound_cidrs to hashivault_auth_ldap #493

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ansible/modules/hashivault/hashivault_auth_ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@
userfilter:
description:
- LDAP filter that will determine if a user has permission to authenticate to Vault
token_bound_cidrs:
description:
- List of CIDR blocks; if set, specifies blocks of IP addresses which can authenticate successfully, and
ties the resulting token to these blocks as well.
extends_documentation_fragment: hashivault
'''
EXAMPLES = '''
Expand Down Expand Up @@ -157,6 +161,7 @@ def main():
argspec['use_token_groups'] = dict(required=False, type='bool', default=False)
argspec['token_ttl'] = dict(required=False, type='int', default=0)
argspec['token_max_ttl'] = dict(required=False, type='int', default=0)
argspec['token_bound_cidrs'] = dict(required=False, type='list', default=[])

module = hashivault_init(argspec, supports_check_mode=True)
result = hashivault_auth_ldap(module)
Expand Down Expand Up @@ -194,6 +199,7 @@ def hashivault_auth_ldap(module):
desired_state['use_token_groups'] = params.get('use_token_groups')
desired_state['token_ttl'] = params.get('token_ttl')
desired_state['token_max_ttl'] = params.get('token_max_ttl')
desired_state['token_bound_cidrs'] = params.get('token_bound_cidrs')

# if bind pass is None, remove it from desired state since we can't compare
if desired_state['bind_pass'] is None:
Expand Down Expand Up @@ -225,6 +231,7 @@ def hashivault_auth_ldap(module):
current_state['starttls'] = result['starttls']
current_state['token_ttl'] = result['token_ttl']
current_state['token_max_ttl'] = result['token_max_ttl']
current_state['token_bound_cidrs'] = result['token_bound_cidrs']
except InvalidPath:
pass

Expand Down
Loading