mirror of
https://github.com/keycloak/keycloak.git
synced 2026-01-10 15:32:05 -03:30
Remove default cache configurations from cache-local.xml
Closes #42351 Signed-off-by: Ryan Emerson <remerson@ibm.com>
This commit is contained in:
parent
df478a8a8f
commit
73a4020baa
@ -42,6 +42,7 @@ import org.jboss.logging.Logger;
|
||||
import org.keycloak.Config;
|
||||
import org.keycloak.cluster.ClusterEvent;
|
||||
import org.keycloak.cluster.ClusterProvider;
|
||||
import org.keycloak.config.CachingOptions;
|
||||
import org.keycloak.connections.infinispan.remote.RemoteInfinispanConnectionProvider;
|
||||
import org.keycloak.infinispan.health.ClusterHealth;
|
||||
import org.keycloak.infinispan.util.InfinispanUtils;
|
||||
@ -245,7 +246,7 @@ public class DefaultInfinispanConnectionProviderFactory implements InfinispanCon
|
||||
*/
|
||||
@Deprecated(since = "26.3", forRemoval = true)
|
||||
protected Configuration getKeysCacheConfig() {
|
||||
return CacheConfigurator.getCacheConfiguration(KEYS_CACHE_NAME).build();
|
||||
return CacheConfigurator.getCacheConfiguration(KEYS_CACHE_NAME, true).build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -113,10 +113,11 @@ public final class CacheConfigurator {
|
||||
public static void applyDefaultConfiguration(ConfigurationBuilderHolder holder, boolean warnMutate) {
|
||||
var configs = holder.getNamedConfigurationBuilders();
|
||||
boolean userProvidedConfig = false;
|
||||
boolean clustered = holder.getGlobalConfigurationBuilder().transport().getTransport() != null;
|
||||
for (var name : ALL_CACHES_NAME) {
|
||||
var config = configs.get(name);
|
||||
if (config == null) {
|
||||
configs.put(name, getCacheConfiguration(name));
|
||||
configs.put(name, getCacheConfiguration(name, clustered));
|
||||
} else if (!userProvidedConfig) {
|
||||
userProvidedConfig = true;
|
||||
}
|
||||
@ -354,7 +355,7 @@ public final class CacheConfigurator {
|
||||
// cache configuration below
|
||||
|
||||
public static ConfigurationBuilder getCrlCacheConfig() {
|
||||
return getCacheConfiguration(CRL_CACHE_NAME);
|
||||
return getCacheConfiguration(CRL_CACHE_NAME, true);
|
||||
}
|
||||
|
||||
public static ConfigurationBuilder getRevisionCacheConfig(long maxEntries) {
|
||||
@ -391,7 +392,7 @@ public final class CacheConfigurator {
|
||||
* Returns a cache's default configuration.
|
||||
* Revision caches are not returned as their configuration depends on their associated cache's configuration.
|
||||
*/
|
||||
public static ConfigurationBuilder getCacheConfiguration(String cacheName) {
|
||||
public static ConfigurationBuilder getCacheConfiguration(String cacheName, boolean clustered) {
|
||||
var builder = new ConfigurationBuilder();
|
||||
switch (cacheName) {
|
||||
// Distributed Caches
|
||||
@ -399,13 +400,17 @@ public final class CacheConfigurator {
|
||||
case USER_SESSION_CACHE_NAME:
|
||||
case OFFLINE_CLIENT_SESSION_CACHE_NAME:
|
||||
case OFFLINE_USER_SESSION_CACHE_NAME:
|
||||
builder.clustering().cacheMode(CacheMode.DIST_SYNC).hash().numOwners(1);
|
||||
if (clustered) {
|
||||
builder.clustering().cacheMode(CacheMode.DIST_SYNC).hash().numOwners(1);
|
||||
}
|
||||
builder.memory().maxCount(SESSIONS_CACHE_DEFAULT_MAX);
|
||||
return builder;
|
||||
case ACTION_TOKEN_CACHE:
|
||||
case AUTHENTICATION_SESSIONS_CACHE_NAME:
|
||||
case LOGIN_FAILURE_CACHE_NAME:
|
||||
builder.clustering().cacheMode(CacheMode.DIST_SYNC);
|
||||
if (clustered) {
|
||||
builder.clustering().cacheMode(CacheMode.DIST_SYNC);
|
||||
}
|
||||
builder.encoding().mediaType(MediaType.APPLICATION_OBJECT_TYPE);
|
||||
return builder;
|
||||
// Local Caches
|
||||
@ -426,7 +431,9 @@ public final class CacheConfigurator {
|
||||
return builder;
|
||||
// Replicated caches
|
||||
case WORK_CACHE_NAME:
|
||||
builder.clustering().cacheMode(CacheMode.REPL_SYNC);
|
||||
if (clustered) {
|
||||
builder.clustering().cacheMode(CacheMode.REPL_SYNC);
|
||||
}
|
||||
return builder;
|
||||
default:
|
||||
return null;
|
||||
|
||||
@ -20,80 +20,5 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="urn:infinispan:config:15.0 http://www.infinispan.org/schemas/infinispan-config-15.0.xsd"
|
||||
xmlns="urn:infinispan:config:15.0">
|
||||
|
||||
<cache-container name="keycloak">
|
||||
<local-cache name="default">
|
||||
<transaction transaction-manager-lookup="org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup"/>
|
||||
</local-cache>
|
||||
<local-cache name="realms" simple-cache="true">
|
||||
<encoding>
|
||||
<key media-type="application/x-java-object"/>
|
||||
<value media-type="application/x-java-object"/>
|
||||
</encoding>
|
||||
<memory max-count="10000"/>
|
||||
</local-cache>
|
||||
<local-cache name="users" simple-cache="true">
|
||||
<encoding>
|
||||
<key media-type="application/x-java-object"/>
|
||||
<value media-type="application/x-java-object"/>
|
||||
</encoding>
|
||||
<memory max-count="10000"/>
|
||||
</local-cache>
|
||||
<local-cache name="sessions">
|
||||
<expiration lifespan="-1"/>
|
||||
<memory max-count="10000"/>
|
||||
</local-cache>
|
||||
<local-cache name="authenticationSessions">
|
||||
<expiration lifespan="-1"/>
|
||||
</local-cache>
|
||||
<local-cache name="offlineSessions">
|
||||
<expiration lifespan="-1"/>
|
||||
<memory max-count="10000"/>
|
||||
</local-cache>
|
||||
<local-cache name="clientSessions">
|
||||
<expiration lifespan="-1"/>
|
||||
<memory max-count="10000"/>
|
||||
</local-cache>
|
||||
<local-cache name="offlineClientSessions">
|
||||
<expiration lifespan="-1"/>
|
||||
<memory max-count="10000"/>
|
||||
</local-cache>
|
||||
<local-cache name="loginFailures">
|
||||
<expiration lifespan="-1"/>
|
||||
</local-cache>
|
||||
<local-cache name="authorization" simple-cache="true">
|
||||
<encoding>
|
||||
<key media-type="application/x-java-object"/>
|
||||
<value media-type="application/x-java-object"/>
|
||||
</encoding>
|
||||
<memory max-count="10000"/>
|
||||
</local-cache>
|
||||
<local-cache name="work">
|
||||
<expiration lifespan="-1"/>
|
||||
</local-cache>
|
||||
<local-cache name="keys" simple-cache="true">
|
||||
<encoding>
|
||||
<key media-type="application/x-java-object"/>
|
||||
<value media-type="application/x-java-object"/>
|
||||
</encoding>
|
||||
<expiration max-idle="3600000"/>
|
||||
<memory max-count="1000"/>
|
||||
</local-cache>
|
||||
<local-cache name="crl" simple-cache="true">
|
||||
<encoding>
|
||||
<key media-type="application/x-java-object"/>
|
||||
<value media-type="application/x-java-object"/>
|
||||
</encoding>
|
||||
<expiration lifespan="-1"/>
|
||||
<memory max-count="1000"/>
|
||||
</local-cache>
|
||||
<local-cache name="actionTokens">
|
||||
<encoding>
|
||||
<key media-type="application/x-java-object"/>
|
||||
<value media-type="application/x-java-object"/>
|
||||
</encoding>
|
||||
<expiration max-idle="-1" lifespan="-1" interval="300000"/>
|
||||
<memory max-count="-1"/>
|
||||
</local-cache>
|
||||
</cache-container>
|
||||
<cache-container />
|
||||
</infinispan>
|
||||
|
||||
@ -206,6 +206,7 @@ public class ClusterConfigDistTest {
|
||||
result.assertNoMessage("JGroups JDBC_PING discovery enabled");
|
||||
result.assertNoMessage("JGroups Encryption enabled.");
|
||||
result.assertNoMessage("Starting JGroups certificate reload manager");
|
||||
result.assertNoMessage("Modifying the default cache configuration in the config file without setting cache-config-mutate=true is deprecated.");
|
||||
}
|
||||
|
||||
public static class ConfigureCacheUsingAsyncEncryption implements Consumer<KeycloakDistribution> {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user