Message Obfuscation

One of the methods to protect your data is to obfuscate messages which are sent with queue using secure key you've defined.

Obfuscate Channel

Channel can be protected in general which means every message will be obfuscated. In order to do that, you have to provide ChannelProtectionConfiguration.

use Ecotone\DataProtection\Configuration\ChannelProtectionConfiguration;

class DataProtection
{
    #[ServiceContext]
    public function paymentChannelProtectionConfiguration(): ChannelProtectionConfiguration
    {
        return ChannelProtectionConfiguration::create(
            channelName: 'payment', // define which channel needs protection
            encryptionKey: 'primary-key' // define which key should be used
            isPayloadSensitive: true, // // define if payload of messages sent by `payment` channel whould be obfuscated
            sensitiveHeaders: ['credit-card-number', 'iban'], // if occurs, those headers will be obfuscated. Ecotone won't add them.
        );
    }

    // payloads are considered sensitive by default
    // if not defined, channel will be secured with default key
    #[ServiceContext]
    public function dummyChannelProtectionConfiguration(): ChannelProtectionConfiguration
    {
        return ChannelProtectionConfiguration::create(
            channelName: 'dummy',
            sensitiveHeaders: ['foo', 'bar'],
        );
    }
}

Obfuscate Message

You can also obfuscate single message by using Data Protection attributes directly in your class.

Obfuscate Endpoint

Message obfuscation can be also defined at endpoint. Data Protection attributes can be used with #[Payload] or #[Header] .

circle-exclamation

In following example, ChargeCreditCard command and iban header will be secured with secondary-key despite payment channel uses primary-key and endpoint is defined with another-key.

Last updated

Was this helpful?