mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-21 20:59:10 +00:00
keycloak_client: fix diff for keycloak client auth flow overrides (#11455)
* 11430: fix diff for keycloak client auth flow overrides * 11430: add changelog fragment * 11430: move util function merge_settings_without_absent_nulls to the util functions file _keycloak_utils * 11443: code cleanup --------- Co-authored-by: Thomas Bargetz <thomas.bargetz@rise-world.com>
This commit is contained in:
parent
8b0ce3e28f
commit
af4dbafe86
3 changed files with 47 additions and 8 deletions
|
|
@ -768,6 +768,9 @@ import copy
|
|||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils.identity.keycloak._keycloak_utils import (
|
||||
merge_settings_without_absent_nulls,
|
||||
)
|
||||
from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import (
|
||||
KeycloakAPI,
|
||||
KeycloakError,
|
||||
|
|
@ -1364,15 +1367,17 @@ def main():
|
|||
if client_param == "protocol_mappers":
|
||||
new_param_value = [{k: v for k, v in x.items() if v is not None} for x in new_param_value]
|
||||
elif client_param == "authentication_flow_binding_overrides":
|
||||
new_param_value = flow_binding_from_dict_to_model(new_param_value, realm, kc)
|
||||
elif client_param == "attributes" and "attributes" in before_client:
|
||||
attributes_copy = copy.deepcopy(before_client["attributes"])
|
||||
# Merge client attributes while excluding null-valued attributes that are not present in Keycloak's response.
|
||||
# This ensures idempotency by treating absent attributes and null attributes as equivalent.
|
||||
attributes_copy.update(
|
||||
{key: value for key, value in new_param_value.items() if value is not None or key in attributes_copy}
|
||||
desired_flow_binding_overrides = flow_binding_from_dict_to_model(new_param_value, realm, kc)
|
||||
existing_flow_binding_overrides = before_client.get("authenticationFlowBindingOverrides")
|
||||
# ensures idempotency
|
||||
new_param_value = merge_settings_without_absent_nulls(
|
||||
existing_flow_binding_overrides, desired_flow_binding_overrides
|
||||
)
|
||||
new_param_value = attributes_copy
|
||||
elif client_param == "attributes" and "attributes" in before_client:
|
||||
desired_attributes = new_param_value
|
||||
existing_attributes = copy.deepcopy(before_client["attributes"])
|
||||
# ensures idempotency
|
||||
new_param_value = merge_settings_without_absent_nulls(existing_attributes, desired_attributes)
|
||||
elif client_param in ["clientScopesBehavior", "client_scopes_behavior"]:
|
||||
continue
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue