ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
833 stars 1.53k forks source link

[PR #8831/2ae41fa8 backport][stable-8] keycloak_user_federation: get the before mappers from `before_comp` to fix `UnboundLocalError` #8849

Closed patchback[bot] closed 2 months ago

patchback[bot] commented 2 months ago

This is a backport of PR #8831 as merged into main (2ae41fa83f44aefce38cd845e377dcdd73b9f32b).

SUMMARY

The module crashes if an id is provided for a mapper, see https://github.com/ansible-collections/community.general/pull/8695#issuecomment-2331251238.

The before mappers should be retrieved from the before_comp not before_mapper.

ISSUE TYPE
COMPONENT NAME

community.general.keycloak_user_federation

ADDITIONAL INFORMATION
  1. create a mapper without providing an id:
    mappers:
    - name: "first name"
    providerId: "user-attribute-ldap-mapper"
    providerType: "org.keycloak.storage.ldap.mappers.LDAPStorageMapper"
    config:
      ldap.attribute: givenName
      read.only: true
      write.only: false
      attribute.force.default: true
      is.mandatory.in.ldap: true
      is.binary.attribute: false
      user.model.attribute: firstName
  2. copy id from keycloak and update mapper:
    mappers:
    - name: "first name"
    id: f2d82dec-923c-40da-a9f7-0fe83ca8c009
    providerId: "user-attribute-ldap-mapper"
    providerType: "org.keycloak.storage.ldap.mappers.LDAPStorageMapper"
    config:
      ldap.attribute: givenName
      read.only: true
      write.only: false
      attribute.force.default: true
      is.mandatory.in.ldap: true
      is.binary.attribute: false
      user.model.attribute: firstName
ansibullbot commented 2 months ago

cc @eikef @laurpaum @mattock @ndclt @thomasbach-dev click here for bot help