+
Skip to content

Pass IDP config values to themes #40373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.net.URI;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Properties;
Expand All @@ -53,6 +54,7 @@ public class IdentityProviderBean {

public static OrderedModel.OrderedModelComparator<IdentityProvider> IDP_COMPARATOR_INSTANCE = new OrderedModel.OrderedModelComparator<>();
private static final String ICON_THEME_PREFIX = "kcLogoIdP-";
private static final String IDP_THEME_CONFIG_PREFIX = "kcTheme-";

protected AuthenticationFlowContext context;
protected List<IdentityProvider> providers;
Expand Down Expand Up @@ -108,9 +110,12 @@ public AuthenticationFlowContext getFlowContext() {
protected IdentityProvider createIdentityProvider(RealmModel realm, URI baseURI, IdentityProviderModel identityProvider) {
String loginUrl = Urls.identityProviderAuthnRequest(baseURI, identityProvider.getAlias(), realm.getName()).toString();
String displayName = KeycloakModelUtils.getIdentityProviderDisplayName(session, identityProvider);
Map<String, String> themeConfig = identityProvider.getConfig().entrySet().stream()
.filter(entry -> entry.getKey().startsWith(IDP_THEME_CONFIG_PREFIX))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
return new IdentityProvider(identityProvider.getAlias(),
displayName, identityProvider.getProviderId(), loginUrl,
identityProvider.getConfig().get("guiOrder"), getLoginIconClasses(identityProvider));
identityProvider.getConfig().get("guiOrder"), getLoginIconClasses(identityProvider), themeConfig);
}

// Get icon classes defined in properties of current theme with key 'kcLogoIdP-{alias}'
Expand Down Expand Up @@ -253,18 +258,20 @@ public static class IdentityProvider implements OrderedModel {
private final String guiOrder;
private final String displayName;
private final String iconClasses;
private final Map<String, String> themeConfig;

public IdentityProvider(String alias, String displayName, String providerId, String loginUrl, String guiOrder) {
this(alias, displayName, providerId, loginUrl, guiOrder, "");
this(alias, displayName, providerId, loginUrl, guiOrder, "", null);
}

public IdentityProvider(String alias, String displayName, String providerId, String loginUrl, String guiOrder, String iconClasses) {
public IdentityProvider(String alias, String displayName, String providerId, String loginUrl, String guiOrder, String iconClasses, Map<String, String> themeConfig) {
this.alias = alias;
this.displayName = displayName;
this.providerId = providerId;
this.loginUrl = loginUrl;
this.guiOrder = guiOrder;
this.iconClasses = iconClasses;
this.themeConfig = themeConfig;
}

public String getAlias() {
Expand All @@ -291,6 +298,10 @@ public String getDisplayName() {
public String getIconClasses() {
return iconClasses;
}

public Map<String, String> getThemeConfig() {
return themeConfig;
}
}


Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载