From 147ca2fe66a7b80b5e6f607315210c7d087d2ab3 Mon Sep 17 00:00:00 2001 From: Gaetan2907 <48204380+Gaetan2907@users.noreply.github.com> Date: Sun, 26 Sep 2021 13:30:29 +0200 Subject: [PATCH] Keycloak: Fix bug on keycloak_authentication, requirement not always updated (#3330) * Fix diff mode when updating authentication flow with keycloak_authentication module * Update documentation of create_or_update_executions function (return tuple instead of dict) * Fix: Update requirement when new exex created * Add changelog fragment * Update changelogs/fragments/3330-bugfix-keycloak-authentication-flow-requirements-not-set-correctly.yml.yml Co-authored-by: Felix Fontein * Update changelogs/fragments/3330-bugfix-keycloak-authentication-flow-requirements-not-set-correctly.yml.yml Co-authored-by: Felix Fontein * Edit requirement of sublow Co-authored-by: Felix Fontein --- ...uthentication-flow-requirements-not-set-correctly.yml.yml | 3 +++ plugins/modules/identity/keycloak/keycloak_authentication.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/3330-bugfix-keycloak-authentication-flow-requirements-not-set-correctly.yml.yml diff --git a/changelogs/fragments/3330-bugfix-keycloak-authentication-flow-requirements-not-set-correctly.yml.yml b/changelogs/fragments/3330-bugfix-keycloak-authentication-flow-requirements-not-set-correctly.yml.yml new file mode 100644 index 0000000000..bcd2e594d7 --- /dev/null +++ b/changelogs/fragments/3330-bugfix-keycloak-authentication-flow-requirements-not-set-correctly.yml.yml @@ -0,0 +1,3 @@ +bugfixes: + - keycloak_authentication - fix bug, the requirement was always on ``DISABLED`` when creating a new authentication flow + (https://github.com/ansible-collections/community.general/pull/3330). diff --git a/plugins/modules/identity/keycloak/keycloak_authentication.py b/plugins/modules/identity/keycloak/keycloak_authentication.py index 8a33409b58..5a48eab2ce 100644 --- a/plugins/modules/identity/keycloak/keycloak_authentication.py +++ b/plugins/modules/identity/keycloak/keycloak_authentication.py @@ -195,7 +195,6 @@ def create_or_update_executions(kc, config, realm='master'): :param kc: Keycloak API access. :param config: Representation of the authentication flow including it's executions. :param realm: Realm - :return: True if executions have been modified. False otherwise. :return: tuple (changed, dict(before, after) WHERE bool changed indicates if changes have been made @@ -235,10 +234,14 @@ def create_or_update_executions(kc, config, realm='master'): elif new_exec["providerId"] is not None: kc.create_execution(new_exec, flowAlias=flow_alias_parent, realm=realm) exec_found = True + exec_index = new_exec_index + id_to_update = kc.get_executions_representation(config, realm=realm)[exec_index]["id"] after += str(new_exec) + '\n' elif new_exec["displayName"] is not None: kc.create_subflow(new_exec["displayName"], flow_alias_parent, realm=realm) exec_found = True + exec_index = new_exec_index + id_to_update = kc.get_executions_representation(config, realm=realm)[exec_index]["id"] after += str(new_exec) + '\n' if exec_found: changed = True