Skip to content

Commit bd0bf4d

Browse files
authored
Merge pull request #40 from danielkesselberg/master
Add support for custom credentials provider
2 parents 0ef4a08 + 437e470 commit bd0bf4d

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## 0.9.3
4+
5+
- AWS S3: added `credentials` for custom credential provider
6+
37
## 0.9.2
48

59
- AWS S3: added `pathStyleEndpoint` to allow the use of https://www.minio.io/ as storage service

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)