#30282: CSRF token invalid after DELETE request
-------------------------------------+-------------------------------------
Reporter: my-tien | Owner: nobody
Type: Bug | Status: new
Component: CSRF | Version: 2.1
Severity: Normal | Keywords: CSRF RESTful-API
Triage Stage: | DELETE
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I am using a RESTful API in my django server with CSRF Middleware enabled.
When I only use GET and POST requests, all works as expected. But when I
send a DELETE request to a resource and afterwards perform a POST request
– that contains a csrf cookie and csrfmiddlewaretoken in body – the latter
is rejected with `CSRF token missing or incorrect` and I have to login
again.
DELETE request Headers:
- REQUEST_METHOD: DELETE
- CONTENT_TYPE: "application/x-www-form-urlencoded"
- HTTP_COOKIE: sessionid=[session id], csrftoken=[csrfcookie]
- HTTP_X_CSRFTOKEN: [csrfcookie] (I also don’t understand why DELETE needs
this extra header with the same content as the csrftoken…)
- HTTP_REFERER: [url]
DELETE request Body: csrfmiddlewaretoken: [csrfcookie]
--
Ticket URL: <https://code.djangoproject.com/ticket/30282>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.b5590541df3b9a9fed1d52cc4e29209b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.