Actions
Issue #7888
closedCan't update Fields through Rest API We pages (PUT requests)
Start date:
Due date:
Estimated time:
Severity:
1. Low
Version:
Master
Platform Release:
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Sprint:
Quarter:
Description
Using rest api on pulp (PUT Request), I current Get the following error raised
{ "detail": "CSRF Failed: CSRF token missing or incorrect." }
Investigation¶
-
The root cause of this issue comes from the X-CRRFToken been checked but not sent through the Ajax Call
-
Source of this check comes from the authentication scheme in place (SessionAuthentication) (cf settings.py) 'DEFAULT_AUTHENTICATION_CLASSES': [ 'rest_framework.authentication.SessionAuthentication', 'rest_framework.authentication.BasicAuthentication', ]
Actions
Define window.drf.csrfToken in api.html
This variable is expected in csrf.js to get the X-CSRFToken / csrfHeaderName to be set.
If not http PUT on form update won't work.
Fixes: #7888