Fixed #30360 -- Added support for secret key rotation.

Thanks Florian Apolloner for the implementation idea.

Co-authored-by: Andreas Pelme <andreas@pelme.se>
Co-authored-by: Carlton Gibson <carlton.gibson@noumenal.es>
Co-authored-by: Vuyisile Ndlovu <terrameijar@gmail.com>
This commit is contained in:
tschilling 2021-12-13 21:47:03 -06:00 committed by Mariusz Felisiak
parent ba4a6880d1
commit 0dcd549bbe
18 changed files with 364 additions and 56 deletions

View file

@ -59,6 +59,22 @@ or from a file::
with open('/etc/secret_key.txt') as f:
SECRET_KEY = f.read().strip()
If rotating secret keys, you may use :setting:`SECRET_KEY_FALLBACKS`::
import os
SECRET_KEY = os.environ['CURRENT_SECRET_KEY']
SECRET_KEY_FALLBACKS = [
os.environ['OLD_SECRET_KEY'],
]
Ensure that old secret keys are removed from ``SECRET_KEY_FALLBACKS`` in a
timely manner.
.. versionchanged:: 4.1
The ``SECRET_KEY_FALLBACKS`` setting was added to support rotating secret
keys.
:setting:`DEBUG`
----------------