Use encrypt/decrypt methods in place of signing

This commit is contained in:
Ryan Ahearn
2022-12-09 16:33:10 -05:00
parent 1f183b96b9
commit 17ee4c3f2b
15 changed files with 179 additions and 150 deletions

View File

@@ -12,7 +12,7 @@ from app.utils import DATETIME_FORMAT
def send_delivery_status_to_service(
self, notification_id, encrypted_status_update
):
status_update = encryption.verify_signature(encrypted_status_update)
status_update = encryption.decrypt(encrypted_status_update)
data = {
"id": str(notification_id),
@@ -38,7 +38,7 @@ def send_delivery_status_to_service(
@notify_celery.task(bind=True, name="send-complaint", max_retries=5, default_retry_delay=300)
def send_complaint_to_service(self, complaint_data):
complaint = encryption.verify_signature(complaint_data)
complaint = encryption.decrypt(complaint_data)
data = {
"notification_id": complaint['notification_id'],
@@ -125,7 +125,7 @@ def create_delivery_status_callback_data(notification, service_callback_api):
"template_id": str(notification.template_id),
"template_version": notification.template_version,
}
return encryption.sign(data)
return encryption.encrypt(data)
def create_complaint_callback_data(complaint, notification, service_callback_api, recipient):
@@ -138,4 +138,4 @@ def create_complaint_callback_data(complaint, notification, service_callback_api
"service_callback_api_url": service_callback_api.url,
"service_callback_api_bearer_token": service_callback_api.bearer_token,
}
return encryption.sign(data)
return encryption.encrypt(data)

View File

@@ -125,7 +125,7 @@ def get_recipient_csv_and_template_and_sender_id(job):
def process_row(row, template, job, service, sender_id=None):
template_type = template.template_type
encrypted = encryption.sign({
encrypted = encryption.encrypt({
'template': str(template.id),
'template_version': job.template_version,
'job': str(job.id),
@@ -183,7 +183,7 @@ def save_sms(self,
notification_id,
encrypted_notification,
sender_id=None):
notification = encryption.verify_signature(encrypted_notification)
notification = encryption.decrypt(encrypted_notification)
service = SerialisedService.from_id(service_id)
template = SerialisedTemplate.from_id_and_service_id(
notification['template'],
@@ -241,7 +241,7 @@ def save_email(self,
notification_id,
encrypted_notification,
sender_id=None):
notification = encryption.verify_signature(encrypted_notification)
notification = encryption.decrypt(encrypted_notification)
service = SerialisedService.from_id(service_id)
template = SerialisedTemplate.from_id_and_service_id(
@@ -298,7 +298,7 @@ def save_api_sms(self, encrypted_notification):
def save_api_email_or_sms(self, encrypted_notification):
notification = encryption.verify_signature(encrypted_notification)
notification = encryption.decrypt(encrypted_notification)
service = SerialisedService.from_id(notification['service_id'])
q = QueueNames.SEND_EMAIL if notification['notification_type'] == EMAIL_TYPE else QueueNames.SEND_SMS
provider_task = provider_tasks.deliver_email if notification['notification_type'] == EMAIL_TYPE \
@@ -348,7 +348,7 @@ def save_letter(
notification_id,
encrypted_notification,
):
notification = encryption.verify_signature(encrypted_notification)
notification = encryption.decrypt(encrypted_notification)
postal_address = PostalAddress.from_personalisation(
InsensitiveDict(notification['personalisation'])