我的组织已经有一些web应用程序部署在一个自由服务器上,使用它的SSO,它为整个intranet域设置了一个LtpaToken cookie。
现在,我们切换到经过身份验证、无会话(使用JWT)安全的web应用程序。
身份验证很好--只涉及浏览器--授权也很好(功能为mpJwt-1.1)。
但是,当用户来自另一个web应用程序(在同一会话内)时,浏览器发送LtpaToken2 cookie,并使用401 (未经授权)拒绝请求。
我想:
编辑
上面的第二点并没有真正发生(要明确的是,这个新的自由服务器并不生成LtpaToken)。
我已经成功地创建了一个米维,它包括(实际上非常少,您只需要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-<mpJwt/>"
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。
发布于 2020-07-03 18:46:10
找到了一个解决办法:
<server>
...
<webAppSecurity ssoCookieName="" useOnlyCustomCookieName="true"/>
...
</server>https://stackoverflow.com/questions/62610786
复制相似问题