1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-02-03 23:41:51 +00:00

keycloak_user_rolemapping: fix: failling to assign role to user (#11256)

* docs: clarify keycloak documentation example section with uid

* fix: allow assign role to user

* Add changelog frag

* Update changelogs/fragments/11256-fix-keycloak-roles-mapping.yml

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

---------

Co-authored-by: Guillaume Dorschner <guillaume.dorschner@thalesgroup.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Guillaume Dorschner 2025-12-06 13:41:40 +01:00 committed by GitHub
parent 0ef3eac0f4
commit a9540f93d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View file

@ -117,7 +117,7 @@ EXAMPLES = r"""
auth_username: USERNAME
auth_password: PASSWORD
state: present
user_id: user1Id
uid: user_uid
roles:
- name: role_name1
id: role_id1
@ -135,7 +135,7 @@ EXAMPLES = r"""
auth_password: PASSWORD
state: present
client_id: client1
user_id: user1Id
uid: user_uid
roles:
- name: role_name1
id: role_id1
@ -351,7 +351,9 @@ def main():
# Fetch missing role_name
else:
if cid is None:
role["name"] = kc.get_realm_user_rolemapping_by_id(uid=uid, rid=role.get("id"), realm=realm)["name"]
role_rep = kc.get_realm_user_rolemapping_by_id(uid=uid, rid=role.get("id"), realm=realm)
if role_rep is not None:
role["name"] = role_rep["name"]
else:
role["name"] = kc.get_client_user_rolemapping_by_id(
uid=uid, cid=cid, rid=role.get("id"), realm=realm