FOCUSCurrently working on ScheduleSomething and LayerdEvents algorithmsLearn More
FOCUSCurrently working on ScheduleSomething and LayerdEvents algorithmsLearn More
FOCUSCurrently working on ScheduleSomething and LayerdEvents algorithmsLearn More
FOCUSCurrently working on ScheduleSomething and LayerdEvents algorithmsLearn More
SECURITY.MdOperations & Runbooks
Runbook: Rotate Fernet Keys
DocsSECURITY.mdOperations & RunbooksRunbook: Rotate Fernet Keys
GitHub Live Sync

Runbook: Rotate Fernet Keys

Live technical documentation fetched from GitHub repository omghante/metapilot/docs/operations/runbooks/rotate-fernet-keys.md

Runbook: Rotating Fernet Encryption Keys

Procedure for re-encrypting
TenantConfig
secrets when updating
FERNET_KEY
.

Procedure Steps

1. Generate New Fernet Key

bash
python scripts/generate_fernet_key.py
(Store
OLD_KEY
and
NEW_KEY
in environment)

2. Run Key Rotation Re-encryption Script

python
from cryptography.fernet import Fernet
from tenants.models import TenantConfig

old_fernet = Fernet(OLD_KEY.encode())
new_fernet = Fernet(NEW_KEY.encode())

for config in TenantConfig.objects.all():
    plain_val = old_fernet.decrypt(config.encrypted_value.encode()).decode()
    config.encrypted_value = new_fernet.encrypt(plain_val.encode()).decode()
    config.save()

3. Update Environment Variable

Update
FERNET_KEY
in
services/api/.env
and restart Daphne.