Skip to content

encrypt_backend_traffic

Functions for encrypting backend traffic.

set_backend_funcs()

Sets the encode and decode methods of the Celery backend to custom implementations that handle encryption and decryption.

This function replaces the default encode and decode methods with _encrypt_encode and _decrypt_decode, respectively, ensuring that all data processed by the Celery backend is encrypted and decrypted appropriately.

Source code in merlin/common/security/encrypt_backend_traffic.py
def set_backend_funcs():
    """
    Sets the encode and decode methods of the Celery backend to custom
    implementations that handle encryption and decryption.

    This function replaces the default encode and decode methods with
    `_encrypt_encode` and `_decrypt_decode`, respectively, ensuring that
    all data processed by the Celery backend is encrypted and decrypted
    appropriately.
    """
    celery.backends.base.Backend.encode = _encrypt_encode
    celery.backends.base.Backend.decode = _decrypt_decode