forked from aws/aws-sdk-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: SamRemis <[email protected]>
- Loading branch information
Showing
32 changed files
with
3,586 additions
and
795 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[ | ||
{ | ||
"type": "feature", | ||
"category": "S3", | ||
"description": "This release adds support for the S3express identity provider" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
namespace Aws\Identity\S3; | ||
|
||
use Aws\Credentials\Credentials; | ||
|
||
class S3ExpressIdentity extends Credentials {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
namespace Aws\Identity\S3; | ||
|
||
use Aws; | ||
use Aws\LruArrayCache; | ||
use GuzzleHttp\Promise; | ||
|
||
class S3ExpressIdentityProvider | ||
{ | ||
|
||
private $cache; | ||
private $s3Client; | ||
public function __construct(string $clientRegion, array $config = []) | ||
{ | ||
$this->cache = new LruArrayCache(100); | ||
$this->s3Client = isset($config['client']) | ||
? $config['client'] // internal use only | ||
: new Aws\S3\S3Client([ | ||
'region' => $clientRegion, | ||
'disable_express_session_auth' => true | ||
]); | ||
} | ||
|
||
public function __invoke($command) | ||
{ | ||
return function () use ($command) { | ||
$bucket = $command['Bucket']; | ||
if ($identity = $this->cache->get($bucket)) { | ||
if (!$identity->isExpired()) { | ||
return Promise\Create::promiseFor($identity); | ||
} | ||
} | ||
$response = $this->s3Client->createSession(['Bucket' => $bucket]); | ||
$identity = new Aws\Identity\S3\S3ExpressIdentity( | ||
$response['Credentials']['AccessKeyId'], | ||
$response['Credentials']['SecretAccessKey'], | ||
$response['Credentials']['SessionToken'], | ||
$response['Credentials']['Expiration']->getTimestamp() | ||
); | ||
$this->cache->set($bucket, $identity); | ||
return Promise\Create::promiseFor($identity); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.