forked from orbit-oss/flask
access sha1 lazily
This commit is contained in:
parent
7320e311a0
commit
db461112c7
2 changed files with 13 additions and 1 deletions
|
|
@ -3,6 +3,10 @@ Version 3.0.3
|
|||
|
||||
Unreleased
|
||||
|
||||
- The default ``hashlib.sha1`` may not be available in FIPS builds. Don't
|
||||
access it at import time so the developer has time to change the default.
|
||||
:issue:`5448`
|
||||
|
||||
|
||||
Version 3.0.2
|
||||
-------------
|
||||
|
|
|
|||
|
|
@ -277,6 +277,14 @@ class SessionInterface:
|
|||
session_json_serializer = TaggedJSONSerializer()
|
||||
|
||||
|
||||
def _lazy_sha1(string: bytes = b"") -> t.Any:
|
||||
"""Don't access ``hashlib.sha1`` until runtime. FIPS builds may not include
|
||||
SHA-1, in which case the import and use as a default would fail before the
|
||||
developer can configure something else.
|
||||
"""
|
||||
return hashlib.sha1(string)
|
||||
|
||||
|
||||
class SecureCookieSessionInterface(SessionInterface):
|
||||
"""The default session interface that stores sessions in signed cookies
|
||||
through the :mod:`itsdangerous` module.
|
||||
|
|
@ -286,7 +294,7 @@ class SecureCookieSessionInterface(SessionInterface):
|
|||
#: signing of cookie based sessions.
|
||||
salt = "cookie-session"
|
||||
#: the hash function to use for the signature. The default is sha1
|
||||
digest_method = staticmethod(hashlib.sha1)
|
||||
digest_method = staticmethod(_lazy_sha1)
|
||||
#: the name of the itsdangerous supported key derivation. The default
|
||||
#: is hmac.
|
||||
key_derivation = "hmac"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue