From a6048dec70980497b4b48c28ecb6d73bd852d1a2 Mon Sep 17 00:00:00 2001 From: myron_nzms Date: Thu, 23 Feb 2023 21:31:45 +0000 Subject: [PATCH] validate key and secrets --- src/AwsServiceProvider.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/AwsServiceProvider.php b/src/AwsServiceProvider.php index 60b1b69..f80aed9 100644 --- a/src/AwsServiceProvider.php +++ b/src/AwsServiceProvider.php @@ -1,4 +1,6 @@ -app instanceof LaravelApplication && $this->app->runningInConsole()) { $this->publishes( - [__DIR__.'/../config/aws_publish.php' => config_path('aws.php')], + [__DIR__ . '/../config/aws_publish.php' => config_path('aws.php')], 'aws-config' ); } elseif ($this->app instanceof LumenApplication) { @@ -44,13 +46,21 @@ public function boot() public function register() { $this->mergeConfigFrom( - __DIR__.'/../config/aws_default.php', + __DIR__ . '/../config/aws_default.php', 'aws' ); $this->app->singleton('aws', function ($app) { $config = $app->make('config')->get('aws'); + // validate key and secrets, empty value will stop aws sdk from looking for the correct credentials + if ( + !isset($config['credentials']['key']) || !isset($config['credentials']['secret']) + || empty($config['credentials']['key']) || empty($config['credentials']['secret']) + ) { + unset($config['credentials']); + } + return new Sdk($config); }); @@ -66,5 +76,4 @@ public function provides() { return ['aws', 'Aws\Sdk']; } - }