From c14bc6f2b03c647e691493f3f4d78a1a25774613 Mon Sep 17 00:00:00 2001 From: rmartinc Date: Tue, 12 Dec 2023 12:59:40 +0100 Subject: [PATCH] Create terms and conditions execution when registration form is added Closes #21730 Signed-off-by: rmartinc --- .../utils/DefaultAuthenticationFlows.java | 17 ++++++++--------- .../admin/authentication/InitialFlowsTest.java | 1 + 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/server-spi-private/src/main/java/org/keycloak/models/utils/DefaultAuthenticationFlows.java b/server-spi-private/src/main/java/org/keycloak/models/utils/DefaultAuthenticationFlows.java index 27bb1d16de..a5ffb533b6 100755 --- a/server-spi-private/src/main/java/org/keycloak/models/utils/DefaultAuthenticationFlows.java +++ b/server-spi-private/src/main/java/org/keycloak/models/utils/DefaultAuthenticationFlows.java @@ -63,6 +63,7 @@ public class DefaultAuthenticationFlows { if (realm.getFlowByAlias(SAML_ECP_FLOW) == null) samlEcpProfile(realm); if (realm.getFlowByAlias(DOCKER_AUTH) == null) dockerAuthenticationFlow(realm); } + public static void migrateFlows(RealmModel realm) { if (realm.getFlowByAlias(BROWSER_FLOW) == null) browserFlow(realm, true); if (realm.getFlowByAlias(DIRECT_GRANT_FLOW) == null) directGrantFlow(realm, true); @@ -135,15 +136,13 @@ public class DefaultAuthenticationFlows { //execution.setAuthenticatorConfig(captchaConfig.getId()); realm.addAuthenticatorExecution(execution); - if (!migrate) { - execution = new AuthenticationExecutionModel(); - execution.setParentFlow(registrationFormFlow.getId()); - execution.setRequirement(AuthenticationExecutionModel.Requirement.DISABLED); - execution.setAuthenticator("registration-terms-and-conditions"); - execution.setPriority(70); - execution.setAuthenticatorFlow(false); - realm.addAuthenticatorExecution(execution); - } + execution = new AuthenticationExecutionModel(); + execution.setParentFlow(registrationFormFlow.getId()); + execution.setRequirement(AuthenticationExecutionModel.Requirement.DISABLED); + execution.setAuthenticator("registration-terms-and-conditions"); + execution.setPriority(70); + execution.setAuthenticatorFlow(false); + realm.addAuthenticatorExecution(execution); } public static void browserFlow(RealmModel realm) { diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/InitialFlowsTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/InitialFlowsTest.java index 0256645bac..6665a076db 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/InitialFlowsTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/authentication/InitialFlowsTest.java @@ -200,6 +200,7 @@ public class InitialFlowsTest extends AbstractAuthenticationTest { addExecInfo(execs, "Registration User Profile Creation", "registration-user-creation", false, 1, 0, REQUIRED, null, new String[]{REQUIRED, DISABLED}); addExecInfo(execs, "Password Validation", "registration-password-action", false, 1, 1, REQUIRED, null, new String[]{REQUIRED, DISABLED}); addExecInfo(execs, "Recaptcha", "registration-recaptcha-action", true, 1, 2, DISABLED, null, new String[]{REQUIRED, DISABLED}); + addExecInfo(execs, "Terms and conditions", "registration-terms-and-conditions", false, 1, 3, DISABLED, null, new String[]{REQUIRED, DISABLED}); expected.add(new FlowExecutions(flow, execs)); flow = newFlow("reset credentials", "Reset credentials for a user if they forgot their password or something", "basic-flow", true, true);