From eb17157e447194c49edd004fd585774d40c6fd02 Mon Sep 17 00:00:00 2001 From: stianst Date: Thu, 10 Nov 2022 05:39:20 -0500 Subject: [PATCH] Stop adding .v2 to default theme if set in server config Closes #15392 --- .../keycloak/theme/ThemeSelectorProvider.java | 23 +++++++++++++------ .../theme/DefaultThemeSelectorProvider.java | 2 -- 2 files changed, 16 insertions(+), 9 deletions(-) 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 4a96cd1b98..4e49c4d4a3 100755 --- a/server-spi/src/main/java/org/keycloak/theme/ThemeSelectorProvider.java +++ b/server-spi/src/main/java/org/keycloak/theme/ThemeSelectorProvider.java @@ -19,7 +19,6 @@ package org.keycloak.theme; import org.keycloak.Config; import org.keycloak.common.Profile; -import org.keycloak.common.Version; import org.keycloak.provider.Provider; /** @@ -27,6 +26,9 @@ import org.keycloak.provider.Provider; */ public interface ThemeSelectorProvider extends Provider { + String DEFAULT = "keycloak"; + String DEFAULT_V2 = "keycloak.v2"; + /** * Return the theme name to use for the specified type * @@ -36,13 +38,20 @@ public interface ThemeSelectorProvider extends Provider { String getThemeName(Theme.Type type); default String getDefaultThemeName(Theme.Type type) { - String name = Config.scope("theme").get("default", Version.NAME.toLowerCase()); - if ((type == Theme.Type.ACCOUNT) && Profile.isFeatureEnabled(Profile.Feature.ACCOUNT2)) { - name = name.concat(".v2"); - } else if ((type == Theme.Type.ADMIN) && Profile.isFeatureEnabled(Profile.Feature.ADMIN2)) { - name = name.concat(".v2"); + String name = Config.scope("theme").get("default"); + if (name != null && !name.isEmpty()) { + return name; } - return name; + + if ((type == Theme.Type.ACCOUNT) && Profile.isFeatureEnabled(Profile.Feature.ACCOUNT2)) { + return DEFAULT_V2; + } + + if ((type == Theme.Type.ADMIN) && Profile.isFeatureEnabled(Profile.Feature.ADMIN2)) { + return DEFAULT_V2; + } + + return DEFAULT; } } diff --git a/services/src/main/java/org/keycloak/theme/DefaultThemeSelectorProvider.java b/services/src/main/java/org/keycloak/theme/DefaultThemeSelectorProvider.java index b1a61dc81b..9208fa6fc4 100644 --- a/services/src/main/java/org/keycloak/theme/DefaultThemeSelectorProvider.java +++ b/services/src/main/java/org/keycloak/theme/DefaultThemeSelectorProvider.java @@ -1,8 +1,6 @@ package org.keycloak.theme; import org.keycloak.Config; -import org.keycloak.common.Profile; -import org.keycloak.common.Version; import org.keycloak.models.ClientModel; import org.keycloak.models.KeycloakSession;