Open Liberty 22.0.0.4-beta提供了GraphQL 2.0,其中纳入了Jakarta EE 9.1的依赖性,并支持Java 18,其中包括许多新的令人兴奋的功能和变化。这个版本还包括分布式安全缓存支持,它允许多个Liberty服务器通过JCache提供者共享缓存。
Open Liberty22.0.0.4-beta包括以下测试版特性和功能(以及所有GA特性和功能):
MicroProfile GraphQL 2.0
MicroProfile GraphQL 2.0结合了Jakarta EE 9.1的依赖性。 这使得开发者可以继续使用MP GraphQL 1.0提供的相同功能,但要有更新的Jakarta特性,如CDI 3.0、restfulWS3.0、JSON-B 2.0等。在功能上,2.0版与1.0版相同,因为它使用相同版本的底层实现(SmallRye GraphQL)。 如果你想了解更多关于MP GraphQL的信息,请参阅我们之前关于MP GraphQL 1.0的博文以及关于如何使用GraphiQL UI和第三方客户端API的博文。
要在你的应用程序中启用MicroProfile GraphQL 2.0测试版功能,请将其添加到你的server.xml :
<featureManager>
<feature>mpGraphQL-2.0</feature>
</featureManager>
Java 18支持
Java 18即将到来,随之而来的是以下功能和变化:
Java安全支持已经随着Liberty中的Java 18+被移除。 如果 "websphere.java.security "被设置在 |
通过现在试用Java 18,你可以有更多的时间来审查你的应用程序、微服务和运行时环境,当它普遍可用时,你将领先一步。
要想今天就试一试,请下载Java 18的早期访问版本,安装22.0.0.4-beta版本的Open Liberty,编辑你的Liberty服务器的server.env文件,将JAVA_HOME ,指向你的Java 18安装,然后开始测试
关于Java 18的更多信息,请访问Java 18发布说明页面、API Javadoc页面或下载页面。 关于Open Liberty的更多信息,请访问我们的文档页面。
如果你发现有什么不妥,请告诉我们。
分布式安全缓存
分布式安全缓存支持已经被引入,以便多个Liberty服务器可以通过JCache 提供者共享缓存。在此功能之前,认证(主题)和注销的cookie缓存被限制为本地和内存中的缓存。多个服务器无法从他们的同行的缓存中获益,每个服务器都是从一个冷缓存开始的。
作为这个功能的一部分,两个缓存都可以存储在一个分布式的JCache 。这可以提高性能和故障恢复,减少后端用户注册的负载,并提高服务器的安全态势。
在这个测试版中使用新的分布式缓存功能时,需要在server.xml 文件的功能列表中包含distributedSecurityCache-1.0 。这个仅供测试的功能将JCache API暴露给第三方JCache 供应商。 |
配置分布式认证缓存
由于创建一个主题可能会影响性能,Liberty提供了一个认证缓存,在用户认证成功后存储一个主题。现在,认证缓存可以使用第三方JCache提供者来分布。要配置分布式认证缓存,请使用以下server.xml配置:
<featureManager>
<feature>appSecurity-3.0</feature>
<feature>distributedSecurityCache-1.0</feature>
</featureManager>
<!--
The 3rd-party JCache provider library that Liberty will use to manage and connect to the cache.
-->
<library id="JCacheProviderLib">
<fileset dir="${shared.resource.dir}" includes="jcacheprovider.jar" />
</library>
<!--
Configure the JCache cache instance.
-->
<cache id="AuthCache" name="AuthCache">
<cacheManager uri="uri://someuri">
<properties prop1="value1" prop2="value2" />
<cachingProvider libraryRef="JCacheProviderLib" />
</cacheManager>
</cache>
<!--
Configure the authentication cache.
-->
<authCache cacheRef="AuthCache" />
如果你的Liberty环境在你的主体中注入了自定义的原则或凭证,例如在自定义的LoginModule 或Trust Association Interceptor (TAI),它们必须被Serializable ,以便将它们存储在分布式认证缓存中。此外,包含这些类的共享库必须对缓存提供者和需要访问这些类的任何其他配置可用。如果每个共享库没有使用相同的共享库,那么在使用从分布式缓存中检索的类时可能会遇到ClassCastExceptions 。
<featureManager>
<feature>appSecurity-3.0</feature>
<feature>distributedSecurityCache-1.0</feature>
</featureManager>
<!--
The 3rd-party JCache provider library that Liberty will use to manage and connect to the cache.
-->
<library id="JCacheProviderLib">
<fileset dir="${shared.resource.dir}" includes="jcacheprovider.jar" />
</library>
<!--
This shared library contains any custom credentials and/or principals that
are stored in the subject.
-->
<library id="CustomLib">
<fileset dir="${shared.resource.dir}" includes="customlibrary.jar" />
</library>
<!--
Take notice that the 'libraryRef' attribute has both library references.
-->
<cache ... >
<cacheManager ... >
<cachingProvider libraryRef="JCacheProviderLib,CustomLib" />
</cacheManager>
</cache>
<!--
Some sample JAAS custom login module configuration. The custom login module
in this example would inject custom credentials or principals into the subject.
Note that the 'libraryRef' in the 'jaasLoginModule' needs to be set to the same
library referenced from the caching provider.
-->
<jaasLoginContextEntry id="system.WEB_INBOUND"
name="system.WEB_INBOUND"
loginModuleRef="custom, hashtable, userNameAndPassword, certificate, token" />
<jaasLoginModule id="custom"
className="org.acme.CustomLoginModule"
controlFlag="REQUIRED" libraryRef="CustomLib" />
<!--
Any applications that will be accessing classes from the Subject also need
to use the same library reference.
-->
<application ...>
<classloader commonLibraryRef="CustomLib" />
</application>
在配置用于认证缓存的JCache时,有几点需要考虑:
-
分布式认证缓存由键和值组成,类型为
Object。为了与本地认证缓存的行为相匹配,设置一个最近最少使用的驱逐(LRU)策略,最大条目数为25000,条目TTL为600秒。注意,对于分布式缓存,缓存的分区可能导致实际容量低于配置值。 -
如果你的
JCache供应商支持它,配置一个客户端缓存以减少对分布式缓存的交易。如果客户端缓存支持将条目存储为反序列化的对象,这可以进一步提高性能。 -
目前,测试版的支持仅限于
LTPA和JWT。还不支持单点登录方法,如SPNEGO、Oauth、OIDC和SAML(等)。 -
分布式缓存中的主题应像对待其他安全敏感信息一样对待,如用户名和密码。配置你的
JCache供应商,以确保数据在移动和静止时的安全。这应该包括加密和访问控制。
配置一个分布式的已注销Cookie缓存
注销的cookie缓存存储LTPA 和JWT 已经注销的cookie。现在可以使用第三方JCache 供应商来分配注销的cookie缓存,确保注销的cookie在多个服务器上强制执行。要配置分布式注销cookie缓存,请使用以下server.xml 配置。
<featureManager>
<feature>appSecurity-3.0</feature>
<feature>distributedSecurityCache-1.0</feature>
</featureManager>
<!--
The 3rd-party JCache provider library that Liberty will use to manage and connect to the cache.
-->
<library id="JCacheProviderLib">
<fileset dir="${shared.resource.dir}" includes="jcacheprovider.jar" />
</library>
<!--
Configure the JCache instances.
-->
<cache id="LoggedOutCookieCache" name="LoggedOutCookieCache">
<cacheManager uri="uri://someuri">
<properties prop1="value1" prop2="value2" />
<cachingProvider libraryRef="JCacheProviderLib" />
</cacheManager>
</cache>
<!--
Configure the authentication cache to use the JCache.
-->
<webAppSecurity loggedoutCookieCacheRef="LoggedOutCookieCache" />
在配置JCache缓存以使用注销cookie缓存时,有几点需要考虑:
-
分布式注销cookie缓存由键和值组成,其类型为
Object。 -
为了与本地注销的cookie缓存的行为相匹配,将缓存的最大条目数配置为10000,条目TTL为无限。注意,对于分布式缓存,缓存的分区可能导致实际容量低于配置值。缓存的容量应该足够大,不会因为新注销的cookies被插入缓存而导致未过期的cookies被驱逐。
-
如果你的JCache提供商支持,配置一个客户端缓存以减少对分布式缓存的事务。如果客户端缓存支持将条目存储为反序列化的对象,这可以进一步提高性能。
用新的分布式缓存配置来配置会话缓存
sessionCache-1.0 功能已经更新,允许使用新的分布式缓存配置元素,以允许在所有使用JCache 的功能中进行共同配置。这消除了为会话缓存单独配置JCache 的需要。
<featureManager>
<feature>distributedSecurityCache-1.0</feature>
<feature>sessionCache-1.0</feature>
</featureManager>
<!--
The 3rd-party JCache provider library that Liberty will use to manage and connect to the cache.
-->
<library id="JCacheProviderLib">
<fileset dir="${shared.resource.dir}" includes="jcacheprovider.jar" />
</library>
<!--
Configure the JCache cache manager.
-->
<cacheManager id="CacheManager" uri="uri://someuri">
<properties prop1="value1" prop2="value2" />
<cachingProvider libraryRef="JCacheProviderLib" />
</cacheManager>
<!--
Configure the HTTP session cache.
-->
<httpSessionCache cacheManagerRef="CacheManager" ... />
配置多个缓存
当配置多个分布式缓存时,不需要在缓存元素中嵌套cacheManager 配置元素,缓存元素需要通过cacheRef 属性来引用缓存管理器。
<featureManager>
<feature>appSecurity-3.0</feature>
<feature>distributedSecurityCache-1.0</feature>
<feature>sessionCache-1.0</feature>
</featureManager>
<!--
The 3rd-party JCache provider library that Liberty will use to manage and connect to the cache.
-->
<library id="JCacheProviderLib">
<fileset dir="${shared.resource.dir}" includes="jcacheprovider.jar" />
</library>
<!--
Configure the JCache cache manager.
-->
<cacheManager id="CacheManager" uri="uri://someuri">
<properties prop1="value1" prop2="value2" />
<cachingProvider libraryRef="JCacheProviderLib" />
</cacheManager>
<!--
Configure the JCache cache instances.
-->
<cache id="AuthCache" name="AuthCache" cacheManagerRef="CacheManager" />
<cache id="LoggedOutCookieCache" name="LoggedOutCookieCache" cacheManagerRef="CacheManager" />
<!--
Configured the authentication cache, logged-out cookie cache and HTTP session cache.
-->
<authCache cacheRef="AuthCache" />
<webAppSecurity loggedoutCookieCacheRef="LoggedOutCookieCache" ... />
<httpSessionCache cacheManagerRef="CacheManager" ... />
要了解更多信息,请查看appSecurity功能启用的认证和authCache元素,以及JCache会话持久性的例子。
现在就试试吧
要尝试这些功能,只需更新你的构建工具,拉出Open Liberty所有测试版功能包,而不是主版本。该测试版适用于Java SE 18、Java SE 11或Java SE 8。
如果你使用Maven,这里有坐标:
<dependency>
<groupId>io.openliberty.beta</groupId>
<artifactId>openliberty-runtime</artifactId>
<version>22.0.0.4-beta</version>
<type>pom</type>
</dependency>
或者对于Gradle:
dependencies {
libertyRuntime group: 'io.openliberty.beta', name: 'openliberty-runtime', version: '[22.0.0.4-beta,)'
}
或者看一下我们的下载页面。