Make the IDPProvider via session.identityProviders()

Closes #31252

Signed-off-by: Stefan Guilhen <sguilhen@redhat.com>
This commit is contained in:
Stefan Guilhen 2024-07-23 12:56:51 -03:00 committed by Alexander Schwartz
parent 4c5f54ce0b
commit c16e88bcee
4 changed files with 27 additions and 1 deletions

View file

@ -20,6 +20,7 @@ package org.keycloak.storage.datastore;
import org.keycloak.models.ClientProvider; import org.keycloak.models.ClientProvider;
import org.keycloak.models.ClientScopeProvider; import org.keycloak.models.ClientScopeProvider;
import org.keycloak.models.GroupProvider; import org.keycloak.models.GroupProvider;
import org.keycloak.models.IDPProvider;
import org.keycloak.models.KeycloakSession; import org.keycloak.models.KeycloakSession;
import org.keycloak.models.RealmProvider; import org.keycloak.models.RealmProvider;
import org.keycloak.models.RoleProvider; import org.keycloak.models.RoleProvider;
@ -49,6 +50,7 @@ public class DefaultDatastoreProvider implements DatastoreProvider, StoreManager
private ClientProvider clientProvider; private ClientProvider clientProvider;
private ClientScopeProvider clientScopeProvider; private ClientScopeProvider clientScopeProvider;
private GroupProvider groupProvider; private GroupProvider groupProvider;
private IDPProvider idpProvider;
private UserLoginFailureProvider userLoginFailureProvider; private UserLoginFailureProvider userLoginFailureProvider;
private RealmProvider realmProvider; private RealmProvider realmProvider;
private RoleProvider roleProvider; private RoleProvider roleProvider;
@ -210,6 +212,14 @@ public class DefaultDatastoreProvider implements DatastoreProvider, StoreManager
return groupProvider; return groupProvider;
} }
@Override
public IDPProvider identityProviders() {
if (idpProvider == null) {
idpProvider = session.getProvider(IDPProvider.class);
}
return idpProvider;
}
@Override @Override
public UserLoginFailureProvider loginFailures() { public UserLoginFailureProvider loginFailures() {
if (userLoginFailureProvider == null) { if (userLoginFailureProvider == null) {

View file

@ -20,6 +20,7 @@ package org.keycloak.storage;
import org.keycloak.models.ClientProvider; import org.keycloak.models.ClientProvider;
import org.keycloak.models.ClientScopeProvider; import org.keycloak.models.ClientScopeProvider;
import org.keycloak.models.GroupProvider; import org.keycloak.models.GroupProvider;
import org.keycloak.models.IDPProvider;
import org.keycloak.models.RealmProvider; import org.keycloak.models.RealmProvider;
import org.keycloak.models.RoleProvider; import org.keycloak.models.RoleProvider;
import org.keycloak.models.SingleUseObjectProvider; import org.keycloak.models.SingleUseObjectProvider;
@ -39,6 +40,8 @@ public interface DatastoreProvider extends Provider {
GroupProvider groups(); GroupProvider groups();
IDPProvider identityProviders();
UserLoginFailureProvider loginFailures(); UserLoginFailureProvider loginFailures();
RealmProvider realms(); RealmProvider realms();

View file

@ -204,6 +204,13 @@ public interface KeycloakSession extends AutoCloseable {
SingleUseObjectProvider singleUseObjects(); SingleUseObjectProvider singleUseObjects();
/**
* Returns the default IDP provider .
*
* @return the default IDP provider.
*/
IDPProvider identityProviders();
@Override @Override
void close(); void close();

View file

@ -25,6 +25,7 @@ import org.keycloak.keys.DefaultKeyManager;
import org.keycloak.models.ClientProvider; import org.keycloak.models.ClientProvider;
import org.keycloak.models.ClientScopeProvider; import org.keycloak.models.ClientScopeProvider;
import org.keycloak.models.GroupProvider; import org.keycloak.models.GroupProvider;
import org.keycloak.models.IDPProvider;
import org.keycloak.models.KeyManager; import org.keycloak.models.KeyManager;
import org.keycloak.models.KeycloakContext; import org.keycloak.models.KeycloakContext;
import org.keycloak.models.KeycloakSession; import org.keycloak.models.KeycloakSession;
@ -316,6 +317,11 @@ public abstract class DefaultKeycloakSession implements KeycloakSession {
return getDatastoreProvider().singleUseObjects(); return getDatastoreProvider().singleUseObjects();
} }
@Override
public IDPProvider identityProviders() {
return getDatastoreProvider().identityProviders();
}
@Override @Override
public KeyManager keys() { public KeyManager keys() {
if (keyManager == null) { if (keyManager == null) {