Mercurial > p > roundup > code
comparison doc/admin_guide.txt @ 8575:b1024bf0d9f7
feature: add nonceless/tokenless CSRF protection
Add tokenless CSRF protection following:
https://words.filippo.io/csrf/
Must be enabled using use_tokenless_csrf_protection in config.ini. By
default it's off. If enabled the older csrf_* settings are ignored.
The allowed_api_origins setting is still used for Origin comparisons.
This should also improve performance as a nonce isn't required so
generating random nonce and saving it to the otks database is
eliminated.
doc/admin_guide.txt, doc/reference.txt doc/upgrading.txt
doc updates.
roundup/configuration.py
add use_tokenless_csrf_protection setting.
move allowed_api_origins directly after
use_tokenless_csrf_protection and before the older csrf_* settings.
It's used by both of them.
Rewrite description of allowed_api_origins as its applied to all
URLs with tokenless protection, not just API URLs.
roundup/anypy/urllib_.py
import urlsplit, it is used in new code.
urlparse() is less efficient and splits params out of the path
component.
Since Roundup doesn't require that params be split from the path. I
expect future patch will replace urlparse() with urlsplit() globally
and not need urlparse().
roundup/cgi/client.py
add handle_csrf_tokenless() and call from handle_csrf() if
use_tokenless_csrf_protection is enabled.
refactor code that expires csrf tokens when used with the wrong
methods (i.e. GET) into expire_exposed_keys(). Call same from
handle_csrf and handle_csrf_tokenless. Also improve logging if this
happens including both Referer and Origin headers if available.
Arguably we dont care about CSRF tokens exposed via
GET/HEAD/OPTIONS in the tokenless case, but this cleans them up in
case the admin has to switch back. At some future date we can
delete all the nonce based CSRF from 2018.
Update handle_csrf() docstring about calling/returning
handle_csrf_tokenless() when enabled. Call
expire_exposed_keys(method) if token is supplied with wrong method.
roundup/cgi/templating.py
disable nonce generation/save and always return "0" when
use_tokenless_csrf_protection enabled.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 19 Apr 2026 20:50:07 -0400 |
| parents | 05e21949657a |
| children |
comparison
equal
deleted
inserted
replaced
| 8574:89117bb7416d | 8575:b1024bf0d9f7 |
|---|---|
| 1677 The session and OTK (one time key) databases | 1677 The session and OTK (one time key) databases |
| 1678 store information about the operation of Roundup. | 1678 store information about the operation of Roundup. |
| 1679 This ephemeral data: | 1679 This ephemeral data: |
| 1680 | 1680 |
| 1681 * web login session keys, | 1681 * web login session keys, |
| 1682 * CSRF tokens, | 1682 * CSRF tokens (if enabled), |
| 1683 * email password recovery one time keys, | 1683 * email password recovery one time keys, |
| 1684 * rate limiting data, | 1684 * rate limiting data, |
| 1685 * ... | 1685 * ... |
| 1686 | 1686 |
| 1687 can be a performance bottleneck. It usually happens with | 1687 can be a performance bottleneck. It usually happens with |
