mirror of
https://github.com/keycloak/keycloak.git
synced 2026-05-28 04:13:22 -04:00
Role mapper should check if an update is needed for the role
Closes #43698 Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
This commit is contained in:
parent
3cb9e0bcd8
commit
47288a9643
1 changed files with 8 additions and 2 deletions
|
|
@ -62,9 +62,15 @@ public abstract class AbstractAttributeToRoleMapper extends AbstractIdentityProv
|
|||
if (!context.hasMapperGrantedRole(roleName)) {
|
||||
if (this.applies(mapperModel, context)) {
|
||||
context.addMapperGrantedRole(roleName);
|
||||
user.grantRole(role);
|
||||
if ((!role.isClientRole() && user.getRealmRoleMappingsStream().noneMatch(r -> r.equals(role)))
|
||||
|| (role.isClientRole() && user.getClientRoleMappingsStream(session.clients().getClientById(realm, role.getContainerId())).noneMatch(r -> r.equals(role)))) {
|
||||
user.grantRole(role);
|
||||
}
|
||||
} else {
|
||||
user.deleteRoleMapping(role);
|
||||
if ((!role.isClientRole() && user.getRealmRoleMappingsStream().anyMatch(r -> r.equals(role)))
|
||||
|| (role.isClientRole() && user.getClientRoleMappingsStream(session.clients().getClientById(realm, role.getContainerId())).anyMatch(r -> r.equals(role)))) {
|
||||
user.deleteRoleMapping(role);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue