Michael Merickel
2017-04-29 682a9b9df6f42f8261daa077f04b47b65bf00c34
refs
author Michael Merickel <michael@merickel.org>
Saturday, April 29, 2017 08:43 +0200
committer Michael Merickel <michael@merickel.org>
Saturday, April 29, 2017 09:04 +0200
commit682a9b9df6f42f8261daa077f04b47b65bf00c34
tree 54232513a60d4c94b21221280e9138f7a2219485 tree | zip | gz
parent 4b3603ad2f4850605c45e1b7bf4f077584303641 view | diff
final cleanup of csrf decoupling in #2854

- Renamed `SessionCSRFStoragePolicy` to `LegacySessionCSRFStoragePolicy` for
the version that uses the legacy `ISession.get_csrf_token` and
`ISession.new_csrf_token` apis and set that as the default.

- Added new `SessionCSRFStoragePolicy` that stores data in the session
similar to how the `SessionAuthenticationPolicy` works.

- `CookieCSRFStoragePolicy` did not properly return the newly generated
token from `get_csrf_token` after calling `new_csrf_token`. It needed
to cache the new value since the response callback does not affect
the current request.

- `CookieCSRFStoragePolicy` was not forwarding the `domain` value to the
`CookieProfile` causing that setting to be ignored.

- Removed `check_csrf_token` from the `ICSRFStoragePolicy` interface
to simplify implementations of storage policies.

- Added an introspectable item for the configured storage policy so that
it appears on the debugtoolbar.

- Added a change note on `ISession` that it no longer required the csrf methods.

- Leave deprecated shims in ``pyramid.session`` for
``check_csrf_origin`` and ``check_csrf_token``.
10 files modified
308 ■■■■■ changed files
CHANGES.txt 13 ●●●● diff | view | raw | blame | history
docs/api/csrf.rst 3 ●●●●● diff | view | raw | blame | history
docs/narr/security.rst 1 ●●●● diff | view | raw | blame | history
docs/narr/templates.rst 4 ●●●● diff | view | raw | blame | history
pyramid/config/security.py 20 ●●●●● diff | view | raw | blame | history
pyramid/csrf.py 109 ●●●●● diff | view | raw | blame | history
pyramid/interfaces.py 30 ●●●●● diff | view | raw | blame | history
pyramid/session.py 14 ●●●●● diff | view | raw | blame | history
pyramid/tests/test_csrf.py 108 ●●●● diff | view | raw | blame | history
pyramid/tests/test_util.py 6 ●●●● diff | view | raw | blame | history