创建具有特定会话 ID 的会话
谢谢你们看我的帖子。
由于许可问题中的灰色地带,我运行了两个 tomcat 实例。我正在使用 Apache 代理在两者之间进行无缝通信。
App1 位于 tomcatA 中。 App2 位于 tomcatB 中。
两者都需要用户身份验证并使用会话来存储数据。 App1 是唯一对外界可见的,所有进入 App2 的请求都是由 App1 的 JavaScript 生成的。不幸的是,App1 有一个会话并将该特定的 JSESSIONID 发送到来自 App2 的所有请求。由于 App2 中不存在具有该特定 id 的会话,因此它会返回错误。
有没有办法让我用特定的 id 初始化会话? 有没有办法让我修改所有请求,以便将有效的会话 ID 放入标头中。
编辑:我需要 App2 认识到来自 App1 的请求具有特定的会话 ID 映射到 App2 创建的会话。
thank you you guys for looking at my post.
Due to grey areas in licensing issues, I have two instances of tomcat running. I'm using Apache proxy to seamlessly communicate between the two.
App1 lives in tomcatA.
App2 lives in tomcatB.
Both requires user authentication and uses sessions for storing data. App1 is the only one visible to outside world and all the requests that comes in to App2 are generated by JavaScripts from App1. Unfortunately, App1 has a session and sends that specific JSESSIONID to all the requests from App2. Since there isn't a session with that specific id in App2, it returns with errors.
Is there a way for me to initialize a session with specific id?
Is there a way for me to modify all the requests so that it puts the valid session id into the headers.
Edit: I need App2 to realize that requests coming through, from App1, with a particular session id maps to a session that App2 created.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以为您的 tomcatB 使用不同的会话 cookie 名称(或路径,如果可能)。因此,tomcatB 会将 JSESSIONID cookie 视为任何其他 cookie,而不是会话 cookie。
请参阅 http://tomcat.apache.org/tomcat-7.0-doc/ config/context.html。
You could just use a different session cookie name (or path, if possible) for your tomcatB. tomcatB would thus consider the JSESSIONID cookie as any other cookie, and not as a session cookie.
See http://tomcat.apache.org/tomcat-7.0-doc/config/context.html.
即使两个应用程序都位于同一个 Tomcat 中,会话也会不同,因为它们是基于每个应用程序发出的。就我个人而言,我并不完全相信这个设计。
如果您的问题是如何将身份验证传播到另一个应用程序,请使用单点登录应用程序,例如 Josso 或 CAS;要共享会话数据,您可以使用可从两个应用程序访问并通过 JSON 访问的集中式缓存。
是的,会话数据很糟糕。
更新:您不能简单地实现一个握手协议,例如:app2/register/{app1 session id} - 此时您都持有两个会话 ID,并且可以相互关联。这也可以通过会话侦听器来完成。
Even if both application lived in the same Tomcat, sessions would be different as they are issued on a per-app basis. Personally, I am not entirely convinced by this design.
If your question is how to propagate authentication to another app, use a single sign-on application like Josso or a CAS; to share session data, you can use a centralized cache accessible from both applications and accessible through JSON.
And yes, session data is bad.
Update: can't you simply implement a handshake protocol like: app2/register/{app1 session id} - at this point you both hold both session ID's and you can correlate each other. This can be done also with a session listener.