mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
[PR #11256/a9540f93 backport][stable-12] keycloak_user_rolemapping: fix: failling to assign role to user (#11263)
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
---------
(cherry picked from commit a9540f93d2)
Co-authored-by: Guillaume Dorschner <44686652+GuillaumeDorschner@users.noreply.github.com>
Co-authored-by: Guillaume Dorschner <guillaume.dorschner@thalesgroup.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
@@ -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_username: USERNAME
|
||||||
auth_password: PASSWORD
|
auth_password: PASSWORD
|
||||||
state: present
|
state: present
|
||||||
user_id: user1Id
|
uid: user_uid
|
||||||
roles:
|
roles:
|
||||||
- name: role_name1
|
- name: role_name1
|
||||||
id: role_id1
|
id: role_id1
|
||||||
@@ -135,7 +135,7 @@ EXAMPLES = r"""
|
|||||||
auth_password: PASSWORD
|
auth_password: PASSWORD
|
||||||
state: present
|
state: present
|
||||||
client_id: client1
|
client_id: client1
|
||||||
user_id: user1Id
|
uid: user_uid
|
||||||
roles:
|
roles:
|
||||||
- name: role_name1
|
- name: role_name1
|
||||||
id: role_id1
|
id: role_id1
|
||||||
@@ -351,7 +351,9 @@ def main():
|
|||||||
# Fetch missing role_name
|
# Fetch missing role_name
|
||||||
else:
|
else:
|
||||||
if cid is None:
|
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:
|
else:
|
||||||
role["name"] = kc.get_client_user_rolemapping_by_id(
|
role["name"] = kc.get_client_user_rolemapping_by_id(
|
||||||
uid=uid, cid=cid, rid=role.get("id"), realm=realm
|
uid=uid, cid=cid, rid=role.get("id"), realm=realm
|
||||||
|
|||||||
Reference in New Issue
Block a user