Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1027fad

Browse files
committed
feature#45064 [Messenger] Add sessionToken option to SQS transport (filkaris)
This PR was squashed before being merged into the 6.1 branch.Discussion----------[Messenger] Add sessionToken option to SQS transport| Q | A| ------------- | ---| Branch? | 6.1| Bug fix? | no| New feature? | yes| Deprecations? | no| Tickets || License | MIT| Doc PR | [symfony/symfony-docs#16411](symfony/symfony-docs#16411)When trying to authenticate to use an SQS transport, AWS Credentials have 3 "keys"- aws_access_key_id- aws_secret_access_key- aws_session_tokenThe last one, `aws_session_token` is only required for temporary credentials. In those cases though, it must be passed as well otherwise AWS returns a 403 Access Denied.The async-aws library supports this in its configurationhttps://async-aws.com/configuration.html#sessiontokenThis MR essentially makes sure the user can pass this parameter inside yaml optionsCommits-------d3bce0e [Messenger] Add sessionToken option to SQS transport
2 parents19e99a6 +d3bce0e commit1027fad

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

‎src/Symfony/Component/Messenger/Bridge/AmazonSqs/CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
6.1
5+
---
6+
7+
* Added`session_token` option to support short-lived AWS credentials
8+
49
5.3
510
---
611

‎src/Symfony/Component/Messenger/Bridge/AmazonSqs/Tests/Transport/ConnectionTest.php‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,24 @@ public function testConfigureWithCredentials()
5656
);
5757
}
5858

59+
publicfunctiontestConfigureWithTemporaryCredentials()
60+
{
61+
$awsKey ='some_aws_access_key_value';
62+
$awsSecret ='some_aws_secret_value';
63+
$sessionToken ='some_aws_sessionToken';
64+
$region ='eu-west-1';
65+
$httpClient =$this->createMock(HttpClientInterface::class);
66+
$this->assertEquals(
67+
newConnection(['queue_name' =>'queue'],newSqsClient(['region' =>$region,'accessKeyId' =>$awsKey,'accessKeySecret' =>$awsSecret,'sessionToken' =>$sessionToken],null,$httpClient)),
68+
Connection::fromDsn('sqs://default/queue', [
69+
'access_key' =>$awsKey,
70+
'secret_key' =>$awsSecret,
71+
'session_token' =>$sessionToken,
72+
'region' =>$region,
73+
],$httpClient)
74+
);
75+
}
76+
5977
publicfunctiontestFromInvalidDsn()
6078
{
6179
$this->expectException(\InvalidArgumentException::class);

‎src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/Connection.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class Connection
4141
'auto_setup' =>true,
4242
'access_key' =>null,
4343
'secret_key' =>null,
44+
'session_token' =>null,
4445
'endpoint' =>'https://sqs.eu-west-1.amazonaws.com',
4546
'region' =>'eu-west-1',
4647
'queue_name' =>'messages',
@@ -89,6 +90,7 @@ public function __destruct()
8990
* * account: identifier of the AWS account
9091
* * access_key: AWS access key
9192
* * secret_key: AWS secret key
93+
* * session_token: AWS session token (required only when using temporary credentials)
9294
* * buffer_size: number of messages to prefetch (Default: 9)
9395
* * wait_time: long polling duration in seconds (Default: 20)
9496
* * poll_timeout: amount of seconds the transport should wait for new message
@@ -135,6 +137,9 @@ public static function fromDsn(string $dsn, array $options = [], HttpClientInter
135137
'accessKeyId' =>urldecode($parsedUrl['user'] ??'') ?:$options['access_key'] ??self::DEFAULT_OPTIONS['access_key'],
136138
'accessKeySecret' =>urldecode($parsedUrl['pass'] ??'') ?:$options['secret_key'] ??self::DEFAULT_OPTIONS['secret_key'],
137139
];
140+
if (null !==$options['session_token']) {
141+
$clientConfiguration['sessionToken'] =$options['session_token'];
142+
}
138143
if (isset($options['debug'])) {
139144
$clientConfiguration['debug'] =$options['debug'];
140145
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp