You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -26,20 +26,20 @@ If the token is missing or invalid, the request is rejected.
26
26
27
27
## Auto protection
28
28
29
-
In Plone, CSRF protection is done almost transparently by [plone.protect](https://pypi.org/project/plone.protect/).
29
+
In Plone, CSRF protection is done almost transparently by [`plone.protect`](https://pypi.org/project/plone.protect/).
30
30
One important aspect of `plone.protect` is that it performs the CSRF token validation at the database transaction commit time (at the end of the request), rather than at the beginning of the request.
31
31
This means that the view can execute and make changes to the database, but the changes will not be persisted unless a valid CSRF token is present in the request.
32
32
33
-
When a logged-in user requests a page, Plone automatically includes the CSRF token in all forms by applying a transform (using `plone.transformchain`) that adds a hidden field with the token.
33
+
When a logged-in user requests a page, Plone automatically includes the CSRF token in all forms by applying a transform (using `plone.transformchain`) that adds a hidden input with its value set to the token.
34
34
This includes, but is not limited to the following:
35
35
36
36
- add and edit forms
37
-
- control-panels
38
-
- custom z3c-forms
37
+
- controlpanels
38
+
- custom z3cforms
39
39
40
40
## Manual protection
41
41
42
-
To ensure that code that is not part of a database transaction, such as code that writes to an external API or a service that is not automatically included in the transaction mechanism, is protected, you will need to manually implement protection for that code.
42
+
To ensure that code that is not part of a database transaction—such as code that writes to an external API or a service that is not automatically included in the transaction mechanism—is protected, you will need to manually implement protection for that code.
43
43
44
44
`plone.protect` offers the `@protect` decorator.
45
45
The decorator expects a callable to perform the check.
@@ -63,7 +63,7 @@ Usage example:
63
63
64
64
### HTTP POST check with `PostOnly`
65
65
66
-
Checks whether the request is an HTTP POST and raise`Unauthorized` if not.
66
+
Checks whether the request is an HTTP POST request, and raises`Unauthorized` if not.
To allow certain objects to be modified and written to the database without protection, follow these steps:
145
145
146
146
1. Identify the modified object as a single object in the database.
147
-
2. If an attribute of the object is a "persistent" attribute (e.g., a PersistentDict or PersistentList instance, a BTree, or an annotation), use this instead.
147
+
2. If an attribute of the object is a "persistent" attribute (for example, a `PersistentDict` or `PersistentList` instance, a `BTree`, or an `annotation`), use this instead.
148
148
3. Use the `safeWrite` function to mark the object as safe for writing.
149
149
150
-
Note: This is the preferred method for allowing modification and writing of specific objects to the database.
150
+
```{note}
151
+
This is the preferred method for allowing modification and writing of specific objects to the database.
0 commit comments