Skip to content

Commit

Permalink
Merge pull request #3157 from Uninett/fix-csrf-token-rendering-in-for…
Browse files Browse the repository at this point in the history
…m-template

Always render hidden CSRF token input in reusable non-crispy templates
  • Loading branch information
podliashanyk authored Nov 7, 2024
2 parents c3c1ff7 + 713ce0f commit ca3d09f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/3157.security.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure that CSRF token info is included when reusing NAV's form templates. This means that flat_form.html and _form_content.html templates will always include a hidden CSRF token input regardless of which form method is set.
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{# NB! This template can be used directly (without form template wrapper) for cases where form.helper.form_tag is set to False. #}
{% load forms %}

{% if form.attrs.method|lower == 'post' %}
{% csrf_token %}
{% endif %}
{% csrf_token %}

{% include 'foundation-5/errors.html' %}

Expand Down

0 comments on commit ca3d09f

Please sign in to comment.