Skip to content

Commit

Permalink
[10.x] Fix: Prevent invalid AWS credentials options being created
Browse files Browse the repository at this point in the history
Improves on 909ea24 which could create credentials arrays with only a token
  • Loading branch information
robchett authored Nov 22, 2024
1 parent f4cb362 commit ef47f6a
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 17 deletions.
8 changes: 4 additions & 4 deletions src/Illuminate/Bus/BusServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ protected function registerBatchServices()
];

if (! empty($config['key']) && ! empty($config['secret'])) {
$dynamoConfig['credentials'] = Arr::only(
$config,
['key', 'secret', 'token']
);
$dynamoConfig['credentials'] = Arr::only($config, ['key', 'secret']);
if (! empty($config['token'])) {
$dynamoConfig['credentials']['token'] = $config['token'];
}
}

return new DynamoBatchRepository(
Expand Down
7 changes: 3 additions & 4 deletions src/Illuminate/Cache/CacheManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,9 @@ protected function newDynamodbClient(array $config)
$dynamoConfig['credentials'] = Arr::only(
$config, ['key', 'secret']
);
}

if (! empty($config['token'])) {
$dynamoConfig['credentials']['token'] = $config['token'];
if (! empty($config['token'])) {
$dynamoConfig['credentials']['token'] = $config['token'];
}
}

return new DynamoDbClient($dynamoConfig);
Expand Down
7 changes: 3 additions & 4 deletions src/Illuminate/Filesystem/FilesystemManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,9 @@ protected function formatS3Config(array $config)

if (! empty($config['key']) && ! empty($config['secret'])) {
$config['credentials'] = Arr::only($config, ['key', 'secret']);
}

if (! empty($config['token'])) {
$config['credentials']['token'] = $config['token'];
if (! empty($config['token'])) {
$config['credentials']['token'] = $config['token'];
}
}

return Arr::except($config, ['token']);
Expand Down
5 changes: 4 additions & 1 deletion src/Illuminate/Mail/MailManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,10 @@ protected function createSesV2Transport(array $config)
protected function addSesCredentials(array $config)
{
if (! empty($config['key']) && ! empty($config['secret'])) {
$config['credentials'] = Arr::only($config, ['key', 'secret', 'token']);
$config['credentials'] = Arr::only($config, ['key', 'secret']);
if (! empty($config['token'])) {
$config['credentials']['token'] = $config['token'];
}
}

return Arr::except($config, ['token']);
Expand Down
5 changes: 4 additions & 1 deletion src/Illuminate/Queue/Connectors/SqsConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ public function connect(array $config)
$config = $this->getDefaultConfiguration($config);

if (! empty($config['key']) && ! empty($config['secret'])) {
$config['credentials'] = Arr::only($config, ['key', 'secret', 'token']);
$config['credentials'] = Arr::only($config, ['key', 'secret']);
if (! empty($config['token'])) {
$config['credentials']['token'] = $config['token'];
}
}

return new SqsQueue(
Expand Down
7 changes: 4 additions & 3 deletions src/Illuminate/Queue/QueueServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,10 @@ protected function dynamoFailedJobProvider($config)
];

if (! empty($config['key']) && ! empty($config['secret'])) {
$dynamoConfig['credentials'] = Arr::only(
$config, ['key', 'secret', 'token']
);
$dynamoConfig['credentials'] = Arr::only($config, ['key', 'secret']);
if (! empty($config['token'])) {
$dynamoConfig['credentials']['token'] = $config['token'];
}
}

return new DynamoDbFailedJobProvider(
Expand Down

0 comments on commit ef47f6a

Please sign in to comment.