From af30cdb326f9103da2613cb108580d60c489993b Mon Sep 17 00:00:00 2001 From: Skrekulko Date: Mon, 19 Jun 2023 13:27:55 +0200 Subject: [PATCH 01/10] fix: keep original index --- plugins/modules/keycloak_authentication.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/modules/keycloak_authentication.py b/plugins/modules/keycloak_authentication.py index 966d5b20f78..f95f2c164fc 100644 --- a/plugins/modules/keycloak_authentication.py +++ b/plugins/modules/keycloak_authentication.py @@ -279,6 +279,8 @@ def create_or_update_executions(kc, config, realm='master'): # Compare the executions to see if it need changes if not is_struct_included(new_exec, existing_executions[exec_index], exclude_key) or exec_index != new_exec_index: exec_found = True + if new_exec['index'] is None: + new_exec_index = exec_index before += str(existing_executions[exec_index]) + '\n' id_to_update = existing_executions[exec_index]["id"] # Remove exec from list in case 2 exec with same name From 63bf16ad0293ab41ed72e58e954dae49629b32fa Mon Sep 17 00:00:00 2001 From: Skrekulko Date: Mon, 19 Jun 2023 13:29:21 +0200 Subject: [PATCH 02/10] refac: provider id choice --- plugins/modules/keycloak_authentication.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/keycloak_authentication.py b/plugins/modules/keycloak_authentication.py index f95f2c164fc..517d5165d97 100644 --- a/plugins/modules/keycloak_authentication.py +++ b/plugins/modules/keycloak_authentication.py @@ -333,7 +333,7 @@ def main(): meta_args = dict( realm=dict(type='str', required=True), alias=dict(type='str', required=True), - providerId=dict(type='str'), + providerId=dict(type='str', choices=["basic-flow", "client-flow"], default="basic-flow"), description=dict(type='str'), copyFrom=dict(type='str'), authenticationExecutions=dict(type='list', elements='dict', From 49470e80d58784d526d1aac05bc309080321af34 Mon Sep 17 00:00:00 2001 From: Skrekulko Date: Mon, 19 Jun 2023 14:14:37 +0200 Subject: [PATCH 03/10] refac: default --- plugins/modules/keycloak_authentication.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/keycloak_authentication.py b/plugins/modules/keycloak_authentication.py index 517d5165d97..5e591dee98a 100644 --- a/plugins/modules/keycloak_authentication.py +++ b/plugins/modules/keycloak_authentication.py @@ -333,7 +333,7 @@ def main(): meta_args = dict( realm=dict(type='str', required=True), alias=dict(type='str', required=True), - providerId=dict(type='str', choices=["basic-flow", "client-flow"], default="basic-flow"), + providerId=dict(type='str', choices=["basic-flow", "client-flow"]), description=dict(type='str'), copyFrom=dict(type='str'), authenticationExecutions=dict(type='list', elements='dict', From f8718a4092ca259aa7c64435c470b724483b7aab Mon Sep 17 00:00:00 2001 From: Skrekulko Date: Mon, 19 Jun 2023 14:16:04 +0200 Subject: [PATCH 04/10] fix: missing docs --- plugins/modules/keycloak_authentication.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/modules/keycloak_authentication.py b/plugins/modules/keycloak_authentication.py index 5e591dee98a..ee051191f93 100644 --- a/plugins/modules/keycloak_authentication.py +++ b/plugins/modules/keycloak_authentication.py @@ -43,6 +43,7 @@ providerId: description: - C(providerId) for the new flow when not copied from an existing flow. + choices: [ "basic-flow", "client-flow" ] type: str copyFrom: description: From 858e4e351bd2eb5e01f92f7deeca89b5ac58b007 Mon Sep 17 00:00:00 2001 From: Skrekulko Date: Tue, 20 Jun 2023 08:22:10 +0200 Subject: [PATCH 05/10] fix: ident --- plugins/modules/keycloak_authentication.py | 142 ++++++++++----------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/plugins/modules/keycloak_authentication.py b/plugins/modules/keycloak_authentication.py index ee051191f93..a2c4dd4b3a1 100644 --- a/plugins/modules/keycloak_authentication.py +++ b/plugins/modules/keycloak_authentication.py @@ -110,77 +110,77 @@ ''' EXAMPLES = ''' - - name: Create an authentication flow from first broker login and add an execution to it. - community.general.keycloak_authentication: - auth_keycloak_url: http://localhost:8080/auth - auth_realm: master - auth_username: admin - auth_password: password - realm: master - alias: "Copy of first broker login" - copyFrom: "first broker login" - authenticationExecutions: - - providerId: "test-execution1" - requirement: "REQUIRED" - authenticationConfig: - alias: "test.execution1.property" - config: - test1.property: "value" - - providerId: "test-execution2" - requirement: "REQUIRED" - authenticationConfig: - alias: "test.execution2.property" - config: - test2.property: "value" - state: present - - - name: Re-create the authentication flow - community.general.keycloak_authentication: - auth_keycloak_url: http://localhost:8080/auth - auth_realm: master - auth_username: admin - auth_password: password - realm: master - alias: "Copy of first broker login" - copyFrom: "first broker login" - authenticationExecutions: - - providerId: "test-provisioning" - requirement: "REQUIRED" - authenticationConfig: - alias: "test.provisioning.property" - config: - test.provisioning.property: "value" - state: present - force: true - - - name: Create an authentication flow with subflow containing an execution. - community.general.keycloak_authentication: - auth_keycloak_url: http://localhost:8080/auth - auth_realm: master - auth_username: admin - auth_password: password - realm: master - alias: "Copy of first broker login" - copyFrom: "first broker login" - authenticationExecutions: - - providerId: "test-execution1" - requirement: "REQUIRED" - - displayName: "New Subflow" - requirement: "REQUIRED" - - providerId: "auth-cookie" - requirement: "REQUIRED" - flowAlias: "New Sublow" - state: present - - - name: Remove authentication. - community.general.keycloak_authentication: - auth_keycloak_url: http://localhost:8080/auth - auth_realm: master - auth_username: admin - auth_password: password - realm: master - alias: "Copy of first broker login" - state: absent +- name: Create an authentication flow from first broker login and add an execution to it. + community.general.keycloak_authentication: + auth_keycloak_url: http://localhost:8080/auth + auth_realm: master + auth_username: admin + auth_password: password + realm: master + alias: "Copy of first broker login" + copyFrom: "first broker login" + authenticationExecutions: + - providerId: "test-execution1" + requirement: "REQUIRED" + authenticationConfig: + alias: "test.execution1.property" + config: + test1.property: "value" + - providerId: "test-execution2" + requirement: "REQUIRED" + authenticationConfig: + alias: "test.execution2.property" + config: + test2.property: "value" + state: present + +- name: Re-create the authentication flow + community.general.keycloak_authentication: + auth_keycloak_url: http://localhost:8080/auth + auth_realm: master + auth_username: admin + auth_password: password + realm: master + alias: "Copy of first broker login" + copyFrom: "first broker login" + authenticationExecutions: + - providerId: "test-provisioning" + requirement: "REQUIRED" + authenticationConfig: + alias: "test.provisioning.property" + config: + test.provisioning.property: "value" + state: present + force: true + +- name: Create an authentication flow with subflow containing an execution. + community.general.keycloak_authentication: + auth_keycloak_url: http://localhost:8080/auth + auth_realm: master + auth_username: admin + auth_password: password + realm: master + alias: "Copy of first broker login" + copyFrom: "first broker login" + authenticationExecutions: + - providerId: "test-execution1" + requirement: "REQUIRED" + - displayName: "New Subflow" + requirement: "REQUIRED" + - providerId: "auth-cookie" + requirement: "REQUIRED" + flowAlias: "New Sublow" + state: present + +- name: Remove authentication. + community.general.keycloak_authentication: + auth_keycloak_url: http://localhost:8080/auth + auth_realm: master + auth_username: admin + auth_password: password + realm: master + alias: "Copy of first broker login" + state: absent ''' RETURN = ''' From fcfc88d1a809ebfe945c894a4f2f2dd8d4f53204 Mon Sep 17 00:00:00 2001 From: Skrekulko Date: Tue, 20 Jun 2023 08:41:58 +0200 Subject: [PATCH 06/10] fix: yaml formatting --- plugins/modules/keycloak_authentication.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/modules/keycloak_authentication.py b/plugins/modules/keycloak_authentication.py index a2c4dd4b3a1..bc2898d9be8 100644 --- a/plugins/modules/keycloak_authentication.py +++ b/plugins/modules/keycloak_authentication.py @@ -111,7 +111,7 @@ EXAMPLES = ''' - name: Create an authentication flow from first broker login and add an execution to it. - community.general.keycloak_authentication: + community.general.keycloak_authentication: auth_keycloak_url: http://localhost:8080/auth auth_realm: master auth_username: admin @@ -120,13 +120,13 @@ alias: "Copy of first broker login" copyFrom: "first broker login" authenticationExecutions: - - providerId: "test-execution1" + - providerId: "test-execution1" requirement: "REQUIRED" authenticationConfig: alias: "test.execution1.property" config: test1.property: "value" - - providerId: "test-execution2" + - providerId: "test-execution2" requirement: "REQUIRED" authenticationConfig: alias: "test.execution2.property" @@ -135,7 +135,7 @@ state: present - name: Re-create the authentication flow - community.general.keycloak_authentication: + community.general.keycloak_authentication: auth_keycloak_url: http://localhost:8080/auth auth_realm: master auth_username: admin @@ -144,7 +144,7 @@ alias: "Copy of first broker login" copyFrom: "first broker login" authenticationExecutions: - - providerId: "test-provisioning" + - providerId: "test-provisioning" requirement: "REQUIRED" authenticationConfig: alias: "test.provisioning.property" @@ -154,7 +154,7 @@ force: true - name: Create an authentication flow with subflow containing an execution. - community.general.keycloak_authentication: + community.general.keycloak_authentication: auth_keycloak_url: http://localhost:8080/auth auth_realm: master auth_username: admin @@ -163,17 +163,17 @@ alias: "Copy of first broker login" copyFrom: "first broker login" authenticationExecutions: - - providerId: "test-execution1" + - providerId: "test-execution1" requirement: "REQUIRED" - - displayName: "New Subflow" + - displayName: "New Subflow" requirement: "REQUIRED" - - providerId: "auth-cookie" + - providerId: "auth-cookie" requirement: "REQUIRED" flowAlias: "New Sublow" state: present - name: Remove authentication. - community.general.keycloak_authentication: + community.general.keycloak_authentication: auth_keycloak_url: http://localhost:8080/auth auth_realm: master auth_username: admin From 5e5cabc9668f24e9ad5c442d1fc75b37a54f798d Mon Sep 17 00:00:00 2001 From: Skrekulko Date: Wed, 21 Jun 2023 08:36:54 +0200 Subject: [PATCH 07/10] chore: bugfix changelog fragment --- changelogs/fragments/6734-keycloak-auth-management-indexing | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/6734-keycloak-auth-management-indexing diff --git a/changelogs/fragments/6734-keycloak-auth-management-indexing b/changelogs/fragments/6734-keycloak-auth-management-indexing new file mode 100644 index 00000000000..6cfe17361b9 --- /dev/null +++ b/changelogs/fragments/6734-keycloak-auth-management-indexing @@ -0,0 +1,2 @@ +bugfixes: + - Fix Keycloak authentication flow (step or sub-flow) indexing during update, if not specified by the user (https://github.com/ansible-collections/community.general/pull/6734). From 3dcfda640aa5417f17ccb9f4580c7136c08ae711 Mon Sep 17 00:00:00 2001 From: Skrekulko Date: Wed, 21 Jun 2023 08:39:36 +0200 Subject: [PATCH 08/10] fix: remove minor changes form current PR --- plugins/modules/keycloak_authentication.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/modules/keycloak_authentication.py b/plugins/modules/keycloak_authentication.py index bc2898d9be8..63571249bdd 100644 --- a/plugins/modules/keycloak_authentication.py +++ b/plugins/modules/keycloak_authentication.py @@ -43,7 +43,6 @@ providerId: description: - C(providerId) for the new flow when not copied from an existing flow. - choices: [ "basic-flow", "client-flow" ] type: str copyFrom: description: @@ -334,7 +333,7 @@ def main(): meta_args = dict( realm=dict(type='str', required=True), alias=dict(type='str', required=True), - providerId=dict(type='str', choices=["basic-flow", "client-flow"]), + providerId=dict(type='str'), description=dict(type='str'), copyFrom=dict(type='str'), authenticationExecutions=dict(type='list', elements='dict', From 6fc747b450004aa58b599e82f21c175ed70eff2d Mon Sep 17 00:00:00 2001 From: Skrekulko Date: Wed, 21 Jun 2023 08:44:02 +0200 Subject: [PATCH 09/10] fix: missing yml extension --- ...gement-indexing => 6734-keycloak-auth-management-indexing.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelogs/fragments/{6734-keycloak-auth-management-indexing => 6734-keycloak-auth-management-indexing.yml} (100%) diff --git a/changelogs/fragments/6734-keycloak-auth-management-indexing b/changelogs/fragments/6734-keycloak-auth-management-indexing.yml similarity index 100% rename from changelogs/fragments/6734-keycloak-auth-management-indexing rename to changelogs/fragments/6734-keycloak-auth-management-indexing.yml From 4cd59c234650bbf24e348e07e513805fce3b4ad6 Mon Sep 17 00:00:00 2001 From: Skrekulko <111891715+Skrekulko@users.noreply.github.com> Date: Thu, 22 Jun 2023 08:02:34 +0200 Subject: [PATCH 10/10] Update changelogs/fragments/6734-keycloak-auth-management-indexing.yml Co-authored-by: Felix Fontein --- changelogs/fragments/6734-keycloak-auth-management-indexing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/6734-keycloak-auth-management-indexing.yml b/changelogs/fragments/6734-keycloak-auth-management-indexing.yml index 6cfe17361b9..f2b5fa9e33b 100644 --- a/changelogs/fragments/6734-keycloak-auth-management-indexing.yml +++ b/changelogs/fragments/6734-keycloak-auth-management-indexing.yml @@ -1,2 +1,2 @@ bugfixes: - - Fix Keycloak authentication flow (step or sub-flow) indexing during update, if not specified by the user (https://github.com/ansible-collections/community.general/pull/6734). + - keycloak_authentication - fix Keycloak authentication flow (step or sub-flow) indexing during update, if not specified by the user (https://github.com/ansible-collections/community.general/pull/6734).