mirror of
https://github.com/keycloak/keycloak.git
synced 2026-01-09 23:12:06 -03:30
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
@ -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…
x
Reference in New Issue
Block a user