mirror of
https://github.com/jazzband/django-fernet-encrypted-fields.git
synced 2026-03-16 22:40:27 +00:00
Updated README - added paragraph about rotating secret key
This commit is contained in:
parent
05be6f7bc4
commit
83194fbf4c
1 changed files with 10 additions and 1 deletions
11
README.md
11
README.md
|
|
@ -39,9 +39,18 @@ SALT_KEY = [
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Rotating SECRET_KEY
|
||||||
|
|
||||||
|
When you would want to rotate your `SECRET_KEY`, set the new value and put your old secret key value to `SECRET_KEY_FALLBACKS` list. That way the existing encrypted fields will still work, but when you re-save the field or create new record, it will be encrypted with the new secret key. (supported in Django >=4.1)
|
||||||
|
|
||||||
|
```python
|
||||||
|
SECRET_KEY = "new-key"
|
||||||
|
SECRET_KEY_FALLBACKS = ["old-key"]
|
||||||
|
```
|
||||||
|
|
||||||
If you wish to update the existing encrypted records simply load and re-save the models to use the new key.
|
If you wish to update the existing encrypted records simply load and re-save the models to use the new key.
|
||||||
|
|
||||||
```
|
```python
|
||||||
for obj in MuModel.objects.all():
|
for obj in MuModel.objects.all():
|
||||||
obj.save()
|
obj.save()
|
||||||
```
|
```
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue