无法使用 Firefox 从 Tomcat 注销
我在使用 Tomcat 和 CAS 授权时遇到了非常意外的问题。我只是无法在 Firefox 中注销。我被重定向到注销页面,但是一旦我在地址栏中重新输入应用程序 URL,它就会打开,就像我已登录一样(而且我实际上已登录!)。
首先,我进行了大量尝试来修复 tomcat 配置中的某些内容,然后我阅读了日志,但在我想到检查其他浏览器中的注销行为之前,没有任何帮助。
在其他浏览器中,一切都按预期工作。 我只是被困住了,如果有人能给我一个提示,我将不胜感激。
我想[这个问题][1]在某种程度上与我的问题相关,但是,helas,在应该我注销的页面上禁用缓存也没有帮助。
UPD:一些调试信息。 Firefox的版本是7.0.1,不幸的是,它不是公共应用程序,我无法提供任何网址。看起来 Firefox 缺少 response.sendRedirect 输出。以下是可在除 Firefox 之外的任何浏览器中运行的最小代码。
session.invalidate();
response.sendRedirect("https://app:8552/cas/logout");
标题 第一个请求 - 使会话无效并重定向到 CAS 注销页面
请求标头
- 主机:dev.service.net
- 用户代理:Mozilla/5.0(Macintosh;Intel Mac OS X 10.6;rv:7.0.1)Gecko/20100101 Firefox/7.0。 1
- 接受: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
- 接受语言: en-us,en;q=0.5
- 接受编码: gzip, deflate
- 接受字符集:ISO-8859-1,utf-8;q=0.7,*;q=0.7
- 连接:保持活动
- 引用:http://dev.service.net/
- Cookie:JSESSIONID=53B9469EFE9F130E9694F7406BFAB755
响应标头
- 服务器:nginx/1.0.4
- 日期:2011 年 10 月 20 日星期四 09:20:45 GMT
- 内容类型:text/html
- 内容长度:184
- 位置:https://dev:8552/cas/logout
第二个请求 - cas 注销页面本身
请求标头
- 主机:dev:8552
- 用户代理:Mozilla/5.0(Macintosh;Intel Mac OS X 10.6;rv:7.0.1)Gecko/20100101 Firefox/7.0.1
- 接受:text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
- 接受语言:en-us,en;q=0.5
- 接受编码: gzip, deflate
- 接受字符集: ISO-8859-1,utf-8;q=0.7,*;q=0.7
- 连接: keep-alive
- Referer: http://dev.service.net/
- Cookie:JSESSIONID=8A68F008825A0F0D14C6BF803E1332CF; GUEST_LANGUAGE_ID=en_US; COOKIE_SUPPORT=true
响应标头
- 服务器:Apache-Coyote/1.1
- 编译指示:无缓存
- 过期时间:1970 年 1 月 1 日星期四 00:00:00 GMT
- 缓存控制:无缓存、无存储
- 内容类型:text/html;charset =UTF-8
- 内容语言:en-US
- 内容长度:1226
- 日期:10 月 20 日星期四2011 15:53:57 GMT
第三个请求 - 我们正在重新调整到实际应该的页面 将我们重定向到登录页面,但事实并非如此。
请求标头
- 主机:dev.service.net
- 用户代理:Mozilla/5.0(Macintosh;Intel Mac OS X 10.6;rv:7.0.1) Gecko/20100101 Firefox/7.0.1
- 接受:text/html,application/xhtml+xml ,application/xml;q=0.9,/;q=0.8
- 接受语言: en-us,en;q=0.5
- 接受编码:gzip、deflate
- 接受字符集:ISO-8859-1,utf-8;q=0.7,*;q=0.7
- 连接:保持活动
- Cookie:JSESSIONID=53B9469EFE9F130E9694F7406BFAB755
响应标头
- 服务器:Apache-Coyote/1.1
- Pragma:无缓存
- 过期:Thu, 01 Jan 1970 00:00:00 GMT
- 缓存控制:无缓存、无存储
- 内容类型:text/html;charset=UTF-8
- :en-US 内容
- 内容语言 -长度:1226
- 日期:2011 年 10 月 20 日星期四 13:30:51 GMT
I've encountered quite unexpected problem using Tomcat and CAS authorization. I just cannot logout in Firefox. I'm redirected to the logout page, but as soon as I reenter application url in the address bar, it is opened as if I'm logged (and I'm logged actually!).
First I've take a notable amount of attempts to fix something in tomcat config, then I've read logs, but nothing helped me actually before it comes up to my mind to check logout behavior in other browsers.
In other browsers everything work just as expected.
And I'm just stuck and would appreciate if one will give me a hint.
I guess [this question][1] is in some way relative with mine, but, helas, disabling caching on the page which should me logouted doesn't help either.
UPD: Some debug information. Firefox's version is 7.0.1, unfortunately, it is not a public application and I can not provide any url. It looks like response.sendRedirect output is something that Firefox is missing. Here is minimal code that works in any browser except Firefox.
session.invalidate();
response.sendRedirect("https://app:8552/cas/logout");
HEADERS
1st REQUEST - which invalidates session and redirect to CAS logout page
REQUEST HEADERS
- Host: dev.service.net
- User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20100101 Firefox/7.0.1
- Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
- Accept-Language: en-us,en;q=0.5
- Accept-Encoding: gzip, deflate
- Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
- Connection: keep-alive
- Referer: http://dev.service.net/
- Cookie: JSESSIONID=53B9469EFE9F130E9694F7406BFAB755
RESPONSE HEADERS
- Server: nginx/1.0.4
- Date: Thu, 20 Oct 2011 09:20:45 GMT
- Content-Type: text/html
- Content-Length: 184
- Location: https://dev:8552/cas/logout
2nd REQUEST - cas logout page itself
REQUEST HEADERS
- Host: dev:8552
- User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20100101 Firefox/7.0.1
- Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
- Accept-Language: en-us,en;q=0.5
- Accept-Encoding: gzip, deflate
- Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
- Connection: keep-alive
- Referer: http://dev.service.net/
- Cookie: JSESSIONID=8A68F008825A0F0D14C6BF803E1332CF; GUEST_LANGUAGE_ID=en_US; COOKIE_SUPPORT=true
RESPONSE HEADERS
- Server: Apache-Coyote/1.1
- Pragma: no-cache
- Expires: Thu, 01 Jan 1970 00:00:00 GMT
- Cache-Control: no-cache, no-store
- Content-Type: text/html;charset=UTF-8
- Content-Language: en-US
- Content-Length: 1226
- Date: Thu, 20 Oct 2011 15:53:57 GMT
3rd REQUEST - we are retuninig to the page which actually should
redirect us to login page, but it does not.
REQUEST HEADERS
- Host: dev.service.net
- User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20100101 Firefox/7.0.1
- Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
- Accept-Language: en-us,en;q=0.5
- Accept-Encoding: gzip, deflate
- Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
- Connection: keep-alive
- Cookie: JSESSIONID=53B9469EFE9F130E9694F7406BFAB755
RESPONSE HEADERS
- Server: Apache-Coyote/1.1
- Pragma: no-cache
- Expires: Thu, 01 Jan 1970 00:00:00 GMT
- Cache-Control: no-cache, no-store
- Content-Type: text/html;charset=UTF-8
- Content-Language: en-US
- Content-Length: 1226
- Date: Thu, 20 Oct 2011 13:30:51 GMT
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据标题,您在两个不同的主机上维护两个不同的会话。当您请求在第一台主机上注销时,您将被重定向到第二台主机(它使用不同的会话 cookie)。第二个主机的会话 cookie 确实又失效了(根据
Set-Cookie
标头的存在)。但根据最后一个请求,会话尚未在服务器端重新创建(没有Set-Cookie
标头)。这意味着response.sendRedirect()
之前的session.invalidate()
以某种方式失败,或者该页面实际上是从浏览器缓存请求的。在 Firebug 中,您应该能够通过检查 Net 选项卡中请求的文本颜色来查看该页面是否是从浏览器缓存请求的。如果它呈灰色,则意味着它是从浏览器缓存提供的。对于 Firefox,
must-revalidate
标头实际上是强制的,位于no-cache, no-store
标头旁边。您需要配置服务器以将该条目添加到标头,或者为此更改/创建一个Filter
。另请参阅:
According to the headers, you're maintaining two different sessions on two different hosts. When you request a logout on the first host, you're redirected to the second host (which uses a different session cookie). The session cookie of the second host is in turn indeed invalidated (according to the presence of the
Set-Cookie
header). But based on the last request, the session has not been recreated on the server side (there is noSet-Cookie
header). This means thatsession.invalidate()
beforeresponse.sendRedirect()
has failed somehow, or that the page is actually requested from the browser cache.In Firebug you should be able to see if the page is requested from the browser cache by checking the text color of the request in the Net tab. If it's grayed out, then it means that it's been served from the browser cache. For Firefox, the
must-revalidate
header is actually mandatory next to theno-cache, no-store
headers. You need to configure your server to add that entry to the header, or to change/create aFilter
for that.See also: