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

Fix Keycloak authentication management indexing (#6734)

* fix: keep original index

* refac: provider id choice

* refac: default

* fix: missing docs

* fix: ident

* fix: yaml formatting

* chore: bugfix changelog fragment

* fix: remove minor changes form current PR

* fix: missing yml extension

* Update changelogs/fragments/6734-keycloak-auth-management-indexing.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Skrekulko <Skrekulko@users.noreply.github.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Skrekulko 2023-07-08 10:13:51 +02:00 committed by GitHub
parent 704a3019b7
commit 7748002636
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 72 additions and 68 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- 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).

View file

@ -110,77 +110,77 @@ author:
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: Create an authentication flow from first broker login and add an execution to it. - 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_keycloak_url: http://localhost:8080/auth
auth_realm: master auth_realm: master
auth_username: admin auth_username: admin
auth_password: password auth_password: password
realm: master realm: master
alias: "Copy of first broker login" alias: "Copy of first broker login"
copyFrom: "first broker login" copyFrom: "first broker login"
authenticationExecutions: authenticationExecutions:
- providerId: "test-execution1" - providerId: "test-execution1"
requirement: "REQUIRED" requirement: "REQUIRED"
authenticationConfig: authenticationConfig:
alias: "test.execution1.property" alias: "test.execution1.property"
config: config:
test1.property: "value" test1.property: "value"
- providerId: "test-execution2" - providerId: "test-execution2"
requirement: "REQUIRED" requirement: "REQUIRED"
authenticationConfig: authenticationConfig:
alias: "test.execution2.property" alias: "test.execution2.property"
config: config:
test2.property: "value" test2.property: "value"
state: present state: present
- name: Re-create the authentication flow - name: Re-create the authentication flow
community.general.keycloak_authentication: community.general.keycloak_authentication:
auth_keycloak_url: http://localhost:8080/auth auth_keycloak_url: http://localhost:8080/auth
auth_realm: master auth_realm: master
auth_username: admin auth_username: admin
auth_password: password auth_password: password
realm: master realm: master
alias: "Copy of first broker login" alias: "Copy of first broker login"
copyFrom: "first broker login" copyFrom: "first broker login"
authenticationExecutions: authenticationExecutions:
- providerId: "test-provisioning" - providerId: "test-provisioning"
requirement: "REQUIRED" requirement: "REQUIRED"
authenticationConfig: authenticationConfig:
alias: "test.provisioning.property" alias: "test.provisioning.property"
config: config:
test.provisioning.property: "value" test.provisioning.property: "value"
state: present state: present
force: true force: true
- name: Create an authentication flow with subflow containing an execution. - 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_keycloak_url: http://localhost:8080/auth
auth_realm: master auth_realm: master
auth_username: admin auth_username: admin
auth_password: password auth_password: password
realm: master realm: master
alias: "Copy of first broker login" alias: "Copy of first broker login"
copyFrom: "first broker login" copyFrom: "first broker login"
authenticationExecutions: authenticationExecutions:
- providerId: "test-execution1" - providerId: "test-execution1"
requirement: "REQUIRED" requirement: "REQUIRED"
- displayName: "New Subflow" - displayName: "New Subflow"
requirement: "REQUIRED" requirement: "REQUIRED"
- providerId: "auth-cookie" - providerId: "auth-cookie"
requirement: "REQUIRED" requirement: "REQUIRED"
flowAlias: "New Sublow" flowAlias: "New Sublow"
state: present state: present
- name: Remove authentication. - name: Remove authentication.
community.general.keycloak_authentication: community.general.keycloak_authentication:
auth_keycloak_url: http://localhost:8080/auth auth_keycloak_url: http://localhost:8080/auth
auth_realm: master auth_realm: master
auth_username: admin auth_username: admin
auth_password: password auth_password: password
realm: master realm: master
alias: "Copy of first broker login" alias: "Copy of first broker login"
state: absent state: absent
''' '''
RETURN = ''' RETURN = '''
@ -280,6 +280,8 @@ def create_or_update_executions(kc, config, realm='master'):
# Compare the executions to see if it need changes # 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: if not is_struct_included(new_exec, existing_executions[exec_index], exclude_key) or exec_index != new_exec_index:
exec_found = True exec_found = True
if new_exec['index'] is None:
new_exec_index = exec_index
before += str(existing_executions[exec_index]) + '\n' before += str(existing_executions[exec_index]) + '\n'
id_to_update = existing_executions[exec_index]["id"] id_to_update = existing_executions[exec_index]["id"]
# Remove exec from list in case 2 exec with same name # Remove exec from list in case 2 exec with same name