Skip to content

Commit

Permalink
Use feature versions for admin3, account3, and login2 (keycloak#33458)
Browse files Browse the repository at this point in the history
Closes keycloak#33405

Signed-off-by: stianst <stianst@gmail.com>
  • Loading branch information
edewit authored Oct 3, 2024
1 parent 6092524 commit e8d8de8
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 23 deletions.
8 changes: 4 additions & 4 deletions common/src/main/java/org/keycloak/common/Profile.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ public enum Feature {

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),

Expand Down
14 changes: 7 additions & 7 deletions common/src/test/java/org/keycloak/common/ProfileTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -85,18 +85,18 @@ public void checkFailureIfDependencyDisabled() {
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());
}

@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));
}

Expand Down Expand Up @@ -159,9 +159,9 @@ public void configWithCommaSeparatedList() {

@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
Expand Down
2 changes: 1 addition & 1 deletion js/apps/keycloak-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.**
Expand Down
2 changes: 1 addition & 1 deletion js/apps/keycloak-server/scripts/start-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void testInvalidFeatureVersion() {
@Test
public void testValidFeatures() {
FeaturePropertyMappers.validateEnabledFeature("preview");
FeaturePropertyMappers.validateEnabledFeature(Feature.ACCOUNT3.getVersionedKey());
FeaturePropertyMappers.validateEnabledFeature(Feature.ACCOUNT_V3.getVersionedKey());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ public Object getResource(KeycloakSession session, RealmModel realm, AdminPermis

@Override
public boolean isSupported(Config.Scope config) {
return Profile.isFeatureEnabled(Profile.Feature.ADMIN2);
return Profile.isFeatureEnabled(Profile.Feature.ADMIN_V2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ default String getDefaultThemeName(Theme.Type type) {
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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ private Response createWelcomePage(String successMessage, String errorMessage) {
}

private static boolean isAdminConsoleEnabled() {
return Profile.isFeatureEnabled(Profile.Feature.ADMIN2);
return Profile.isFeatureEnabled(Profile.Feature.ADMIN_V2);
}

private Theme getTheme() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,6 @@ private static boolean isAdminApiEnabled() {
}

private static boolean isAdminConsoleEnabled() {
return Profile.isFeatureEnabled(Profile.Feature.ADMIN2);
return Profile.isFeatureEnabled(Profile.Feature.ADMIN_V2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -235,17 +235,17 @@ private void setThemes(ServerInfoRepresentation info) {
private LinkedList<String> filterThemes(Theme.Type type, LinkedList<String> themeNames) {
LinkedList<String> 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");
filteredNames.remove("rh-sso.v2");
}

boolean filterAccountV3 = (type == Theme.Type.ACCOUNT) &&
!Profile.isFeatureEnabled(Profile.Feature.ACCOUNT3);
!Profile.isFeatureEnabled(Profile.Feature.ACCOUNT_V3);

if (filterAccountV3) {
filteredNames.remove("keycloak.v3");
Expand Down

0 comments on commit e8d8de8

Please sign in to comment.