grant the new role from the saml token if it exist

grant the user with the new role from the saml token if it is a realm role in keycloak
This commit is contained in:
hassaneinaltememyictu 2016-10-24 17:17:22 +02:00 committed by GitHub
parent dcaac76b4b
commit a119a46495

View file

@ -139,10 +139,12 @@ public class AttributeToRoleMapper extends AbstractIdentityProviderMapper {
@Override
public void updateBrokeredUser(KeycloakSession session, RealmModel realm, UserModel user, IdentityProviderMapperModel mapperModel, BrokeredIdentityContext context) {
String roleName = mapperModel.getConfig().get(ConfigConstants.ROLE);
if (!isAttributePresent(mapperModel, context)) {
RoleModel role = KeycloakModelUtils.getRoleFromString(realm, roleName);
if (role == null) throw new IdentityBrokerException("Unable to find role: " + roleName);
if (!isAttributePresent(mapperModel, context)) {
user.deleteRoleMapping(role);
}else{
user.grantRole(role);
}
}