0

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

现在我们正在切换到经过 openidconnect 身份验证的无会话(使用 JWT)安全 Web 应用程序。

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

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

我想:

  1. 完全忽略请求中碰巧出现的任何 LtpaToken cookie(是的,完全忽略,就好像它从不存在,有效或无效,或过期或其他任何情况,我们的新应用程序永远不会关心旧的 SSO 方案);
  2. 一旦带有有效 JWT 令牌的第一个请求进入,就永远不会生成 LtpaToken。

编辑

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

我设法创建了一个MWE,包括(实际上如此之少,您只需要 server.xml 和任何 index.html):

(服务器.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”标头(是的,事件不需要值)肯定地重现第一点(以 401 拒绝):

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

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

响应头是:

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].`
...

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

4

1 回答 1

0

找到了解决方法:

<server>
  ...
  <webAppSecurity ssoCookieName="" useOnlyCustomCookieName="true"/>
  ...
</server>
于 2020-07-03T18:46:10.960 回答