KEYCLOAK-800 Ensure that loginFailures infinispan cache is defined
This commit is contained in:
parent
99016cdc83
commit
0f25280611
7 changed files with 19 additions and 12 deletions
|
@ -96,8 +96,8 @@ public class DefaultInfinispanConnectionProviderFactory implements InfinispanCon
|
|||
}
|
||||
Configuration invalidationCacheConfiguration = invalidationConfigBuilder.build();
|
||||
|
||||
cacheManager.defineConfiguration("realms", invalidationCacheConfiguration);
|
||||
cacheManager.defineConfiguration("users", invalidationCacheConfiguration);
|
||||
cacheManager.defineConfiguration(InfinispanConnectionProvider.REALM_CACHE_NAME, invalidationCacheConfiguration);
|
||||
cacheManager.defineConfiguration(InfinispanConnectionProvider.USER_CACHE_NAME, invalidationCacheConfiguration);
|
||||
|
||||
ConfigurationBuilder sessionConfigBuilder = new ConfigurationBuilder();
|
||||
if (clustered) {
|
||||
|
@ -115,7 +115,9 @@ public class DefaultInfinispanConnectionProviderFactory implements InfinispanCon
|
|||
.numSegments(config.getInt("sessionsSegments", 60)).build();
|
||||
}
|
||||
|
||||
cacheManager.defineConfiguration("sessions", sessionConfigBuilder.build());
|
||||
Configuration sessionCacheConfiguration = sessionConfigBuilder.build();
|
||||
cacheManager.defineConfiguration(InfinispanConnectionProvider.SESSION_CACHE_NAME, sessionCacheConfiguration);
|
||||
cacheManager.defineConfiguration(InfinispanConnectionProvider.LOGIN_FAILURE_CACHE_NAME, sessionCacheConfiguration);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,11 @@ import org.keycloak.provider.Provider;
|
|||
*/
|
||||
public interface InfinispanConnectionProvider extends Provider {
|
||||
|
||||
static final String REALM_CACHE_NAME = "realms";
|
||||
static final String USER_CACHE_NAME = "users";
|
||||
static final String SESSION_CACHE_NAME = "sessions";
|
||||
static final String LOGIN_FAILURE_CACHE_NAME = "loginFailures";
|
||||
|
||||
<K, V> Cache<K, V> getCache(String name);
|
||||
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
realm keys and password hashes) from being sent between the nodes.
|
||||
</para>
|
||||
<para>
|
||||
User sessions supports either distributed caches or fully replicated caches. We recommend using a distributed
|
||||
User sessions and login failures supports either distributed caches or fully replicated caches. We recommend using a distributed
|
||||
cache.
|
||||
</para>
|
||||
<para>
|
||||
|
@ -65,6 +65,7 @@
|
|||
<invalidation-cache name="realms" mode="SYNC"/>
|
||||
<invalidation-cache name="users" mode="SYNC"/>
|
||||
<distributed-cache name="sessions" mode="SYNC" owners="1" />
|
||||
<distributed-cache name="loginFailures" mode="SYNC" owners="1" />
|
||||
</cache-container>
|
||||
...
|
||||
</subsystem>
|
||||
|
|
|
@ -21,7 +21,7 @@ public class InfinispanCacheRealmProviderFactory implements CacheRealmProviderFa
|
|||
|
||||
@Override
|
||||
public CacheRealmProvider create(KeycloakSession session) {
|
||||
Cache<String, Object> cache = session.getProvider(InfinispanConnectionProvider.class).getCache("realms");
|
||||
Cache<String, Object> cache = session.getProvider(InfinispanConnectionProvider.class).getCache(InfinispanConnectionProvider.REALM_CACHE_NAME);
|
||||
RealmCache realmCache = new InfinispanRealmCache(cache, realmLookup);
|
||||
return new DefaultCacheRealmProvider(realmCache, session);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class InfinispanCacheUserProviderFactory implements CacheUserProviderFact
|
|||
synchronized (this) {
|
||||
if (userCache == null) {
|
||||
checkIspnVersion();
|
||||
Cache<String, CachedUser> cache = session.getProvider(InfinispanConnectionProvider.class).getCache("users");
|
||||
Cache<String, CachedUser> cache = session.getProvider(InfinispanConnectionProvider.class).getCache(InfinispanConnectionProvider.USER_CACHE_NAME);
|
||||
cache.addListener(new CacheListener());
|
||||
userCache = new InfinispanUserCache(cache, usernameLookup, emailLookup);
|
||||
}
|
||||
|
|
|
@ -15,14 +15,11 @@ import org.keycloak.models.sessions.infinispan.entities.SessionEntity;
|
|||
*/
|
||||
public class InfinispanUserSessionProviderFactory implements UserSessionProviderFactory {
|
||||
|
||||
private static final String SESSION_CACHE_NAME = "sessions";
|
||||
private static final String LOGIN_FAILURE_CACHE_NAME = "loginFailures";
|
||||
|
||||
@Override
|
||||
public UserSessionProvider create(KeycloakSession session) {
|
||||
InfinispanConnectionProvider connections = session.getProvider(InfinispanConnectionProvider.class);
|
||||
Cache<String, SessionEntity> cache = connections.getCache(SESSION_CACHE_NAME);
|
||||
Cache<LoginFailureKey, LoginFailureEntity> loginFailures = connections.getCache(LOGIN_FAILURE_CACHE_NAME);
|
||||
Cache<String, SessionEntity> cache = connections.getCache(InfinispanConnectionProvider.SESSION_CACHE_NAME);
|
||||
Cache<LoginFailureKey, LoginFailureEntity> loginFailures = connections.getCache(InfinispanConnectionProvider.LOGIN_FAILURE_CACHE_NAME);
|
||||
return new InfinispanUserSessionProvider(session, cache, loginFailures);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,9 @@ sed -i -e 's/<\/periodic-rotating-file-handler>/&\n <logger category=\"org.keycl
|
|||
|
||||
sed -i -e 's/<subsystem xmlns=\"urn:jboss:domain:infinispan:[0-9]\.[0-9]\">/&\n <cache-container name=\"keycloak\" jndi-name=\"infinispan\/Keycloak\" start=\"EAGER\"> \
|
||||
\n <transport lock-timeout=\"60000\"\/>\n <distributed-cache name=\"sessions\" mode=\"SYNC\" owners=\"2\" segments=\"60\"\/> \
|
||||
\n <invalidation-cache name=\"realms\" mode=\"SYNC\"\/>\n <\/cache-container>/' $JBOSS_HOME/standalone/configuration/standalone-ha.xml
|
||||
\n <distributed-cache name=\"loginFailures\" mode=\"SYNC\" owners=\"2\" segments=\"60\"\/> \
|
||||
\n <invalidation-cache name=\"realms\" mode=\"SYNC\"\/>\n \
|
||||
\n <invalidation-cache name=\"users\" mode=\"SYNC\"\/>\n <\/cache-container>/' $JBOSS_HOME/standalone/configuration/standalone-ha.xml
|
||||
|
||||
sed -i "s|<mod-cluster-config .*>|<mod-cluster-config advertise-socket=\"modcluster\" proxy-list=\"\$\{httpd.proxyList\}\" proxy-url=\"\/\" balancer=\"mycluster\" advertise=\"false\" connector=\"ajp\" sticky-session=\"true\">|" $JBOSS_HOME/standalone/configuration/standalone-ha.xml
|
||||
|
||||
|
|
Loading…
Reference in a new issue