1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

keycloak_client: avoid TypeError if result["attributes"] is a list (#8403)

* fix(keycloak_client): avoid TypeError if attributes is a list

As sanitize_cr might be executed after normalise_cr, result['attributes'] can be of type list and we
run into:

TypeError: list indices must be integers or slices, not str

* Update changelog fragment.

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Thomas Bach 2024-05-26 21:07:48 +02:00 committed by GitHub
parent 43cb5a0d54
commit 572caeaa39
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- keycloak_client - fix TypeError when sanitizing the ``saml.signing.private.key`` attribute in the module's diff or state output. The ``sanitize_cr`` function expected a dict where in some cases a list might occur (https://github.com/ansible-collections/community.general/pull/8403).

View file

@ -775,8 +775,9 @@ def sanitize_cr(clientrep):
if 'secret' in result: if 'secret' in result:
result['secret'] = 'no_log' result['secret'] = 'no_log'
if 'attributes' in result: if 'attributes' in result:
if 'saml.signing.private.key' in result['attributes']: attributes = result['attributes']
result['attributes']['saml.signing.private.key'] = 'no_log' if isinstance(attributes, dict) and 'saml.signing.private.key' in attributes:
attributes['saml.signing.private.key'] = 'no_log'
return normalise_cr(result) return normalise_cr(result)