Search in sources :

Example 6 with MigrationProvider

use of org.keycloak.migration.MigrationProvider in project keycloak by keycloak.

the class MigrateTo1_7_0 method migrateRealm.

protected void migrateRealm(KeycloakSession session, RealmModel realm) {
    // Set default accessToken timeout for implicit flow
    realm.setAccessTokenLifespanForImplicitFlow(Constants.DEFAULT_ACCESS_TOKEN_LIFESPAN_FOR_IMPLICIT_FLOW_TIMEOUT);
    // Add 'admin-cli' builtin client
    MigrationProvider migrationProvider = session.getProvider(MigrationProvider.class);
    migrationProvider.setupAdminCli(realm);
    // add firstBrokerLogin flow and set it to all identityProviders
    DefaultAuthenticationFlows.migrateFlows(realm);
    AuthenticationFlowModel firstBrokerLoginFlow = realm.getFlowByAlias(DefaultAuthenticationFlows.FIRST_BROKER_LOGIN_FLOW);
    realm.getIdentityProvidersStream().filter(provider -> provider.getFirstBrokerLoginFlowId() == null).forEach(provider -> {
        provider.setFirstBrokerLoginFlowId(firstBrokerLoginFlow.getId());
        realm.updateIdentityProvider(provider);
    });
}
Also used : RealmModel(org.keycloak.models.RealmModel) ModelVersion(org.keycloak.migration.ModelVersion) Constants(org.keycloak.models.Constants) AuthenticationFlowModel(org.keycloak.models.AuthenticationFlowModel) KeycloakSession(org.keycloak.models.KeycloakSession) MigrationProvider(org.keycloak.migration.MigrationProvider) RealmRepresentation(org.keycloak.representations.idm.RealmRepresentation) DefaultAuthenticationFlows(org.keycloak.models.utils.DefaultAuthenticationFlows) MigrationProvider(org.keycloak.migration.MigrationProvider) AuthenticationFlowModel(org.keycloak.models.AuthenticationFlowModel)

Aggregations

MigrationProvider (org.keycloak.migration.MigrationProvider)6 ClientScopeModel (org.keycloak.models.ClientScopeModel)2 ProtocolMapperModel (org.keycloak.models.ProtocolMapperModel)2 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 Map (java.util.Map)1 InsertStatement (liquibase.statement.core.InsertStatement)1 ModelVersion (org.keycloak.migration.ModelVersion)1 AuthenticationFlowModel (org.keycloak.models.AuthenticationFlowModel)1 Constants (org.keycloak.models.Constants)1 KeycloakSession (org.keycloak.models.KeycloakSession)1 RealmModel (org.keycloak.models.RealmModel)1 DefaultAuthenticationFlows (org.keycloak.models.utils.DefaultAuthenticationFlows)1 ProtocolMapperRepresentation (org.keycloak.representations.idm.ProtocolMapperRepresentation)1 RealmRepresentation (org.keycloak.representations.idm.RealmRepresentation)1