[keycloak-user] custom cache

Dmitry Telegin dt at acutus.pro
Mon Nov 26 14:45:16 EST 2018


Hello Sud,

Keycloak's Infinispan subsystem doesn't restrict you to the predefined caches only. In your authenticator factory, you can retrieve an InfinispanConnectionProvider:

InfinispanConnectionProvider icp = session.getProvider(InfinispanConnectionProvider.class);

and then ask it to create and return your custom cache:

Cache<K, V> cache = icp.getCache("foobar");

That's basically what happens when you obtain any of the predefined caches. The only difference is that Keycloak preconfigures some defaults for them (see DefaultInfinispanConnectionProviderFactory).

Cheers,
Dmitry Telegin
CTO, Acutus s.r.o.
Keycloak Consulting and Training

Pod lipami street 339/52, 130 00 Prague 3, Czech Republic
+42 (022) 888-30-71
E-mail: info at acutus.pro

On Mon, 2018-11-26 at 13:50 -0500, Sud Ramasamy wrote:
> Hi,
> 
> We’ve developed a custom authenticator that we’ve been able o plugin into Keycloak to handle a custom authentication mechanism. The authenticator has some state that needs to be available across the cluster. We could store the state in the database and thereby make it available to other nodes in the cluster. But this seems a little heavy weight.
> 
> Instead we were hoping to be able to use the Infinispan capabilities in the Keycloak/Wildfly distribution to cache and distribute the state to nodes in the cluster. Is this possible without forking the Keycloak codebase? We noticed that the Keycloak infinispan model module provides the existing caching mechanism for the User, Realm and Session cache. Was wondering if there is a way to possibly plugin our own infinispan Cache Provider for our custom object and thereby use this cache in our custom authenticator in a similar way that the User, Realm and Session caches are used.
> 
> Or what our alternatives might we have.
> 
> Thanks in advance.
> -sud
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user


More information about the keycloak-user mailing list