mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
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:
committed by
Mariusz Felisiak
parent
ba4a6880d1
commit
0dcd549bbe
@@ -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`
|
||||
----------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user