ERROR 403 以及Chrome 浏览器配置

1 问题起源

在使用OpenStack Dashboard的时候出现了403问题

Forbidden (403)
CSRF verification failed. Request aborted.
Help
Reason given for failure:
    CSRF token missing or incorrect.
    
In general, this can occur when there is a genuine Cross Site Request Forgery, or when Django's CSRF mechanism has not been used correctly. For POST forms, you need to ensure:
Your browser is accepting cookies.
The view function uses RequestContext for the template, instead of Context.
In the template, there is a {% csrf_token %} template tag inside each POST form that targets an internal URL.
If you are not using CsrfViewMiddleware, then you must use csrf_protect on any views that use the csrf_token template tag, as well as those that accept the POST data.
You're seeing the help section of this page because you have DEBUG = True in your Django settings file. Change that to False, and only the initial error message will be displayed.
You can customize this page using the CSRF_FAILURE_VIEW setting.

2. 403 问题描述

403问题在页面的"Help" 已经加以描述。一般而言,发生这种情况时,有一个真正的跨站请求伪造,或Django的CSRF的机制没有正确使用,对于POST的表单,需要保证:

  1. 视图使用模板RequestContext 的
  2. 模板中,有{%csrf_token%}
  3. 如果不使用CsrfViewMiddleware,那么必须在view中使用csrf_protect

3 解决方法

解决这个问题的方法当然有很多,代码级别的修改参考 博客

这里主要介绍下通过清楚浏览器缓存的方式来完成登录

查看chrome浏览器的缓存位置:
1. 打开chrome

2. 输入chrome:version
google Chrome 39.0.2171.99 (正式版本) m

修订版本	800fe26985bd6fd8626dd80f710fae8ac527bd6b-refs/branch-heads/2171@{#470}
操作系统	Windows 
Blink	537.36 (@186555)
JavaScript	V8 3.29.88.17
Flash	16.0.0.257
用户代理	Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36
命令行	"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --flag-switches-begin --flag-switches-end
可执行文件路径	C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
<strong>个人资料路径	C:\Users\IBM_ADMIN\AppData\Local\Google\Chrome\User Data\Default</strong>
其他变体	74785582-3f4a17df
e950616e-ca7d8d80
e9f4800b-39c30599
8afebf76-3fa88c43
19f73432-ca7d8d80
76b48ab8-a2567007
c70841c8-a2567007
15e1b27b-3f4a17df
195ce1b5-d93a0620
1d3ad72e-c6a65085
9e5c75f1-ad69ceb0
f79cb77b-3d47f4f4
ca65a9fe-91ac3782
4ea303a6-3d47f4f4
61544484-ca7d8d80
99fda808-6355c4e9
7aa46da5-ca7d8d80
9736de91-ca7d8d80
b2612322-8a9180b2
ea1014b7-dd21eb5a
244ca1ac-4ad60575
f47ae82a-746c2ad4
3ac60855-486e2a9c
f296190c-45641d72
4442aae2-7158671e
ed1d377-e1cc0f14
75f0f0a0-e1cc0f14
e2b18481-5c63917a
e7e71889-4ad60575
cbf0c14e-bf3e6cfd


3. 缓存文件保存位置 
<strong>个人资料路径	C:\Users\IBM_ADMIN\AppData\Local\Google\Chrome\User Data\Default</strong>

删除个人资料路径下的cache目录里的文件,重新登录即可。
3. 缓存文件保存位置 
<strong>个人资料路径	C:\Users\IBM_ADMIN\AppData\Local\Google\Chrome\User Data\Default</strong>

展开阅读全文

没有更多推荐了,返回首页