- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我们必须发送{% csrf_token %}
时,django中的csrftoken
-cookie有什么用在每个表单提交中。
<form method="post" action="actionFile/">
{% csrf_token %}
<button>Submit</button>
</form>
Django 处理器总是要求 {% csrf_token %}
我们是否必须在每个表单中放入{% csrf_token %}
,django处理器不能利用csrftoken
-cookie
{% csrf_token %}
可能需要防止伪造,但是 cookie 有什么用
请澄清.,.,
最佳答案
Cross-site request forgery, also known as a one-click attack or session riding and
abbreviated as CSRF or XSRF, is a type of malicious exploit of a website whereby
unauthorized commands are transmitted from a user that the website trusts.Unlike cross-
site scripting (XSS), which exploits the trust a user has for a particular site, CSRF
exploits the trust that a site has in a user's browser.
使用 secret cookie
Remember that all cookies, even the secret ones, will be submitted with every request.
All authentication tokens will be submitted regardless of whether or not the end-user
was tricked into submitting the request. Furthermore, session identifiers are simply
used by the application container to associate the request with a specific session
object. The session identifier does not verify that the end-user intended to submit
the request.
仅接受 POST 请求
Applications can be developed to only accept POST requests for the execution of business
logic. The misconception is that since the attacker cannot construct a malicious link,
a CSRF attack cannot be executed. Unfortunately, this logic is incorrect. There are
numerous methods in which an attacker can trick a victim into submitting a forged POST
request, such as a simple form hosted in attacker's website with hidden values. This
form can be triggered automatically by JavaScript or can be triggered by the victim who
thinks form will do something else.
每次请求服务器时,Django 都会设置 csrftoken cookie,并且当您将数据从客户端发布到服务器时,此 token 与该 token 匹配,如果不匹配任何问题,如果不匹配,则会抛出错误,这是恶意请求。
如果您可以使用 csrf_exempt 装饰器来禁用特定 View 的 CSRF 保护。
from django.views.decorators.csrf import csrf_exempt
然后在 View 前写入@csrf_exempt
关于python - django 中需要 csrftoken cookie 和 csrf_token INPUT 类型吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23946883/
我试图找到以下问题的答案。 什么情况下浏览器会存储多个csrftoken cookies ? 它是正确的还是技术上有效的功能? 以及在 RFC/security 文档中传递数组的位置,或尝试 csrf
有没有办法直接在View中获取csrftoken? 我想获取当前的 csrftoken,但有时会发生变化,因此从 Cookies 获取它不是一个好主意。 有什么办法吗? 谢谢! 最佳答案 我相信您正在
我使用 ajax 调用对 CRUD(使用 csrf token )的薄美味层。一切都像魅力一样,直到我运行该网站,例如Chrome 隐身模式。我不断收到 CUD 请求的 401。 查看请求 cooki
我正在测试发出 POST ajax 请求,但由于没有 csrftoken,我收到了 403。我跟着文档,但是,它仍然不起作用,我发现名为 csrftoken 的 cookie 是 空 , 意思是 $.
我在我的 SPA 中遇到了 Django CSRF token 的奇怪问题。 当我呈现我的应用程序时,我确保使用 ensure_csrf_cookie 设置 token 。当我检查我的 cookie
我有一个带有表单元素的 django 模板,其中包括一些输入文本编辑和一个提交按钮以及一个带有 DropzoneJS 的用户头像 uploader 。问题是我无法将 DropzonJs 放入表单的 d
试图了解安全性。好奇为什么在Django何时 提交表单(POST)时,有2个单独的“元素” 包含相同的csrf token 值: - the csrftoken cookie: COOKIE
我正在与 Django 合作创建一个网站,并遇到了一些关于 CSRF 的问题。我用 django.middleware.csrf.CsrfViewMiddleware并添加 {% csrf_token
csrftoken 存储在哪里? 当我访问 API 端点时(注销 API,它不需要参数): POST /rest-auth/logout/ HTTP/1.1 Host: 10.10.10.105:80
如何通过 python 模块 Requests 传递 csrftoken?这就是我所拥有的,但它不起作用,我不确定将它传递给哪个参数(数据、 header 、身份验证...) import reque
在我的 Django 的 settings.py 中,我有 SESSION_COOKIE_HTTPONLY = True SECURE_CONTENT_TYPE_NOSNIFF = True SECU
我有这样的python代码 s=requests.Session() headers = {'User-Agent': 'Mozilla/5.0'} URL = 'http://test.dev/ap
我开发了一个 Django 文件上传 API,它从客户端接收发布的数据并将数据保存为文件。 根据Django CSRF manual ,HTTP 请求 header 应使用 csrftoken coo
我需要通过基于 Ajax 的发布请求传递 CSRFToken,但不确定如何以最佳方式完成。使用在请求中内部检查 CSRFToken 的平台(仅限 POST 请求) 最初我想把它添加到标题中 $(fun
在Vue.js项目中,如何获取csrftoken? 我试过使用js-cookie,但无法获取: import Cookies from 'js-cookie'; if (Cookies.get('cs
我使用 Django rest 框架作为我的后端 (api),并使用 React 作为前端。 现在我想将表单数据 POST 到后端。我想用csrf保护,因为安全。因此,我尝试使用 Django 发送的
我的问题是,上传文件时显示以下错误。我该如何解决这个问题? 这是我在模板中的代码:
使用: Django 3.x [Django-Filters 2.2.0、graphene-django 2.8.0、graphql-relay 2.0.1] Vue 2.x [Vue-Apollo]
当我们必须发送{% csrf_token %}时,django中的csrftoken-cookie有什么用在每个表单提交中。 {% csrf_token %} Submit Django 处理器总
如何在 Axios.interceptors.request 的配置中获取 Cookies 的 csrftoken? Axios.interceptors.request.use( config
我是一名优秀的程序员,十分优秀!