enable secret key rotation
This commit is contained in:
parent
7522c4bcdb
commit
e13373f838
9 changed files with 55 additions and 7 deletions
|
|
@ -180,6 +180,7 @@ class Flask(App):
|
|||
"TESTING": False,
|
||||
"PROPAGATE_EXCEPTIONS": None,
|
||||
"SECRET_KEY": None,
|
||||
"SECRET_KEY_FALLBACKS": None,
|
||||
"PERMANENT_SESSION_LIFETIME": timedelta(days=31),
|
||||
"USE_X_SENDFILE": False,
|
||||
"SERVER_NAME": None,
|
||||
|
|
|
|||
|
|
@ -315,14 +315,20 @@ class SecureCookieSessionInterface(SessionInterface):
|
|||
def get_signing_serializer(self, app: Flask) -> URLSafeTimedSerializer | None:
|
||||
if not app.secret_key:
|
||||
return None
|
||||
signer_kwargs = dict(
|
||||
key_derivation=self.key_derivation, digest_method=self.digest_method
|
||||
)
|
||||
|
||||
keys: list[str | bytes] = [app.secret_key]
|
||||
|
||||
if fallbacks := app.config["SECRET_KEY_FALLBACKS"]:
|
||||
keys.extend(fallbacks)
|
||||
|
||||
return URLSafeTimedSerializer(
|
||||
app.secret_key,
|
||||
keys, # type: ignore[arg-type]
|
||||
salt=self.salt,
|
||||
serializer=self.serializer,
|
||||
signer_kwargs=signer_kwargs,
|
||||
signer_kwargs={
|
||||
"key_derivation": self.key_derivation,
|
||||
"digest_method": self.digest_method,
|
||||
},
|
||||
)
|
||||
|
||||
def open_session(self, app: Flask, request: Request) -> SecureCookieSession | None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue