From 7d590761dd176bfeb252a0d9e4035a6ff4ff9b75 Mon Sep 17 00:00:00 2001 From: mposolda Date: Mon, 19 Oct 2015 12:46:17 +0200 Subject: [PATCH] KEYCLOAK-1981 Migration fix of create-client --- .../migration/migrators/MigrateTo1_6_0.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/model/api/src/main/java/org/keycloak/migration/migrators/MigrateTo1_6_0.java b/model/api/src/main/java/org/keycloak/migration/migrators/MigrateTo1_6_0.java index 730810b37b..88817acb27 100644 --- a/model/api/src/main/java/org/keycloak/migration/migrators/MigrateTo1_6_0.java +++ b/model/api/src/main/java/org/keycloak/migration/migrators/MigrateTo1_6_0.java @@ -18,6 +18,7 @@ package org.keycloak.migration.migrators; import java.util.List; +import org.keycloak.Config; import org.keycloak.migration.MigrationProvider; import org.keycloak.migration.ModelVersion; import org.keycloak.models.*; @@ -79,7 +80,18 @@ public class MigrateTo1_6_0 { role.setDescription("${role_" + AdminRoles.CREATE_CLIENT + "}"); role.setScopeParamRequired(false); - realm.getRole(AdminRoles.ADMIN).addCompositeRole(role); + client.getRealm().getRole(AdminRoles.ADMIN).addCompositeRole(role); + } + + if (!realm.getName().equals(Config.getAdminRealm())) { + client = realm.getClientByClientId(Constants.REALM_MANAGEMENT_CLIENT_ID); + if (client.getRole(AdminRoles.CREATE_CLIENT) == null) { + RoleModel role = client.addRole(AdminRoles.CREATE_CLIENT); + role.setDescription("${role_" + AdminRoles.CREATE_CLIENT + "}"); + role.setScopeParamRequired(false); + + client.getRole(AdminRoles.REALM_ADMIN).addCompositeRole(role); + } } } }