简体   繁体   English

Websphere 9,如何检查传入的 ltpatoken2

[英]Websphere 9, how to check incoming ltpatoken2

Good day I have an incoming request to my application based on websphere 9 with ltpatoken2 cookie.美好的一天,我有一个基于 websphere 9 和 ltpatoken2 cookie 的应用程序的传入请求。 Previously, the ltpa key was exported from my websphere and add to another server.以前,ltpa 密钥是从我的 websphere 导出并添加到另一台服务器的。 The option Application security was enabled.选项应用程序安全已启用。 How I can check, at websphere or at my application, that the token is exists and correct?如何在 websphere 或我的应用程序中检查令牌是否存在且正确? And my application should be not avialable for requests without token.对于没有令牌的请求,我的应用程序不应该可用。

There's no API to inspect that token, but you can test it implicitly.没有 API 可以检查该令牌,但您可以隐式测试它。 You can capture browser traffic with Firefox or Chrome developer tools, then after successful login, using either the browser tools or curl, send a modified request without the cookie, or with a bad cookie value, and you should get an authentication challenge since the cookie's not there.您可以使用 Firefox 或 Chrome 开发人员工具捕获浏览器流量,然后在成功登录后,使用浏览器工具或 curl,发送修改后的请求而无需 cookie,或使用错误的 cookie 值,并且您应该收到身份验证质询,因为 cookie 的不在那里。

In WebSphere 9, if request contains a LTPA cookie, LTPA cookie will be processed automatically.在 WebSphere 9 中,如果请求包含 LTPA cookie,LTPA cookie 将被自动处理。 Inside your application code, if you call API com.ibm.websphere.security.auth.WSSubject.getRunAsSubject() , you will see a subject created form the ltpa token if LTPA token is presented and is also valid.在您的应用程序代码中,如果您调用 API com.ibm.websphere.security.auth.WSSubject.getRunAsSubject() ,您将看到一个从 ltpa 令牌创建的主题(如果 LTPA 令牌存在并且也是有效的)。

And you will see unauthenticated subject if ltpa is missing or invalid.如果 ltpa 丢失或无效,您将看到未经身份验证的主题。 Or inside your application, if you call HttpServletRequest.getPrincipal().getName() , you will see a user name represented by the LTPA cookie if it presents and valid, and you will see principal name or see unauthenticated user name if LTPA is missing or invalid.或者在您的应用程序中,如果您调用HttpServletRequest.getPrincipal().getName() ,您将看到一个由 LTPA cookie 表示的用户名(如果它存在且有效),并且如果缺少 LTPA,您将看到主体名称或未验证的用户名或无效。

The easiest would be to just add security constraints to your web.xml protecting whole application (you will find many examples), and map security role to All authenticated .最简单的方法是将安全约束添加到您的web.xml保护整个应用程序(您会发现很多示例),并将 map 安全角色添加到All authenticated Then your application will be available only, if user is already logged in (so the LTPA token exists and is correct), otherwise it will redirect you to login page that you can include in your application and redirect user somewhere, informed that he is not logged in, or whatever you want to do in case there is no valid LTPA token.那么您的应用程序将仅在用户已经登录时才可用(因此 LTPA 令牌存在并且是正确的),否则它会将您重定向到您可以包含在您的应用程序中的登录页面并将用户重定向到某处,通知他没有登录,或在没有有效 LTPA 令牌的情况下执行任何操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM