Skip to content

Commit c35d3e9

Browse files
committed
Added info on dealing with common errors when adding @csrf tokens.
1 parent 6561996 commit c35d3e9

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

doc/upgrading.txt

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,17 @@ rejected. (Note the user's form keeps all the data they
8686
entered if it was rejected.)
8787

8888
Also the admin can include unique csrf tokens for all forms
89-
submitted via post (delete and put methods are also
90-
included, but not currently used by roundup)). The csrf
89+
submitted using the POST method. (Delete and put methods are also
90+
included, but not currently used by roundup.) The csrf
9191
token (nonce) is tied to the user's session. When the user
9292
submits the form and nonce, the nonce is checked to make
9393
sure it was issued to the user and the same session. If this
9494
is not true the post is rejected and the user is notified.
9595

96-
The standard context/submit templating item creates CSRF
97-
tokens by default. If you have forms that are not using the
98-
standard submit routine, you should add the following field
99-
to all forms:
96+
The standard context/submit templating item creates CSRF tokens by
97+
default. If you have forms using the POST method that are not using
98+
the standard submit routine, you should add the following field to all
99+
forms:
100100

101101
<input name="@csrf" type="hidden"
102102
tal:attributes="value python:utils.anti_csrf_nonce()">
@@ -135,6 +135,19 @@ It is suggested that you change your templates so every form
135135
has an @csrf field and change the setting to 'required' for
136136
the csrf_enforce_token.
137137

138+
If you see the @csrf nonce in the URL, you have added the value to a
139+
form that uses the GET method. You should remove the @csrf token from
140+
these forms as it is not needed.
141+
142+
If you get an error:
143+
144+
AttributeError: 'list' object has no attribute 'value'
145+
146+
in handle_csrf, you have more than one @csrf token for the form. This
147+
usually occurs because the form uses the standard context/submit
148+
element but you also added an explicit @csrf statement. Simply remove
149+
the @csrf element for that form.
150+
138151
Support for SameSite cookie option for session cookie
139152
-----------------------------------------------------
140153

0 commit comments

Comments
 (0)