File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,10 @@ Version 3.0.3
33
44Unreleased
55
6+ - The default ``hashlib.sha1 `` may not be available in FIPS builds. Don't
7+ access it at import time so the developer has time to change the default.
8+ :issue: `5448 `
9+
610
711Version 3.0.2
812-------------
Original file line number Diff line number Diff line change @@ -277,6 +277,14 @@ def save_session(
277277session_json_serializer = TaggedJSONSerializer ()
278278
279279
280+ def _lazy_sha1 (string : bytes = b"" ) -> t .Any :
281+ """Don't access ``hashlib.sha1`` until runtime. FIPS builds may not include
282+ SHA-1, in which case the import and use as a default would fail before the
283+ developer can configure something else.
284+ """
285+ return hashlib .sha1 (string )
286+
287+
280288class SecureCookieSessionInterface (SessionInterface ):
281289 """The default session interface that stores sessions in signed cookies
282290 through the :mod:`itsdangerous` module.
@@ -286,7 +294,7 @@ class SecureCookieSessionInterface(SessionInterface):
286294 #: signing of cookie based sessions.
287295 salt = "cookie-session"
288296 #: the hash function to use for the signature. The default is sha1
289- digest_method = staticmethod (hashlib . sha1 )
297+ digest_method = staticmethod (_lazy_sha1 )
290298 #: the name of the itsdangerous supported key derivation. The default
291299 #: is hmac.
292300 key_derivation = "hmac"
You can’t perform that action at this time.
0 commit comments