-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for custom CSRF cookie names #4049
Conversation
@@ -230,6 +230,9 @@ <h4 class="modal-title" id="myModalLabel">{{ error_title }}</h4> | |||
{% if filter_form %}{{ filter_form }}{% endif %} | |||
|
|||
{% block script %} | |||
<script> | |||
var csrf_cookie_name = "{{ csrf_cookie_name|default:'csrftoken' }}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we instead do something like:
window.drf = {
csrfCookieName: "{{ csrf_cookie_name|default:'csrftoken' }}"
};
and use window.drf.csrfCookieName
in csrf.js
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
Good stuff @clintonb, just left one small comment. |
This reminds me, I should probably do some house cleaning of our client side stuff. |
Instead of hardcoding the CSRF cookie name, the value is passed to the template as a context variable, rendered as a JavaScript variable, and read by csrf.js. Fixes #4048
@jpadilla I addressed your comment. Let me know if any other changes are necessary to merge. |
@clintonb thanks! |
Instead of hardcoding the CSRF cookie name, the value is passed to the template as a context variable, rendered as a JavaScript variable, and read by csrf.js.
refs #4048