Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/DataProtection/src/Attribute/Sensitive.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use Attribute;

#[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_CLASS | Attribute::TARGET_PARAMETER)]
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_PARAMETER)]
class Sensitive
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

use Attribute;

#[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_CLASS | Attribute::TARGET_PARAMETER)]
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_PARAMETER)]
class WithEncryptionKey
{
public function __construct(private ?string $encryptionKey = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function prepare(Configuration $messagingConfiguration, array $extensionO
return;
}

$this->verifyLicense($messagingConfiguration, $extensionObjects);
$this->verifyLicense($messagingConfiguration);

Assert::isTrue(ExtensionObjectResolver::contains(JMSConverterConfiguration::class, $extensionObjects), sprintf('%s package require %s package to be enabled. Did you forget to define %s?', ModulePackageList::DATA_PROTECTION_PACKAGE, ModulePackageList::JMS_CONVERTER_PACKAGE, JMSConverterConfiguration::class));

Expand Down Expand Up @@ -180,30 +180,26 @@ private static function resolveObfuscatorConfigsFromAnnotatedMethods(array $anno
continue;
}

$isPayloadSensitive = $payload->hasAnnotation(Sensitive::class) || $methodDefinition->hasAnnotation(Sensitive::class);
$isPayloadSensitive = $payload->hasAnnotation(Sensitive::class);
if (! $isPayloadSensitive) {
continue;
}

$encryptionKey = $payload->findSingleAnnotation(Type::create(WithEncryptionKey::class))?->encryptionKey();
if ($encryptionKey === null) {
$encryptionKey = $methodDefinition->findSingleMethodAnnotation(Type::create(WithEncryptionKey::class))?->encryptionKey();
}
$sensitiveHeaders = array_map(static fn (WithSensitiveHeader $annotation) => $annotation->header, $methodDefinition->getMethodAnnotationsOf(Type::create(WithSensitiveHeader::class)) ?? []);

foreach ($methodDefinition->getInterfaceParameters() as $parameter) {
if ($parameter->hasAnnotation(Header::class) && $parameter->hasAnnotation(Sensitive::class)) {
$sensitiveHeaders[] = $parameter->getName();
}
}

$obfuscatorConfigs[$payload->getTypeHint()] = new ObfuscatorConfig($encryptionKey, $isPayloadSensitive, $sensitiveHeaders);
$obfuscatorConfigs[$payload->getTypeHint()] = new ObfuscatorConfig(encryptionKey: $encryptionKey, isPayloadSensitive: true, sensitiveHeaders: $sensitiveHeaders);
}

return $obfuscatorConfigs;
}

private function verifyLicense(Configuration $messagingConfiguration, array $extensionObjects): void
private function verifyLicense(Configuration $messagingConfiguration): void
{
if ($messagingConfiguration->isRunningForEnterpriseLicence()) {
return;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@
#[Asynchronous('test')]
class CommandHandlerWithAnnotatedEndpointWithAlreadyAnnotatedMessage
{
#[Sensitive]
#[WithEncryptionKey('secondary')]
#[WithSensitiveHeader('foo')]
#[WithSensitiveHeader('bar')]
#[WithSensitiveHeader('fos')]
#[CommandHandler(endpointId: 'test.obfuscateAnnotatedEndpoints.commandHandler.annotatedMethod')]
public function annotatedMethod(
AnnotatedMessage $message,
#[Sensitive] #[WithEncryptionKey('secondary')] AnnotatedMessage $message,
#[Headers] array $headers,
#[Reference] MessageReceiver $messageReceiver,
): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
#[Asynchronous('test')]
class CommandHandlerWithAnnotatedEndpointWithSecondaryEncryptionKey
{
#[Sensitive]
#[WithEncryptionKey('secondary')]
#[WithSensitiveHeader('foo')]
#[WithSensitiveHeader('bar')]
#[CommandHandler(endpointId: 'test.commandHandler.obfuscateAnnotatedEndpoints.annotatedMethodWithSecondaryEncryptionKey')]
public function annotatedMethodWithSecondaryEncryptionKey(
SomeMessage $message,
#[Sensitive] #[WithEncryptionKey('secondary')] SomeMessage $message,
#[Headers] array $headers,
#[Reference] MessageReceiver $messageReceiver,
): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#[Asynchronous('test')]
class CommandHandlerWithAnnotatedMethodWithoutPayload
{
#[Sensitive]
#[WithSensitiveHeader('foo')]
#[WithSensitiveHeader('bar')]
#[WithSensitiveHeader('fos')]
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@
#[Asynchronous('test')]
class EventHandlerWithAnnotatedEndpointWithAlreadyAnnotatedMessage
{
#[Sensitive]
#[WithEncryptionKey('secondary')]
#[WithSensitiveHeader('foo')]
#[WithSensitiveHeader('bar')]
#[WithSensitiveHeader('fos')]
#[EventHandler(endpointId: 'test.obfuscateAnnotatedEndpoints.eventHandler.annotatedMethod')]
public function annotatedMethod(
AnnotatedMessage $message,
#[Sensitive] #[WithEncryptionKey('secondary')] AnnotatedMessage $message,
#[Headers] array $headers,
#[Reference] MessageReceiver $messageReceiver,
): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
#[Asynchronous('test')]
class EventHandlerWithAnnotatedEndpointWithSecondaryEncryptionKey
{
#[Sensitive]
#[WithEncryptionKey('secondary')]
#[WithSensitiveHeader('foo')]
#[WithSensitiveHeader('bar')]
#[EventHandler(endpointId: 'test.obfuscateAnnotatedEndpoints.eventHandler.annotatedMethodWithSecondaryEncryptionKey')]
public function annotatedMethodWithSecondaryEncryptionKey(
SomeMessage $message,
#[Sensitive] #[WithEncryptionKey('secondary')] SomeMessage $message,
#[Headers] array $headers,
#[Reference] MessageReceiver $messageReceiver,
): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#[Asynchronous('test')]
class EventHandlerWithAnnotatedMethodWithoutPayload
{
#[Sensitive]
#[WithSensitiveHeader('foo')]
#[WithSensitiveHeader('bar')]
#[WithSensitiveHeader('fos')]
Expand Down
Loading