From e21b3db390883e80585972a463f754e5ebbb6231 Mon Sep 17 00:00:00 2001 From: Sirn Thanabulpong Date: Wed, 7 Sep 2022 14:38:57 +0900 Subject: [PATCH] Move csrf configuration into core.csrf --- fanboi2/core/__init__.py | 1 + fanboi2/core/csrf.py | 6 ++++++ fanboi2/core/session.py | 2 -- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 fanboi2/core/csrf.py diff --git a/fanboi2/core/__init__.py b/fanboi2/core/__init__.py index 26adefd..e79fe9c 100644 --- a/fanboi2/core/__init__.py +++ b/fanboi2/core/__init__.py @@ -4,6 +4,7 @@ from pyramid.config import Configurator # type: ignore def includeme(config: Configurator): # pragma: no cover config.include("fanboi2.core.auth") config.include("fanboi2.core.cache") + config.include("fanboi2.core.csrf") config.include("fanboi2.core.geoip") config.include("fanboi2.core.redis") config.include("fanboi2.core.serializers") diff --git a/fanboi2/core/csrf.py b/fanboi2/core/csrf.py new file mode 100644 index 0000000..5aadb27 --- /dev/null +++ b/fanboi2/core/csrf.py @@ -0,0 +1,6 @@ +from pyramid.config import Configurator # type: ignore +from pyramid.csrf import SessionCSRFStoragePolicy # type: ignore + + +def includeme(config: Configurator): + config.set_csrf_storage_policy(SessionCSRFStoragePolicy(key="_csrf")) diff --git a/fanboi2/core/session.py b/fanboi2/core/session.py index 3740b64..88f5f29 100644 --- a/fanboi2/core/session.py +++ b/fanboi2/core/session.py @@ -1,7 +1,6 @@ import binascii from pyramid.config import Configurator # type: ignore -from pyramid.csrf import SessionCSRFStoragePolicy # type: ignore from pyramid_nacl_session import EncryptedCookieSessionFactory # type: ignore @@ -13,4 +12,3 @@ def includeme(config: Configurator): ) config.set_session_factory(session_factory) - config.set_csrf_storage_policy(SessionCSRFStoragePolicy(key="_csrf")) -- 2.45.2