-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added fields for holding encrypted data in database (ENT 5613)
- Loading branch information
1 parent
adb7f83
commit 48a4adf
Showing
2 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
integrated_channels/moodle/migrations/0028_auto_20230928_1530.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,58 @@ | ||
# Generated by Django 3.2.20 on 2023-09-28 15:30 | ||
|
||
from django.db import migrations | ||
import fernet_fields.fields | ||
|
||
|
||
def populate_decrypted_fields(apps, schema_editor): | ||
""" | ||
Populates the encryption fields with the data previously stored in database. | ||
""" | ||
MoodleEnterpriseCustomerConfiguration = apps.get_model('moodle', 'MoodleEnterpriseCustomerConfiguration') | ||
|
||
for moodle_enterprise_configuration in MoodleEnterpriseCustomerConfiguration.objects.all(): | ||
moodle_enterprise_configuration.decrypted_username = moodle_enterprise_configuration.username | ||
moodle_enterprise_configuration.decrypted_password = moodle_enterprise_configuration.password | ||
moodle_enterprise_configuration.decrypted_token = moodle_enterprise_configuration.token | ||
moodle_enterprise_configuration.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('moodle', '0027_alter_historicalmoodleenterprisecustomerconfiguration_options'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='historicalmoodleenterprisecustomerconfiguration', | ||
name='decrypted_password', | ||
field=fernet_fields.fields.EncryptedCharField(blank=True, help_text="The encrypted API user's password used to obtain new tokens.", max_length=255, null=True, verbose_name='Encrypted Webservice Password'), | ||
), | ||
migrations.AddField( | ||
model_name='historicalmoodleenterprisecustomerconfiguration', | ||
name='decrypted_token', | ||
field=fernet_fields.fields.EncryptedCharField(blank=True, help_text="The encrypted API user's token used to obtain new tokens.", max_length=255, null=True, verbose_name='Encrypted Webservice Token'), | ||
), | ||
migrations.AddField( | ||
model_name='historicalmoodleenterprisecustomerconfiguration', | ||
name='decrypted_username', | ||
field=fernet_fields.fields.EncryptedCharField(blank=True, help_text="The encrypted API user's username used to obtain new tokens.", max_length=255, null=True, verbose_name='Encrypted Webservice Username'), | ||
), | ||
migrations.AddField( | ||
model_name='moodleenterprisecustomerconfiguration', | ||
name='decrypted_password', | ||
field=fernet_fields.fields.EncryptedCharField(blank=True, help_text="The encrypted API user's password used to obtain new tokens.", max_length=255, null=True, verbose_name='Encrypted Webservice Password'), | ||
), | ||
migrations.AddField( | ||
model_name='moodleenterprisecustomerconfiguration', | ||
name='decrypted_token', | ||
field=fernet_fields.fields.EncryptedCharField(blank=True, help_text="The encrypted API user's token used to obtain new tokens.", max_length=255, null=True, verbose_name='Encrypted Webservice Token'), | ||
), | ||
migrations.AddField( | ||
model_name='moodleenterprisecustomerconfiguration', | ||
name='decrypted_username', | ||
field=fernet_fields.fields.EncryptedCharField(blank=True, help_text="The encrypted API user's username used to obtain new tokens.", max_length=255, null=True, verbose_name='Encrypted Webservice Username'), | ||
), | ||
migrations.RunPython(populate_decrypted_fields), | ||
] |
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