fix: consider identity provider models from third-party packages
This commit is contained in:
parent
b2d94b22e7
commit
20a7a5acdb
2 changed files with 23 additions and 2 deletions
|
@ -19,6 +19,9 @@ package org.keycloak.models.jpa;
|
||||||
|
|
||||||
import org.keycloak.Config;
|
import org.keycloak.Config;
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
import org.keycloak.broker.provider.IdentityProvider;
|
||||||
|
import org.keycloak.broker.provider.IdentityProviderFactory;
|
||||||
|
import org.keycloak.broker.social.SocialIdentityProvider;
|
||||||
import org.keycloak.common.enums.SslRequired;
|
import org.keycloak.common.enums.SslRequired;
|
||||||
import org.keycloak.common.util.MultivaluedHashMap;
|
import org.keycloak.common.util.MultivaluedHashMap;
|
||||||
import org.keycloak.common.util.Time;
|
import org.keycloak.common.util.Time;
|
||||||
|
@ -1197,7 +1200,7 @@ public class RealmAdapter implements LegacyRealmModel, JpaModel<RealmEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private IdentityProviderModel entityToModel(IdentityProviderEntity entity) {
|
private IdentityProviderModel entityToModel(IdentityProviderEntity entity) {
|
||||||
IdentityProviderModel identityProviderModel = new IdentityProviderModel();
|
IdentityProviderModel identityProviderModel = getModelFromProviderFactory(entity.getProviderId());
|
||||||
identityProviderModel.setProviderId(entity.getProviderId());
|
identityProviderModel.setProviderId(entity.getProviderId());
|
||||||
identityProviderModel.setAlias(entity.getAlias());
|
identityProviderModel.setAlias(entity.getAlias());
|
||||||
identityProviderModel.setDisplayName(entity.getDisplayName());
|
identityProviderModel.setDisplayName(entity.getDisplayName());
|
||||||
|
@ -1218,6 +1221,21 @@ public class RealmAdapter implements LegacyRealmModel, JpaModel<RealmEntity> {
|
||||||
return identityProviderModel;
|
return identityProviderModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IdentityProviderModel getModelFromProviderFactory(String providerId) {
|
||||||
|
Optional<IdentityProviderFactory> factory = Stream.concat(session.getKeycloakSessionFactory().getProviderFactoriesStream(IdentityProvider.class),
|
||||||
|
session.getKeycloakSessionFactory().getProviderFactoriesStream(SocialIdentityProvider.class))
|
||||||
|
.filter(providerFactory -> Objects.equals(providerFactory.getId(), providerId))
|
||||||
|
.map(IdentityProviderFactory.class::cast)
|
||||||
|
.findFirst();
|
||||||
|
|
||||||
|
if (factory.isPresent()) {
|
||||||
|
return factory.get().createConfig();
|
||||||
|
} else {
|
||||||
|
logger.warn("Couldn't find a suitable identity provider factory for " + providerId);
|
||||||
|
return new IdentityProviderModel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IdentityProviderModel getIdentityProviderByAlias(String alias) {
|
public IdentityProviderModel getIdentityProviderByAlias(String alias) {
|
||||||
return getIdentityProvidersStream()
|
return getIdentityProvidersStream()
|
||||||
|
|
|
@ -70,6 +70,8 @@ public class IdentityProviderModel implements Serializable {
|
||||||
|
|
||||||
private String displayName;
|
private String displayName;
|
||||||
|
|
||||||
|
private String displayIconClasses;
|
||||||
|
|
||||||
private IdentityProviderSyncMode syncMode;
|
private IdentityProviderSyncMode syncMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -96,6 +98,7 @@ public class IdentityProviderModel implements Serializable {
|
||||||
this.addReadTokenRoleOnCreate = model.addReadTokenRoleOnCreate;
|
this.addReadTokenRoleOnCreate = model.addReadTokenRoleOnCreate;
|
||||||
this.firstBrokerLoginFlowId = model.getFirstBrokerLoginFlowId();
|
this.firstBrokerLoginFlowId = model.getFirstBrokerLoginFlowId();
|
||||||
this.postBrokerLoginFlowId = model.getPostBrokerLoginFlowId();
|
this.postBrokerLoginFlowId = model.getPostBrokerLoginFlowId();
|
||||||
|
this.displayIconClasses = model.getDisplayIconClasses();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +209,7 @@ public class IdentityProviderModel implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDisplayIconClasses() {
|
public String getDisplayIconClasses() {
|
||||||
return null;
|
return displayIconClasses;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue