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
3
3
4
4
Unreleased
5
5
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
+
6
10
7
11
Version 3.0.2
8
12
-------------
Original file line number Diff line number Diff line change @@ -277,6 +277,14 @@ def save_session(
277
277
session_json_serializer = TaggedJSONSerializer ()
278
278
279
279
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
+
280
288
class SecureCookieSessionInterface (SessionInterface ):
281
289
"""The default session interface that stores sessions in signed cookies
282
290
through the :mod:`itsdangerous` module.
@@ -286,7 +294,7 @@ class SecureCookieSessionInterface(SessionInterface):
286
294
#: signing of cookie based sessions.
287
295
salt = "cookie-session"
288
296
#: the hash function to use for the signature. The default is sha1
289
- digest_method = staticmethod (hashlib . sha1 )
297
+ digest_method = staticmethod (_lazy_sha1 )
290
298
#: the name of the itsdangerous supported key derivation. The default
291
299
#: is hmac.
292
300
key_derivation = "hmac"
You can’t perform that action at this time.
0 commit comments