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:
parent
0ef3eac0f4
commit
a9540f93d2
2 changed files with 9 additions and 3 deletions
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
bugfixes:
|
||||
- keycloak_user_rolemapping module - fixed crash when assigning roles to users
|
||||
without an existing role (https://github.com/ansible-collections/community.general/issues/10960, https://github.com/ansible-collections/community.general/pull/11256).
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue