Skip to content

Commit 909ea24

Browse files
authored
[10.x] Do not add token to AWS credentials without validating it first (#48297)
* Remove token from config options when making a new DynamoDB client - including this creates an error with the `AwsClient` (which `DynamoDbClient` extends) in recent versions of the AWS PHP SDK: ```Invalid configuration value provided for "token"...``` * Do not add `token` value to the `credentials` array element _unless it was already present_ within the config. Adding a blank `token` value into this array element - simply because two other values (`key` and `secret`) happened to be found within the config - can break the `AwsClient`/`S3Client` being built by these managers. It is also cleaner to have a separate check for this `token` value - rather than assume that because you found two other values, you may as well go ahead and add this third value into the mix too, without having validated it first. --------- Co-authored-by: Michael Mehmet <>
1 parent abe8656 commit 909ea24

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Illuminate/Cache/CacheManager.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,14 @@ protected function newDynamodbClient(array $config)
260260

261261
if (! empty($config['key']) && ! empty($config['secret'])) {
262262
$dynamoConfig['credentials'] = Arr::only(
263-
$config, ['key', 'secret', 'token']
263+
$config, ['key', 'secret']
264264
);
265265
}
266266

267+
if (! empty($config['token'])) {
268+
$dynamoConfig['credentials']['token'] = $config['token'];
269+
}
270+
267271
return new DynamoDbClient($dynamoConfig);
268272
}
269273

src/Illuminate/Filesystem/FilesystemManager.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,11 @@ protected function formatS3Config(array $config)
263263
$config += ['version' => 'latest'];
264264

265265
if (! empty($config['key']) && ! empty($config['secret'])) {
266-
$config['credentials'] = Arr::only($config, ['key', 'secret', 'token']);
266+
$config['credentials'] = Arr::only($config, ['key', 'secret']);
267+
}
268+
269+
if (! empty($config['token'])) {
270+
$config['credentials']['token'] = $config['token'];
267271
}
268272

269273
return Arr::except($config, ['token']);

0 commit comments

Comments
 (0)