Skip to content

[Mailer] [Bridges] Use CPP and add more #[\SensitiveParameter] attributes #53241

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

Merged
merged 1 commit into from
Jan 2, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@
*/
class SesHttpAsyncAwsTransport extends AbstractTransport
{
protected SesClient $sesClient;

public function __construct(SesClient $sesClient, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
{
$this->sesClient = $sesClient;

public function __construct(
protected SesClient $sesClient,
EventDispatcherInterface $dispatcher = null,
LoggerInterface $logger = null,
) {
parent::__construct($dispatcher, $logger);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,36 +29,24 @@ final class AzureApiTransport extends AbstractApiTransport
private const HOST = '%s.communication.azure.com';

/**
* User Access Key from Azure Communication Service (Primary or Secondary key).
* @param string $key User Access Key from Azure Communication Service (Primary or Secondary key)
* @param string $resourceName The endpoint API URL to which to POST emails to Azure https://{acsResourceName}.communication.azure.com/
* @param bool $disableTracking Indicates whether user engagement tracking should be disabled
* @param string $apiVersion The version of API to invoke
*/
private string $key;

/**
* The endpoint API URL to which to POST emails to Azure
* https://{acsResourceName}.communication.azure.com/.
*/
private string $resourceName;

/**
* The version of API to invoke.
*/
private string $apiVersion;

/**
* Indicates whether user engagement tracking should be disabled.
*/
private bool $disableTracking;

public function __construct(string $key, string $resourceName, bool $disableTracking = false, string $apiVersion = '2023-03-31', HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
{
public function __construct(
#[\SensitiveParameter] private string $key,
private string $resourceName,
private bool $disableTracking = false,
private string $apiVersion = '2023-03-31',
HttpClientInterface $client = null,
EventDispatcherInterface $dispatcher = null,
LoggerInterface $logger = null,
) {
if (str_contains($resourceName, '.') || str_ends_with($resourceName, '.')) {
throw new \Exception('Resource name cannot contain or end with a dot.');
}

$this->resourceName = $resourceName;
$this->key = $key;
$this->apiVersion = $apiVersion;
$this->disableTracking = $disableTracking;
parent::__construct($client, $dispatcher, $logger);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
*/
final class BrevoApiTransport extends AbstractApiTransport
{
private string $key;

public function __construct(string $key, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
{
$this->key = $key;

public function __construct(
#[\SensitiveParameter] private string $key,
HttpClientInterface $client = null,
EventDispatcherInterface $dispatcher = null,
LoggerInterface $logger = null,
) {
parent::__construct($client, $dispatcher, $logger);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ final class InfobipApiTransport extends AbstractApiTransport
'X-Infobip-Track' => 'track',
];

private string $key;

public function __construct(string $key, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
{
$this->key = $key;

public function __construct(
#[\SensitiveParameter] private string $key,
HttpClientInterface $client = null,
EventDispatcherInterface $dispatcher = null,
LoggerInterface $logger = null,
) {
parent::__construct($client, $dispatcher, $logger);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ final class MailPaceApiTransport extends AbstractApiTransport
{
private const HOST = 'app.mailpace.com/api/v1';

private string $key;

public function __construct(string $key, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
{
$this->key = $key;

public function __construct(
#[\SensitiveParameter] private string $key,
HttpClientInterface $client = null,
EventDispatcherInterface $dispatcher = null,
LoggerInterface $logger = null,
) {
parent::__construct($client, $dispatcher, $logger);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ class MandrillApiTransport extends AbstractApiTransport
{
private const HOST = 'mandrillapp.com';

private string $key;

public function __construct(string $key, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
{
$this->key = $key;

public function __construct(
#[\SensitiveParameter] private string $key,
HttpClientInterface $client = null,
EventDispatcherInterface $dispatcher = null,
LoggerInterface $logger = null,
) {
parent::__construct($client, $dispatcher, $logger);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ class MandrillHttpTransport extends AbstractHttpTransport
use MandrillHeadersTrait;

private const HOST = 'mandrillapp.com';
private string $key;

public function __construct(string $key, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
{
$this->key = $key;

public function __construct(
#[\SensitiveParameter] private string $key,
HttpClientInterface $client = null,
EventDispatcherInterface $dispatcher = null,
LoggerInterface $logger = null,
) {
parent::__construct($client, $dispatcher, $logger);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
*/
final class MailerSendApiTransport extends AbstractApiTransport
{
private string $key;

public function __construct(#[\SensitiveParameter] string $key, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
{
$this->key = $key;

public function __construct(
#[\SensitiveParameter] private string $key,
HttpClientInterface $client = null,
EventDispatcherInterface $dispatcher = null,
LoggerInterface $logger = null,
) {
parent::__construct($client, $dispatcher, $logger);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,14 @@ class MailgunApiTransport extends AbstractApiTransport
{
private const HOST = 'api.%region_dot%mailgun.net';

private string $key;
private string $domain;
private ?string $region;

public function __construct(string $key, string $domain, string $region = null, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
{
$this->key = $key;
$this->domain = $domain;
$this->region = $region;

public function __construct(
#[\SensitiveParameter] private string $key,
private string $domain,
private ?string $region = null,
HttpClientInterface $client = null,
EventDispatcherInterface $dispatcher = null,
LoggerInterface $logger = null,
) {
parent::__construct($client, $dispatcher, $logger);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,14 @@ class MailgunHttpTransport extends AbstractHttpTransport

private const HOST = 'api.%region_dot%mailgun.net';

private string $key;
private string $domain;
private ?string $region;

public function __construct(string $key, string $domain, string $region = null, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
{
$this->key = $key;
$this->domain = $domain;
$this->region = $region;

public function __construct(
#[\SensitiveParameter] private string $key,
private string $domain,
private ?string $region = null,
HttpClientInterface $client = null,
EventDispatcherInterface $dispatcher = null,
LoggerInterface $logger = null,
) {
parent::__construct($client, $dispatcher, $logger);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,14 @@ class MailjetApiTransport extends AbstractApiTransport
'X-Mailjet-TrackOpen' => ['TrackOpen', 'string'],
];

private string $privateKey;
private string $publicKey;
private bool $sandbox;

public function __construct(string $publicKey, string $privateKey, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null, bool $sandbox = false)
{
$this->publicKey = $publicKey;
$this->privateKey = $privateKey;
$this->sandbox = $sandbox;

public function __construct(
private string $publicKey,
#[\SensitiveParameter] private string $privateKey,
HttpClientInterface $client = null,
EventDispatcherInterface $dispatcher = null,
LoggerInterface $logger = null,
private bool $sandbox = false,
) {
parent::__construct($client, $dispatcher, $logger);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,29 @@ class PostmarkApiTransport extends AbstractApiTransport

private ?EventDispatcherInterface $dispatcher;

private string $key;

private ?string $messageStream = null;

public function __construct(string $key, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
{
$this->key = $key;
public function __construct(
#[\SensitiveParameter] private string $key,
HttpClientInterface $client = null,
EventDispatcherInterface $dispatcher = null,
LoggerInterface $logger = null,
) {
$this->dispatcher = $dispatcher;

parent::__construct($client, $dispatcher, $logger);
}

/**
* @return $this
*/
public function setMessageStream(string $messageStream): static
{
$this->messageStream = $messageStream;

return $this;
}

public function __toString(): string
{
return sprintf('postmark+api://%s', $this->getEndpoint()).($this->messageStream ? '?message_stream='.$this->messageStream : '');
Expand Down Expand Up @@ -177,14 +188,4 @@ private function getEndpoint(): ?string
{
return ($this->host ?: self::HOST).($this->port ? ':'.$this->port : '');
}

/**
* @return $this
*/
public function setMessageStream(string $messageStream): static
{
$this->messageStream = $messageStream;

return $this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,14 @@ final class ScalewayApiTransport extends AbstractApiTransport
{
private const HOST = 'api.scaleway.com';

private string $projectId;
private string $token;
private ?string $region;

public function __construct(string $projectId, string $token, string $region = null, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
{
$this->projectId = $projectId;
$this->token = $token;
$this->region = $region;

public function __construct(
private string $projectId,
#[\SensitiveParameter] private string $token,
private ?string $region = null,
HttpClientInterface $client = null,
EventDispatcherInterface $dispatcher = null,
LoggerInterface $logger = null,
) {
parent::__construct($client, $dispatcher, $logger);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ class SendgridApiTransport extends AbstractApiTransport
{
private const HOST = 'api.sendgrid.com';

private string $key;

public function __construct(string $key, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
{
$this->key = $key;

public function __construct(
#[\SensitiveParameter] private string $key,
HttpClientInterface $client = null,
EventDispatcherInterface $dispatcher = null,
LoggerInterface $logger = null,
) {
parent::__construct($client, $dispatcher, $logger);
}

Expand Down