![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/cartforge.co/vendor/aws/aws-sdk-php/src/Identity/S3/ |
<?php namespace Aws\Identity\S3; use Aws; use Aws\LruArrayCache; use GuzzleHttp\Promise; class S3ExpressIdentityProvider { private $cache; private $region; private $config; private $s3Client; public function __construct($clientRegion, array $config = []) { $this->cache = new LruArrayCache(100); $this->region = $clientRegion; $this->config = $config; } public function __invoke($command) { $s3Client = $this->getS3Client(); $bucket = $command['Bucket']; if ($identity = $this->cache->get($bucket)) { if (!$identity->isExpired()) { return Promise\Create::promiseFor($identity); } } $response = $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); } private function getS3Client() { if (is_null($this->s3Client)) { $this->s3Client = $this->config['client'] ?? new Aws\S3\S3Client([ 'region' => $this->region, 'disable_express_session_auth' => true ]); } return $this->s3Client; } }