From 76d9125c3fad117a23d87cd6e6b054007c6770cf Mon Sep 17 00:00:00 2001 From: Klaus Betz <78362353+klausbetz@users.noreply.github.com> Date: Tue, 18 Oct 2022 15:54:06 +0200 Subject: [PATCH] feat: add DisplayIconClasses to IdentityProviderModel for third-party IDPs https://github.com/klausbetz/apple-identity-provider-keycloak/issues/10 (#14826) Closes #14974 --- .../org/keycloak/models/IdentityProviderModel.java | 4 ++++ .../login/freemarker/model/IdentityProviderBean.java | 11 +++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/server-spi/src/main/java/org/keycloak/models/IdentityProviderModel.java b/server-spi/src/main/java/org/keycloak/models/IdentityProviderModel.java index 101c20951e..7f01927279 100755 --- a/server-spi/src/main/java/org/keycloak/models/IdentityProviderModel.java +++ b/server-spi/src/main/java/org/keycloak/models/IdentityProviderModel.java @@ -205,6 +205,10 @@ public class IdentityProviderModel implements Serializable { this.displayName = displayName; } + public String getDisplayIconClasses() { + return null; + } + /** *
Validates this configuration.
*
diff --git a/services/src/main/java/org/keycloak/forms/login/freemarker/model/IdentityProviderBean.java b/services/src/main/java/org/keycloak/forms/login/freemarker/model/IdentityProviderBean.java
index f8f89930df..2e1b04a349 100755
--- a/services/src/main/java/org/keycloak/forms/login/freemarker/model/IdentityProviderBean.java
+++ b/services/src/main/java/org/keycloak/forms/login/freemarker/model/IdentityProviderBean.java
@@ -73,18 +73,21 @@ public class IdentityProviderBean {
if (!hideOnLoginPage) {
orderedSet.add(new IdentityProvider(identityProvider.getAlias(),
displayName, identityProvider.getProviderId(), loginUrl,
- config != null ? config.get("guiOrder") : null, getLoginIconClasses(identityProvider.getAlias())));
+ config != null ? config.get("guiOrder") : null, getLoginIconClasses(identityProvider)));
}
}
// Get icon classes defined in properties of current theme with key 'kcLogoIdP-{alias}'
+ // OR from IdentityProviderModel.getDisplayIconClasses if not defined in theme (for third-party IDPs like Sign-In-With-Apple)
// f.e. kcLogoIdP-github = fa fa-github
- private String getLoginIconClasses(String alias) {
+ private String getLoginIconClasses(IdentityProviderModel identityProvider) {
final String ICON_THEME_PREFIX = "kcLogoIdP-";
try {
Theme theme = session.theme().getTheme(Theme.Type.LOGIN);
- return Optional.ofNullable(theme.getProperties().getProperty(ICON_THEME_PREFIX + alias)).orElse("");
+ Optional