Tomcat 能否为 HTTPS 请求提供单独的(或仅 HTTPS)会话?
我有一个 Web 应用程序,其中包含安全 (SSL) 页面和非安全页面。
用户可以登录该站点,并且必须在 SSL 和非 SSL 区域中显示为已登录。
(注意。SSL 不是通过 Tomcat 实现的,而是通过位于 Tomcat 前面的 Apache HTTPD 服务器实现的 - 因此 Tomcat 没有 SSL 配置。)
登录状态当前通过 servlet 会话维护(使用 Tomcat 的普通会话管理) 。
这种方法的明显问题是 JSESSIONID cookie 通过 HTTP 和 HTTPS 连接传输,这意味着有可能拦截它并劫持会话。
是否有任何解决方案,无需滚动我们自己的会话管理(即 Tomcat 是否可以满足这种情况)?
我准备实现我们自己的会话管理,但不想重新发明可能已经支持的东西。
I have a web application which contains both secure (SSL) and non-secure pages.
A user can login to the site and must appear logged-in in both the SSL and non-SSL areas.
(NB. SSL isn't implemented via Tomcat, but via Apache HTTPD servers which sit in front of Tomcat - so Tomcat has no SSL configuration.)
The logged-in state is currently maintained via a servlet session (using Tomcat's vanilla session management).
The obvious issue with this approach is that the JSESSIONID cookie is transported over both HTTP and HTTPS connections, meaning that it's potentially possible to intercept it and hijack the session.
Are there any solutions to this without rolling our own session management (i.e. does Tomcat cater for this situation)?
I'm prepared to implement our own session management, but don't want to reinvent something that may already be supported.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你说SSL是在Apache服务器上实现的,并没有传递给Tomcat,所以Tomcat将整个旅程视为HTTP?如果是这样,Tomcat 将不会创建单独的 JSESSIONID,因为它不知道 HTTPS。
您可以检查 request.getUserPrincipal() 以查看用户是否已登录。
You say the SSL is implemented on the Apache server and not passed down to Tomcat, so Tomcat treats the whole journey as HTTP? If so, Tomcat will not create separate JSESSIONIDs since it is not aware of the HTTPS.
You can check the request.getUserPrincipal() to see if user is logged-in.