Use feature versions for admin3, account3, and login2 (#33458)

Closes #33405

Signed-off-by: stianst <stianst@gmail.com>
This commit is contained in:
Erik Jan de Wit 2024-10-03 12:09:36 +02:00 committed by GitHub
parent 6092524d79
commit e8d8de8936
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 23 additions and 23 deletions

View file

@ -51,17 +51,17 @@ public class Profile {
ACCOUNT_API("Account Management REST API", Type.DEFAULT), 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_FINE_GRAINED_AUTHZ("Fine-Grained Admin Permissions", Type.PREVIEW),
ADMIN_API("Admin API", Type.DEFAULT), 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), DOCKER("Docker Registry protocol", Type.DISABLED_BY_DEFAULT),

View file

@ -31,7 +31,7 @@ public class ProfileTest {
private static final Profile.Feature DISABLED_BY_DEFAULT_FEATURE = Profile.Feature.DOCKER; 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 PREVIEW_FEATURE = Profile.Feature.ADMIN_FINE_GRAINED_AUTHZ;
private static final Profile.Feature EXPERIMENTAL_FEATURE = Profile.Feature.DYNAMIC_SCOPES; 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 @Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder(); public TemporaryFolder temporaryFolder = new TemporaryFolder();
@ -85,7 +85,7 @@ public class ProfileTest {
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty("keycloak.profile.feature.account_api", "disabled"); 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, assertThrows(ProfileException.class,
() -> Profile.configure(new PropertiesProfileConfigResolver(properties))).getMessage()); () -> Profile.configure(new PropertiesProfileConfigResolver(properties))).getMessage());
} }
@ -93,10 +93,10 @@ public class ProfileTest {
@Test @Test
public void checkSuccessIfFeatureDisabledWithDisabledDependencies() { public void checkSuccessIfFeatureDisabledWithDisabledDependencies() {
Properties properties = new Properties(); 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"); properties.setProperty("keycloak.profile.feature.account_api", "disabled");
Profile.configure(new PropertiesProfileConfigResolver(properties)); 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)); Assert.assertFalse(Profile.isFeatureEnabled(Profile.Feature.ACCOUNT_API));
} }
@ -159,9 +159,9 @@ public class ProfileTest {
@Test @Test
public void testKeys() { public void testKeys() {
Assert.assertEquals("account3", Profile.Feature.ACCOUNT3.getKey()); Assert.assertEquals("account-v3", Profile.Feature.ACCOUNT_V3.getKey());
Assert.assertEquals("account3", Profile.Feature.ACCOUNT3.getUnversionedKey()); Assert.assertEquals("account", Profile.Feature.ACCOUNT_V3.getUnversionedKey());
Assert.assertEquals("account3:v1", Profile.Feature.ACCOUNT3.getVersionedKey()); Assert.assertEquals("account:v3", Profile.Feature.ACCOUNT_V3.getVersionedKey());
} }
@Test @Test

View file

@ -46,7 +46,7 @@ If you want to run Keycloak standalone (without the script) against the Vite dev
```sh ```sh
KC_ACCOUNT_VITE_URL=http://localhost:5173 KC_ACCOUNT_VITE_URL=http://localhost:5173
KC_ADMIN_VITE_URL=http://localhost:5174 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.** **All other arguments will be passed through to the underlying Keycloak server.**

View file

@ -60,7 +60,7 @@ async function startServer() {
path.join(SERVER_DIR, `bin/kc${SCRIPT_EXTENSION}`), path.join(SERVER_DIR, `bin/kc${SCRIPT_EXTENSION}`),
[ [
"start-dev", "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, ...keycloakArgs,
], ],
{ {

View file

@ -49,7 +49,7 @@ public class FeaturePropertyMappersTest {
@Test @Test
public void testValidFeatures() { public void testValidFeatures() {
FeaturePropertyMappers.validateEnabledFeature("preview"); FeaturePropertyMappers.validateEnabledFeature("preview");
FeaturePropertyMappers.validateEnabledFeature(Feature.ACCOUNT3.getVersionedKey()); FeaturePropertyMappers.validateEnabledFeature(Feature.ACCOUNT_V3.getVersionedKey());
} }
} }

View file

@ -35,6 +35,6 @@ public final class AdminExtProvider implements AdminRealmResourceProviderFactory
@Override @Override
public boolean isSupported(Config.Scope config) { public boolean isSupported(Config.Scope config) {
return Profile.isFeatureEnabled(Profile.Feature.ADMIN2); return Profile.isFeatureEnabled(Profile.Feature.ADMIN_V2);
} }
} }

View file

@ -44,15 +44,15 @@ public interface ThemeSelectorProvider extends Provider {
return name; 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; 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; 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; return DEFAULT_V2;
} }

View file

@ -237,7 +237,7 @@ public class WelcomeResource {
} }
private static boolean isAdminConsoleEnabled() { private static boolean isAdminConsoleEnabled() {
return Profile.isFeatureEnabled(Profile.Feature.ADMIN2); return Profile.isFeatureEnabled(Profile.Feature.ADMIN_V2);
} }
private Theme getTheme() { private Theme getTheme() {

View file

@ -321,6 +321,6 @@ public class AdminRoot {
} }
private static boolean isAdminConsoleEnabled() { private static boolean isAdminConsoleEnabled() {
return Profile.isFeatureEnabled(Profile.Feature.ADMIN2); return Profile.isFeatureEnabled(Profile.Feature.ADMIN_V2);
} }
} }

View file

@ -235,9 +235,9 @@ public class ServerInfoAdminResource {
private LinkedList<String> filterThemes(Theme.Type type, LinkedList<String> themeNames) { private LinkedList<String> filterThemes(Theme.Type type, LinkedList<String> themeNames) {
LinkedList<String> filteredNames = new LinkedList<>(themeNames); LinkedList<String> filteredNames = new LinkedList<>(themeNames);
boolean filterAdminV2 = (type == Theme.Type.ADMIN) && boolean filterAdminV2 = (type == Theme.Type.ADMIN) &&
!Profile.isFeatureEnabled(Profile.Feature.ADMIN2); !Profile.isFeatureEnabled(Profile.Feature.ADMIN_V2);
boolean filterLoginV2 = (type == Theme.Type.LOGIN) && boolean filterLoginV2 = (type == Theme.Type.LOGIN) &&
!Profile.isFeatureEnabled(Profile.Feature.LOGIN2); !Profile.isFeatureEnabled(Profile.Feature.LOGIN_V2);
if (filterAdminV2 || filterLoginV2) { if (filterAdminV2 || filterLoginV2) {
filteredNames.remove("keycloak.v2"); filteredNames.remove("keycloak.v2");
@ -245,7 +245,7 @@ public class ServerInfoAdminResource {
} }
boolean filterAccountV3 = (type == Theme.Type.ACCOUNT) && boolean filterAccountV3 = (type == Theme.Type.ACCOUNT) &&
!Profile.isFeatureEnabled(Profile.Feature.ACCOUNT3); !Profile.isFeatureEnabled(Profile.Feature.ACCOUNT_V3);
if (filterAccountV3) { if (filterAccountV3) {
filteredNames.remove("keycloak.v3"); filteredNames.remove("keycloak.v3");