在 WebSphere Liberty 中忽略 LtpaToken

Ignore LtpaToken in WebSphere Liberty

我的组织已经在自由服务器上部署了一些 Web 应用程序,使用其 SSO,为整个 Intranet 域设置 LtpaToken cookie。

现在我们正在切换到经过身份验证的 openidconnect,session较少(使用 JWT)保护的 Web 应用程序。

身份验证工作正常 - 仅涉及浏览器 - 并且授权也工作正常(功能 mpJwt-1.1)。

但是当用户来自另一个 Web 应用程序(在同一个 session 中)时,浏览器发送 LtpaToken2 cookie 并且 liberty 以 401(未授权)拒绝请求。

我愿意:

  1. 完全忽略请求中碰巧出现的 LtpaToken cookie(是的,完全忽略,就好像它从未存在过一样,无论是有效的还是无效的,或者过期的等等,我们的新的应用程序永远不会关心旧的 SSO 方案);
  2. 一旦收到第一个带有有效 JWT 令牌的请求,就永远不会生成 LtpaToken。

编辑

上面的第二点并没有真正发生(要清楚,这个新的自由服务器没有生成 LtpaToken)。

我已经设法创建了一个 MWE,包括(实际上非​​常小,您只需要 server.xml 和任何 index.html):

(server.xml)

<server>

  <featureManager>
    <feature>servlet-3.1</feature>
    <feature>mpJwt-1.1</feature>
  </featureManager>

  <applicationManager autoExpand="true" />

  <webApplication location="mysample.war" contextRoot="/" />

  <httpEndpoint host="*" httpPort="9080" id="defaultHttpEndpoint"/>

  <mpJwt id="server.xml-&lt;mpJwt/&gt;"
    issuer="sso-issuer"
    keyName="sso-jwk"
  />
</server>

(index.html)

any content will do

我可以用一个简单的 'Cookie: LtpaToken2' header 肯定地重现第一点(用 401 拒绝)(是的,事件不需要值):

$ curl -v http://localhost:9080/index.html -H 'Cookie: LtpaToken2'

这个 returns 确实是 index.html 文件,但是 HTTP 状态为 401。对于 html 这很好。对于 javascript 文件,这不是(浏览器拒绝 运行 脚本)。

响应header是:

HTTP/1.1 401 Unauthorized
X-Powered-By: Servlet/3.1
WWW-Authenticate: Bearer realm="MP-JWT", error="invalid_token"
Date: Wed, 01 Jul 2020 22:18:52 GMT
Content-Type: text/html
Last-Modified: Wed, 01 Jul 2020 21:51:32 GMT
Content-Length: 11
Content-Language: en-US

服务器启动时报告:

...
[AUDIT   ] CWWKS4104A: LTPA keys created in 1.716 seconds. LTPA key file: .../target/liberty/wlp/usr/servers/mysample/resources/security/ltpa.keys
...
[AUDIT   ] CWWKF0012I: The server installed the following features: [appSecurity-2.0, cdi-1.2, distributedMap-1.0, jndi-1.0, jsonp-1.0, jwt-1.0, mpConfig-1.3, mpJwt-1.1, servlet-3.1, ssl-1.0].`
...

将请求 header“Cookie”更改为“LtpaToken2”以外的任何内容,结果完全相同index.html,但状态为 200。

找到解决方法:

<server>
  ...
  <webAppSecurity ssoCookieName="" useOnlyCustomCookieName="true"/>
  ...
</server>