-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add management command to reencrypt enterprise remoting configs
- Loading branch information
1 parent
df00d4a
commit 1506360
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
enterprise/management/commands/reencrypt_enterprise_customer_reporting_config_passwords.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}') |