Forbidden (403)

CSRF verification failed. Request aborted.

You are seeing this message because this site requires a CSRF cookie when submitting forms. This cookie is required for security reasons, to ensure that your browser is not being hijacked by third parties.

If you have configured your browser to disable cookies, please re-enable them, at least for this site, or for 'same-origin' requests.

Help

Reason given for failure:

    CSRF cookie not set.
    

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 passes a request to the template's render method.
  • 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.
  • The form has a valid CSRF token. After logging in in another browser tab or hitting the back button after a login, you may need to reload the page with the form, because the token is rotated after a login.

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.

处理http请求头

微信小程序代码

wx.request({
url: getApp().globalData.apiUrlApp + 'test/getinfo/',
header: {
"Content-Type": "application/x-www-form-urlencoded",
'cookie': wx.getStorageSync("username"), //读取cookie,
'cookie': wx.getStorageSync("uid"), //读取cookie,
'cookie': wx.getStorageSync("gid") //读取cookie, },
method: "GET",
data: {
// uid: wx.getStorageSync("uid")
},
success: function(res) {
console.log(res)
if (res.data.status == 1) {
wx.showToast({
// title: res.data.info,
title: "帐号详情",
icon: 'success',
duration: 1500
}),
that.setData({
companyinfo: res.data.data
})
} else if (res.data.status == 0) {
wx.showToast({
title: "无数据返回",
icon: 'success',
duration: 1500
})
} else if (res.data.status == -1) {
wx.showToast({
title: "请求异常,请检查重试",
icon: 'loading',
duration: 2000
})
}
}
})

  

Django's CSRF mechanism的更多相关文章

  1. Django 的 CSRF 保护机制

    转自:http://www.cnblogs.com/lins05/archive/2012/12/02/2797996.html 用 django 有多久,我跟 csrf 这个概念打交道就有久了. 每 ...

  2. Django 的 CSRF 保护机制(转)

    add by zhj:假设用户登录了网站A,而在网站B中有一个CSRF攻击标签,点击这个标签就会访问网站A,如果前端数据(包括sessionid)都放在本地存储的话, 当在网站B点击CSRF攻击标签时 ...

  3. Python自动化之Django的CSRF

    什么CSRF? CSRF, Cross Site Request Forgery, 跨站点伪造请求.举例来讲,某个恶意的网站上有一个指向你的网站的链接,如果 某个用户已经登录到你的网站上了,那么当这个 ...

  4. Django之CSRF 跨站请求伪造

    一.简介 1.点我了解什么是跨站请求伪造 2.django为用户实现防止跨站请求伪造的功能,通过中间件 django.middleware.csrf.CsrfViewMiddleware 来完成.而对 ...

  5. 详解Django的CSRF认证

    1.csrf原理 csrf要求发送post,put或delete请求的时候,是先以get方式发送请求,服务端响应时会分配一个随机字符串给客户端,客户端第二次发送post,put或delete请求时携带 ...

  6. Django之csrf防御机制

    1.csrf攻击过程 csrf攻击说明: 1.用户C打开浏览器,访问受信任网站A,输入用户名和密码请求登录网站A; 2.在用户信息通过验证后,网站A产生Cookie信息并返回给浏览器,此时用户登录网站 ...

  7. django之CSRF

    在POST请求到达views之前,csrf帮我们进行一层验证 <!DOCTYPE html> <html lang="en"> <head> & ...

  8. 关于Django Ajax CSRF 认证

    CSRF(Cross-site request forgery跨站请求伪造,也被称为“one click attack”或者session riding,通常缩写为CSRF或者XSRF,是一种对网站的 ...

  9. python框架之Django(9)-CSRF

    准备 现有如下模板和视图: <!DOCTYPE html> <html lang="en"> <head> <meta charset=& ...

随机推荐

  1. 条款32:确定你的public继承塑模出is-a 关系(Make sure public inheritacne models "is-a")

    NOTE : 1."public继承"意味is-a.适用于base classes  身上的每一件事一定也适用于derived classes身上,因为每一个derived cla ...

  2. Django 动态建表

    #!/usr/bin/env python # -*- coding:utf-8 -*- # Author:Random_lee # -*- coding: utf-8 -*- from django ...

  3. 剑指Offer(书):重建二叉树

    题目:输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树.假设输入的前序遍历和中序遍历的结果中都不含重复的数字.例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2, ...

  4. 【HIHOCODER 1478】 水陆距离(BFS)

    描述 给定一个N x M的01矩阵,其中1表示陆地,0表示水域.对于每一个位置,求出它距离最近的水域的距离是多少. 矩阵中每个位置与它上下左右相邻的格子距离为1. 输入 第一行包含两个整数,N和M. ...

  5. jmeter-如何进行参数化-循环读取参数

    在进行测试的时候,测试数据是一项重要的准备工作,每次迭代的数据当不一样的时候,需要进行参数化,从参数化的文件中来读取测试数据. 本经验主要介绍的是用Csv Data配置元件来进行参数化. 方法/步骤 ...

  6. linux进程按启动时间排序命令

    show me the code... ps aux --sort=start_time|grep Full|grep -v grep

  7. CodeForce 448C 木片填涂问题

    题目大意:有多片木片需要填涂,可以每次横着涂一行,也可以一次涂一列,当然你涂一行时遇到中间长度不够高的木片,填涂到此中断 这题目运用dfs能更容易的解出,虽然还是十分不容易理解 #include &l ...

  8. POJ 3090 坐标系上的视线遮蔽问题

    Description A lattice point (x, y) in the first quadrant (x and y are integers greater than or equal ...

  9. 汕头市赛srm1X T3

    给n<=100000个点的树,每个点有一个01串,长度m<=200,串的可以随时01取反,串的每一位对应权Vi,从根节点到某个节点经过决定哪些串取反后取得的最大价值为某个点的权值,求:在这 ...

  10. msp430项目编程23

    msp430中项目---风扇控制系统 1.比较器工作原理 2.电路原理说明 3.代码(显示部分) 4.代码(功能实现) 5.项目总结 msp430项目编程 msp430入门学习