Closed jkosir closed 9 years ago
sounds good - but where do we get the secret from? Or did I miss something here?
Thats's why I added the templatetag {% csrf_value %}
.
See also http://django-angular.readthedocs.org/en/latest/csrf-protection.html#set-header-with-x-csrftoken-via-templatetag
Angular reads the cookie value automatically with these settings, no need to set headers manually.
The {% csrf_value %}
approach is a bit safer, so I guess we could keep that and only change the ngCookies
part.
The docs suggest manually setting the
X-CSRFToken
header on post requests:This only works for
POST
(and not delete/put) and requiresngCookies
. Angular already has xsrf support, but it uses different names for cookie and headers,XSRF-TOKEN
andX-XSRF-TOKEN
. Both can be easily changed to what django uses:This is enough for angular app to work with django's csrf protection (also works for post/put/delete) and doesn't have the
ngCookies
dependency, so I suggest we update the docs to this.