Skip to content

Commit

Permalink
Remove password from return object in ldap auth provider
Browse files Browse the repository at this point in the history
We are hiding password value in the ldap_auth_provider
module return object as passwords are visible from
what Sensu Go backend returns.
  • Loading branch information
Miha Dolinar authored and tadeboro committed Apr 29, 2021
1 parent 330edee commit 7130e1a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions plugins/modules/ldap_auth_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@
client_key_file: '/path/to/ssl/key.pem'
binding:
user_dn: 'cn=binder,dc=acme,dc=org'
password: 'YOUR_PASSWORD'
group_search:
base_dn: 'dc=acme,dc=org'
attribute: 'member'
Expand All @@ -220,6 +219,15 @@
API_VERSION = "authentication/v2"


def remove_item(result):
if result:
for server in result["servers"]:
if server["binding"] and "password" in server["binding"]:
del server["binding"]["password"]

return result


def _filter(payload):
# Remove keys with None values from dict
return dict((k, v) for k, v in payload.items() if v is not None)
Expand Down Expand Up @@ -361,7 +369,7 @@ def main():
changed, ldap_provider = utils.sync_v1(
module.params["state"], client, path, payload, module.check_mode, do_differ
)
module.exit_json(changed=changed, object=ldap_provider)
module.exit_json(changed=changed, object=remove_item(ldap_provider))
except errors.Error as e:
module.fail_json(msg=str(e))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
- result.object.servers.0.client_cert_file == '/path/to/ssl/cert.pem'
- result.object.servers.0.client_key_file == '/path/to/ssl/key.pem'
- result.object.servers.0.binding.user_dn == 'cn=binder,dc=acme,dc=org'
- result.object.servers.0.binding.password == 'VALUE_SPECIFIED_IN_NO_LOG_PARAMETER'
- "'password' not in result.object.servers.0.binding"
- result.object.servers.0.group_search.base_dn == 'dc=acme,dc=org'
- result.object.servers.0.group_search.attribute == 'member'
- result.object.servers.0.group_search.name_attribute == 'cn'
Expand Down

0 comments on commit 7130e1a

Please sign in to comment.