mirror of
https://github.com/keycloak/keycloak.git
synced 2026-01-09 15:02:05 -03:30
Update browser flow with organization flow on migration
Closes #36593 Signed-off-by: Pedro Igor <pigor.craveiro@gmail.com>
This commit is contained in:
parent
234526761e
commit
17f0dbdc1c
@ -0,0 +1,23 @@
|
|||||||
|
package org.keycloak.migration.migrators;
|
||||||
|
|
||||||
|
import org.keycloak.migration.ModelVersion;
|
||||||
|
import org.keycloak.models.KeycloakSession;
|
||||||
|
import org.keycloak.models.RealmModel;
|
||||||
|
import org.keycloak.models.utils.DefaultAuthenticationFlows;
|
||||||
|
|
||||||
|
|
||||||
|
public class MigrateTo26_6_0 extends RealmMigration {
|
||||||
|
|
||||||
|
public static final ModelVersion VERSION = new ModelVersion("26.6.0");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ModelVersion getVersion() {
|
||||||
|
return VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void migrateRealm(KeycloakSession session, RealmModel realm) {
|
||||||
|
DefaultAuthenticationFlows.addOrganizationBrowserFlowStep(realm, realm.getBrowserFlow());
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -49,6 +49,7 @@ import org.keycloak.migration.migrators.MigrateTo26_2_0;
|
|||||||
import org.keycloak.migration.migrators.MigrateTo26_3_0;
|
import org.keycloak.migration.migrators.MigrateTo26_3_0;
|
||||||
import org.keycloak.migration.migrators.MigrateTo26_4_0;
|
import org.keycloak.migration.migrators.MigrateTo26_4_0;
|
||||||
import org.keycloak.migration.migrators.MigrateTo26_4_3;
|
import org.keycloak.migration.migrators.MigrateTo26_4_3;
|
||||||
|
import org.keycloak.migration.migrators.MigrateTo26_6_0;
|
||||||
import org.keycloak.migration.migrators.MigrateTo2_0_0;
|
import org.keycloak.migration.migrators.MigrateTo2_0_0;
|
||||||
import org.keycloak.migration.migrators.MigrateTo2_1_0;
|
import org.keycloak.migration.migrators.MigrateTo2_1_0;
|
||||||
import org.keycloak.migration.migrators.MigrateTo2_2_0;
|
import org.keycloak.migration.migrators.MigrateTo2_2_0;
|
||||||
@ -131,7 +132,8 @@ public class DefaultMigrationManager implements MigrationManager {
|
|||||||
new MigrateTo26_2_0(),
|
new MigrateTo26_2_0(),
|
||||||
new MigrateTo26_3_0(),
|
new MigrateTo26_3_0(),
|
||||||
new MigrateTo26_4_0(),
|
new MigrateTo26_4_0(),
|
||||||
new MigrateTo26_4_3()
|
new MigrateTo26_4_3(),
|
||||||
|
new MigrateTo26_6_0()
|
||||||
};
|
};
|
||||||
|
|
||||||
private final KeycloakSession session;
|
private final KeycloakSession session;
|
||||||
|
|||||||
@ -825,6 +825,11 @@ public class DefaultAuthenticationFlows {
|
|||||||
if (!Profile.isFeatureEnabled(Feature.ORGANIZATION)) {
|
if (!Profile.isFeatureEnabled(Feature.ORGANIZATION)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isOrganizationAuthenticatorPresent(realm, flow.getId())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Config.getAdminRealm().equals(realm.getName())) {
|
if (!Config.getAdminRealm().equals(realm.getName())) {
|
||||||
// do not add the org flows to the master realm for now.
|
// do not add the org flows to the master realm for now.
|
||||||
AuthenticationFlowModel organizations = new AuthenticationFlowModel();
|
AuthenticationFlowModel organizations = new AuthenticationFlowModel();
|
||||||
@ -873,4 +878,17 @@ public class DefaultAuthenticationFlows {
|
|||||||
realm.addAuthenticatorExecution(execution);
|
realm.addAuthenticatorExecution(execution);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isOrganizationAuthenticatorPresent(RealmModel realm, String flowId) {
|
||||||
|
return flowId != null && realm.getAuthenticationExecutionsStream(flowId)
|
||||||
|
.anyMatch((e) -> isOrganizationAuthenticatorPresent(realm, e));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isOrganizationAuthenticatorPresent(RealmModel realm, AuthenticationExecutionModel execution) {
|
||||||
|
if ("organization".equals(execution.getAuthenticator())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isOrganizationAuthenticatorPresent(realm, execution.getFlowId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user