Infinispan 在使用 Spring Session 外部化会话存储时没有编组整个 RefreshableKeycloakSecurityContext

Infinispan is not marshalling the whole RefreshableKeycloakSecurityContext when using Spring Session to externalize the session store

我正在使用 Spring Session 将应用程序会话存储在外部存储中,在本例中为 Infinispan 缓存。

为此,我实现了一个自定义 SessionRepository,它在下面使用了 Infinispan 的 RemoteCacheManager

会话中的“正常”对象可以毫无问题地存储和解组。

我的应用程序与用于 SSO 的 Keycloak 集成,使用 Keycloak 的 Spring 启动适配器。这会设置类型 RefreshableKeycloakSecurityContext 的会话对象。这是将会话保存在远程缓存中的调用,正如您所看到的 Refreshable... 具有一些设置的属性(KeycloakDeployment,SpringSecurityTokenStore):

但是当从会话存储中检索 Refreshable... 属性时,KeycloakDeployment 和其他一些属性都消失了:

随着它们的消失,适配器提供的一些功能(例如刷新令牌)丢失了,正如您在 Refreshable 的下一位中所看到的...需要部署的地方:

知道如何存储这些属性并从 Infinispan 检索这些属性吗?

更新

RefreshableKeycloakSecurityContextKeycloakDeploymentAdapterTokenStore 定义为瞬时的,因此它们并不意味着被序列化。这样做的问题是,当会话被外部化或简单序列化时,它会破坏适配器……有什么解决方法吗?

package org.keycloak.adapters;
...
/**
 * @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
 * @version $Revision: 1 $
 */
public class RefreshableKeycloakSecurityContext extends KeycloakSecurityContext {

    protected static Logger log = Logger.getLogger(RefreshableKeycloakSecurityContext.class);

    protected transient KeycloakDeployment deployment;
    protected transient AdapterTokenStore tokenStore;
    protected String refreshToken;

我们正在使用的适配器版本中存在错误,已按照以下 Red Hat 问题中的说明修复:https://issues.redhat.com/browse/KEYCLOAK-6752?attachmentViewMode=list