KEYCLOAK-16648 Fix migration to 12
This commit is contained in:
parent
75be33ccad
commit
8af4a5fc85
1 changed files with 26 additions and 26 deletions
|
@ -22,24 +22,24 @@ import org.keycloak.migration.ModelVersion;
|
|||
import org.keycloak.models.AccountRoles;
|
||||
import org.keycloak.models.Constants;
|
||||
import org.keycloak.models.KeycloakSession;
|
||||
import org.keycloak.models.RealmModel;
|
||||
import org.keycloak.models.RequiredActionProviderModel;
|
||||
|
||||
public class MigrateTo12_0_0 implements Migration {
|
||||
|
||||
public static final ModelVersion VERSION = new ModelVersion("12.0.0");
|
||||
|
||||
public static final RequiredActionProviderModel deleteAccount = new RequiredActionProviderModel();
|
||||
|
||||
static {
|
||||
private static void addDeleteAccountAction(RealmModel realm) {
|
||||
RequiredActionProviderModel deleteAccount = new RequiredActionProviderModel();
|
||||
deleteAccount.setEnabled(false);
|
||||
deleteAccount.setAlias("delete_account");
|
||||
deleteAccount.setName("Delete Account");
|
||||
deleteAccount.setProviderId("delete_account");
|
||||
deleteAccount.setDefaultAction(false);
|
||||
deleteAccount.setPriority(60);
|
||||
realm.addRequiredActionProvider(deleteAccount);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void migrate(KeycloakSession session) {
|
||||
session.realms()
|
||||
|
@ -49,7 +49,7 @@ public class MigrateTo12_0_0 implements Migration {
|
|||
.forEach(client -> client.addRole(AccountRoles.DELETE_ACCOUNT)
|
||||
.setDescription("${role_" + AccountRoles.DELETE_ACCOUNT + "}"));
|
||||
|
||||
session.realms().getRealmsStream().filter(realm -> Objects.isNull(realm.getRequiredActionProviderByAlias("delete_account"))).forEach(realm -> realm.addRequiredActionProvider(deleteAccount));
|
||||
session.realms().getRealmsStream().filter(realm -> Objects.isNull(realm.getRequiredActionProviderByAlias("delete_account"))).forEach(MigrateTo12_0_0::addDeleteAccountAction);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue