From e8d8de8936479f6fa1ca6fe1245e8a38614e33b6 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Thu, 3 Oct 2024 12:09:36 +0200 Subject: [PATCH] Use feature versions for admin3, account3, and login2 (#33458) Closes #33405 Signed-off-by: stianst --- .../src/main/java/org/keycloak/common/Profile.java | 8 ++++---- .../test/java/org/keycloak/common/ProfileTest.java | 14 +++++++------- js/apps/keycloak-server/README.md | 2 +- js/apps/keycloak-server/scripts/start-server.js | 2 +- .../test/FeaturePropertyMappersTest.java | 2 +- .../keycloak/admin/ui/rest/AdminExtProvider.java | 2 +- .../org/keycloak/theme/ThemeSelectorProvider.java | 6 +++--- .../services/resources/WelcomeResource.java | 2 +- .../services/resources/admin/AdminRoot.java | 2 +- .../admin/info/ServerInfoAdminResource.java | 6 +++--- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/common/src/main/java/org/keycloak/common/Profile.java b/common/src/main/java/org/keycloak/common/Profile.java index ef1c6d9742..a4c9095d36 100755 --- a/common/src/main/java/org/keycloak/common/Profile.java +++ b/common/src/main/java/org/keycloak/common/Profile.java @@ -51,17 +51,17 @@ public class Profile { ACCOUNT_API("Account Management REST API", Type.DEFAULT), - ACCOUNT3("Account Console version 3", Type.DEFAULT, Feature.ACCOUNT_API), + ACCOUNT_V3("Account Console version 3", Type.DEFAULT, 3, Feature.ACCOUNT_API), ADMIN_FINE_GRAINED_AUTHZ("Fine-Grained Admin Permissions", Type.PREVIEW), ADMIN_API("Admin API", Type.DEFAULT), - ADMIN2("New Admin Console", Type.DEFAULT, Feature.ADMIN_API), + ADMIN_V2("New Admin Console", Type.DEFAULT, 2, Feature.ADMIN_API), - LOGIN2("New Login Theme", Type.DEFAULT), + LOGIN_V2("New Login Theme", Type.DEFAULT, 2), - LOGIN1("Legacy Login Theme", Type.DEPRECATED), + LOGIN_V1("Legacy Login Theme", Type.DEPRECATED, 1), DOCKER("Docker Registry protocol", Type.DISABLED_BY_DEFAULT), diff --git a/common/src/test/java/org/keycloak/common/ProfileTest.java b/common/src/test/java/org/keycloak/common/ProfileTest.java index afa64768ee..42cde43424 100644 --- a/common/src/test/java/org/keycloak/common/ProfileTest.java +++ b/common/src/test/java/org/keycloak/common/ProfileTest.java @@ -31,7 +31,7 @@ public class ProfileTest { private static final Profile.Feature DISABLED_BY_DEFAULT_FEATURE = Profile.Feature.DOCKER; private static final Profile.Feature PREVIEW_FEATURE = Profile.Feature.ADMIN_FINE_GRAINED_AUTHZ; private static final Profile.Feature EXPERIMENTAL_FEATURE = Profile.Feature.DYNAMIC_SCOPES; - private static Profile.Feature DEPRECATED_FEATURE = Profile.Feature.LOGIN1; + private static Profile.Feature DEPRECATED_FEATURE = Profile.Feature.LOGIN_V1; @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); @@ -85,7 +85,7 @@ public class ProfileTest { Properties properties = new Properties(); properties.setProperty("keycloak.profile.feature.account_api", "disabled"); - Assert.assertEquals("Feature account3 depends on disabled feature account-api", + Assert.assertEquals("Feature account-v3 depends on disabled feature account-api", assertThrows(ProfileException.class, () -> Profile.configure(new PropertiesProfileConfigResolver(properties))).getMessage()); } @@ -93,10 +93,10 @@ public class ProfileTest { @Test public void checkSuccessIfFeatureDisabledWithDisabledDependencies() { Properties properties = new Properties(); - properties.setProperty("keycloak.profile.feature.account3", "disabled"); + properties.setProperty("keycloak.profile.feature.account", "disabled"); properties.setProperty("keycloak.profile.feature.account_api", "disabled"); Profile.configure(new PropertiesProfileConfigResolver(properties)); - Assert.assertFalse(Profile.isFeatureEnabled(Profile.Feature.ACCOUNT3)); + Assert.assertFalse(Profile.isFeatureEnabled(Profile.Feature.ACCOUNT_V3)); Assert.assertFalse(Profile.isFeatureEnabled(Profile.Feature.ACCOUNT_API)); } @@ -159,9 +159,9 @@ public class ProfileTest { @Test public void testKeys() { - Assert.assertEquals("account3", Profile.Feature.ACCOUNT3.getKey()); - Assert.assertEquals("account3", Profile.Feature.ACCOUNT3.getUnversionedKey()); - Assert.assertEquals("account3:v1", Profile.Feature.ACCOUNT3.getVersionedKey()); + Assert.assertEquals("account-v3", Profile.Feature.ACCOUNT_V3.getKey()); + Assert.assertEquals("account", Profile.Feature.ACCOUNT_V3.getUnversionedKey()); + Assert.assertEquals("account:v3", Profile.Feature.ACCOUNT_V3.getVersionedKey()); } @Test diff --git a/js/apps/keycloak-server/README.md b/js/apps/keycloak-server/README.md index 34472e7cae..40e7412951 100644 --- a/js/apps/keycloak-server/README.md +++ b/js/apps/keycloak-server/README.md @@ -46,7 +46,7 @@ If you want to run Keycloak standalone (without the script) against the Vite dev ```sh KC_ACCOUNT_VITE_URL=http://localhost:5173 KC_ADMIN_VITE_URL=http://localhost:5174 -KC_FEATURES=login2,account3,admin-fine-grained-authz,transient-users,oid4vc-vci +KC_FEATURES=login:v2,account:v3,admin-fine-grained-authz,transient-users,oid4vc-vci ``` **All other arguments will be passed through to the underlying Keycloak server.** diff --git a/js/apps/keycloak-server/scripts/start-server.js b/js/apps/keycloak-server/scripts/start-server.js index 8a428746cb..78be000357 100755 --- a/js/apps/keycloak-server/scripts/start-server.js +++ b/js/apps/keycloak-server/scripts/start-server.js @@ -60,7 +60,7 @@ async function startServer() { path.join(SERVER_DIR, `bin/kc${SCRIPT_EXTENSION}`), [ "start-dev", - `--features="login2,account3,admin-fine-grained-authz,transient-users,oid4vc-vci,organization"`, + `--features="login:v2,account:v3,admin-fine-grained-authz,transient-users,oid4vc-vci,organization"`, ...keycloakArgs, ], { diff --git a/quarkus/runtime/src/test/java/org/keycloak/quarkus/runtime/configuration/test/FeaturePropertyMappersTest.java b/quarkus/runtime/src/test/java/org/keycloak/quarkus/runtime/configuration/test/FeaturePropertyMappersTest.java index 748f4465f1..b3d8ab62b5 100644 --- a/quarkus/runtime/src/test/java/org/keycloak/quarkus/runtime/configuration/test/FeaturePropertyMappersTest.java +++ b/quarkus/runtime/src/test/java/org/keycloak/quarkus/runtime/configuration/test/FeaturePropertyMappersTest.java @@ -49,7 +49,7 @@ public class FeaturePropertyMappersTest { @Test public void testValidFeatures() { FeaturePropertyMappers.validateEnabledFeature("preview"); - FeaturePropertyMappers.validateEnabledFeature(Feature.ACCOUNT3.getVersionedKey()); + FeaturePropertyMappers.validateEnabledFeature(Feature.ACCOUNT_V3.getVersionedKey()); } } diff --git a/rest/admin-ui-ext/src/main/java/org/keycloak/admin/ui/rest/AdminExtProvider.java b/rest/admin-ui-ext/src/main/java/org/keycloak/admin/ui/rest/AdminExtProvider.java index d050a0f564..225de09061 100644 --- a/rest/admin-ui-ext/src/main/java/org/keycloak/admin/ui/rest/AdminExtProvider.java +++ b/rest/admin-ui-ext/src/main/java/org/keycloak/admin/ui/rest/AdminExtProvider.java @@ -35,6 +35,6 @@ public final class AdminExtProvider implements AdminRealmResourceProviderFactory @Override public boolean isSupported(Config.Scope config) { - return Profile.isFeatureEnabled(Profile.Feature.ADMIN2); + return Profile.isFeatureEnabled(Profile.Feature.ADMIN_V2); } } diff --git a/server-spi/src/main/java/org/keycloak/theme/ThemeSelectorProvider.java b/server-spi/src/main/java/org/keycloak/theme/ThemeSelectorProvider.java index e860feb527..aba8459dfa 100755 --- a/server-spi/src/main/java/org/keycloak/theme/ThemeSelectorProvider.java +++ b/server-spi/src/main/java/org/keycloak/theme/ThemeSelectorProvider.java @@ -44,15 +44,15 @@ public interface ThemeSelectorProvider extends Provider { return name; } - if ((type == Theme.Type.ACCOUNT) && Profile.isFeatureEnabled(Profile.Feature.ACCOUNT3)) { + if ((type == Theme.Type.ACCOUNT) && Profile.isFeatureEnabled(Profile.Feature.ACCOUNT_V3)) { return DEFAULT_V3; } - if ((type == Theme.Type.ADMIN) && Profile.isFeatureEnabled(Profile.Feature.ADMIN2)) { + if ((type == Theme.Type.ADMIN) && Profile.isFeatureEnabled(Profile.Feature.ADMIN_V2)) { return DEFAULT_V2; } - if ((type == Theme.Type.LOGIN) && Profile.isFeatureEnabled(Profile.Feature.LOGIN2)) { + if ((type == Theme.Type.LOGIN) && Profile.isFeatureEnabled(Profile.Feature.LOGIN_V2)) { return DEFAULT_V2; } diff --git a/services/src/main/java/org/keycloak/services/resources/WelcomeResource.java b/services/src/main/java/org/keycloak/services/resources/WelcomeResource.java index b36a81f876..8b01e3c4ba 100755 --- a/services/src/main/java/org/keycloak/services/resources/WelcomeResource.java +++ b/services/src/main/java/org/keycloak/services/resources/WelcomeResource.java @@ -237,7 +237,7 @@ public class WelcomeResource { } private static boolean isAdminConsoleEnabled() { - return Profile.isFeatureEnabled(Profile.Feature.ADMIN2); + return Profile.isFeatureEnabled(Profile.Feature.ADMIN_V2); } private Theme getTheme() { diff --git a/services/src/main/java/org/keycloak/services/resources/admin/AdminRoot.java b/services/src/main/java/org/keycloak/services/resources/admin/AdminRoot.java index d5262d4917..c2ddaf47b9 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/AdminRoot.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/AdminRoot.java @@ -321,6 +321,6 @@ public class AdminRoot { } private static boolean isAdminConsoleEnabled() { - return Profile.isFeatureEnabled(Profile.Feature.ADMIN2); + return Profile.isFeatureEnabled(Profile.Feature.ADMIN_V2); } } diff --git a/services/src/main/java/org/keycloak/services/resources/admin/info/ServerInfoAdminResource.java b/services/src/main/java/org/keycloak/services/resources/admin/info/ServerInfoAdminResource.java index 6470d32f31..609aece9aa 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/info/ServerInfoAdminResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/info/ServerInfoAdminResource.java @@ -235,9 +235,9 @@ public class ServerInfoAdminResource { private LinkedList filterThemes(Theme.Type type, LinkedList themeNames) { LinkedList filteredNames = new LinkedList<>(themeNames); boolean filterAdminV2 = (type == Theme.Type.ADMIN) && - !Profile.isFeatureEnabled(Profile.Feature.ADMIN2); + !Profile.isFeatureEnabled(Profile.Feature.ADMIN_V2); boolean filterLoginV2 = (type == Theme.Type.LOGIN) && - !Profile.isFeatureEnabled(Profile.Feature.LOGIN2); + !Profile.isFeatureEnabled(Profile.Feature.LOGIN_V2); if (filterAdminV2 || filterLoginV2) { filteredNames.remove("keycloak.v2"); @@ -245,7 +245,7 @@ public class ServerInfoAdminResource { } boolean filterAccountV3 = (type == Theme.Type.ACCOUNT) && - !Profile.isFeatureEnabled(Profile.Feature.ACCOUNT3); + !Profile.isFeatureEnabled(Profile.Feature.ACCOUNT_V3); if (filterAccountV3) { filteredNames.remove("keycloak.v3");