Skip to content

Commit

Permalink
feat: add management command to reencrypt enterprise remoting configs
Browse files Browse the repository at this point in the history
  • Loading branch information
hamzawaleed01 committed Nov 20, 2023
1 parent df00d4a commit 1506360
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Django management command to reencrypt passwords in enterprise custom reporting configs.
"""
import logging
from django.core.management import BaseCommand

from enterprise.models import EnterpriseCustomerReportingConfiguration

LOGGER = logging.getLogger(__name__)


class Command(BaseCommand):
"""
Django management command to reencrypt passwords in enterprise custom reporting configs
It's useful when following encryption keys are rotated
- FERNET_KEYS
- LMS_FERNET_KEY
Example usage:
./manage.py lms reencrypt_enterprise_customer_reporting_config_passwords
"""


def handle(self, *args, **options):
try:
for config in EnterpriseCustomerReportingConfiguration.objects.all():
config.save() # resaving reencrypts all the encrypted columns
LOGGER.info('Enterprise customer reporting configuration passwords reencrypted succesfully!')
except Exception as e: # pylint: disable=broad-except
LOGGER.exception(f'Failed to reencrypt customer reporting configuration passwords. Error: {e}')

0 comments on commit 1506360

Please sign in to comment.