Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Messenger] Add sessionToken option to SQS transport #45064

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
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
5 changes: 5 additions & 0 deletions src/Symfony/Component/Messenger/Bridge/AmazonSqs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

6.1
---

* Added `session_token` option to support short-lived AWS credentials

5.3
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,24 @@ public function testConfigureWithCredentials()
);
}

public function testConfigureWithTemporaryCredentials()
{
$awsKey = 'some_aws_access_key_value';
$awsSecret = 'some_aws_secret_value';
$sessionToken = 'some_aws_sessionToken';
$region = 'eu-west-1';
$httpClient = $this->createMock(HttpClientInterface::class);
$this->assertEquals(
new Connection(['queue_name' => 'queue'], new SqsClient(['region' => $region, 'accessKeyId' => $awsKey, 'accessKeySecret' => $awsSecret, 'sessionToken' => $sessionToken], null, $httpClient)),
Connection::fromDsn('sqs://default/queue', [
'access_key' => $awsKey,
'secret_key' => $awsSecret,
'session_token' => $sessionToken,
'region' => $region,
], $httpClient)
);
}

public function testFromInvalidDsn()
{
$this->expectException(\InvalidArgumentException::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Connection
'auto_setup' => true,
'access_key' => null,
'secret_key' => null,
'session_token' => null,
'endpoint' => 'https://sqs.eu-west-1.amazonaws.com',
'region' => 'eu-west-1',
'queue_name' => 'messages',
Expand Down Expand Up @@ -89,6 +90,7 @@ public function __destruct()
* * account: identifier of the AWS account
* * access_key: AWS access key
* * secret_key: AWS secret key
* * session_token: AWS session token (required only when using temporary credentials)
* * buffer_size: number of messages to prefetch (Default: 9)
* * wait_time: long polling duration in seconds (Default: 20)
* * poll_timeout: amount of seconds the transport should wait for new message
Expand Down Expand Up @@ -135,6 +137,9 @@ public static function fromDsn(string $dsn, array $options = [], HttpClientInter
'accessKeyId' => urldecode($parsedUrl['user'] ?? '') ?: $options['access_key'] ?? self::DEFAULT_OPTIONS['access_key'],
'accessKeySecret' => urldecode($parsedUrl['pass'] ?? '') ?: $options['secret_key'] ?? self::DEFAULT_OPTIONS['secret_key'],
];
if (null !== $options['session_token']) {
$clientConfiguration['sessionToken'] = $options['session_token'];
}
if (isset($options['debug'])) {
$clientConfiguration['debug'] = $options['debug'];
}
Expand Down