Skip to content

validate key and secrets #228

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
17 changes: 13 additions & 4 deletions src/AwsServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php namespace Aws\Laravel;
<?php

namespace Aws\Laravel;

use Aws\Sdk;
use Illuminate\Foundation\Application as LaravelApplication;
Expand Down Expand Up @@ -28,7 +30,7 @@ public function boot()
{
if ($this->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) {
Expand All @@ -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);
});

Expand All @@ -66,5 +76,4 @@ public function provides()
{
return ['aws', 'Aws\Sdk'];
}

}