Skip to content

Commit c6f3e5e

Browse files
committed
Add $credentials as property to allow custom credential provider
1 parent 0ef4a08 commit c6f3e5e

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

src/AwsS3Filesystem.php

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,24 @@ class AwsS3Filesystem extends Filesystem
5858
* @var string
5959
*/
6060
public $endpoint;
61+
/**
62+
* @var array|\Aws\CacheInterface|\Aws\Credentials\CredentialsInterface|bool|callable
63+
*/
64+
public $credentials;
6165

6266
/**
6367
* @inheritdoc
6468
*/
6569
public function init()
6670
{
67-
if ($this->key === null) {
68-
throw new InvalidConfigException('The "key" property must be set.');
69-
}
71+
if ($this->credentials === null) {
72+
if ($this->key === null) {
73+
throw new InvalidConfigException('The "key" property must be set.');
74+
}
7075

71-
if ($this->secret === null) {
72-
throw new InvalidConfigException('The "secret" property must be set.');
76+
if ($this->secret === null) {
77+
throw new InvalidConfigException('The "secret" property must be set.');
78+
}
7379
}
7480

7581
if ($this->bucket === null) {
@@ -84,12 +90,14 @@ public function init()
8490
*/
8591
protected function prepareAdapter()
8692
{
87-
$config = [
88-
'credentials' => [
89-
'key' => $this->key,
90-
'secret' => $this->secret
91-
]
92-
];
93+
$config = [];
94+
95+
if ($this->credentials === null) {
96+
$config['credentials'] = ['key' => $this->key, 'secret' => $this->secret];
97+
} else {
98+
$config['credentials'] = $this->credentials;
99+
}
100+
93101

94102
if ($this->pathStyleEndpoint === true) {
95103
$config['use_path_style_endpoint'] = true;

0 commit comments

Comments
 (0)