Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TableauConnectedApp, TransifexOrganization, and OpenmrsImporter models: AES CBC encryption read and write #35665

Merged
merged 10 commits into from
Jan 24, 2025
3 changes: 1 addition & 2 deletions corehq/apps/translations/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.contrib import admin

from corehq.motech.utils import b64_aes_encrypt

from .forms import TransifexOrganizationForm
from .models import TransifexOrganization
Expand All @@ -10,7 +9,7 @@ class TransifexOrganizationAdmin(admin.ModelAdmin):
form = TransifexOrganizationForm

def save_model(self, request, obj, form, change):
obj.api_token = b64_aes_encrypt(obj.api_token)
obj.plaintext_api_token = obj.api_token
super(TransifexOrganizationAdmin, self).save_model(request, obj, form, change)


Expand Down
6 changes: 5 additions & 1 deletion corehq/apps/translations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.urls import reverse

from corehq.apps.app_manager.dbaccessors import get_app, get_app_ids_in_domain
from corehq.motech.utils import b64_aes_decrypt
from corehq.motech.utils import b64_aes_decrypt, b64_aes_encrypt
from corehq.util.quickcache import quickcache


Expand Down Expand Up @@ -168,6 +168,10 @@ def __str__(self):
def plaintext_api_token(self):
return b64_aes_decrypt(self.api_token)

@plaintext_api_token.setter
def plaintext_api_token(self, plaintext):
jingcheng16 marked this conversation as resolved.
Show resolved Hide resolved
self.api_token = b64_aes_encrypt(plaintext)


class TransifexProject(models.Model):
organization = models.ForeignKey(TransifexOrganization, on_delete=models.CASCADE)
Expand Down