mirror of
https://github.com/SociallyDev/Spaces-API.git
synced 2025-08-14 02:27:23 -07:00
spaces.php
This commit is contained in:
parent
7755490b81
commit
eefa32741e
845 changed files with 50409 additions and 0 deletions
61
aws/Aws/CognitoIdentity/CognitoIdentityProvider.php
Normal file
61
aws/Aws/CognitoIdentity/CognitoIdentityProvider.php
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
namespace Aws\CognitoIdentity;
|
||||
|
||||
use Aws\Credentials\Credentials;
|
||||
use GuzzleHttp\Promise;
|
||||
|
||||
class CognitoIdentityProvider
|
||||
{
|
||||
/** @var CognitoIdentityClient */
|
||||
private $client;
|
||||
/** @var string */
|
||||
private $identityPoolId;
|
||||
/** @var string|null */
|
||||
private $accountId;
|
||||
/** @var array */
|
||||
private $logins;
|
||||
|
||||
public function __construct(
|
||||
$poolId,
|
||||
array $clientOptions,
|
||||
array $logins = [],
|
||||
$accountId = null
|
||||
) {
|
||||
$this->identityPoolId = $poolId;
|
||||
$this->logins = $logins;
|
||||
$this->accountId = $accountId;
|
||||
$this->client = new CognitoIdentityClient($clientOptions + [
|
||||
'credentials' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
public function __invoke()
|
||||
{
|
||||
return Promise\coroutine(function () {
|
||||
$params = $this->logins ? ['Logins' => $this->logins] : [];
|
||||
$getIdParams = $params + ['IdentityPoolId' => $this->identityPoolId];
|
||||
if ($this->accountId) {
|
||||
$getIdParams['AccountId'] = $this->accountId;
|
||||
}
|
||||
|
||||
$id = (yield $this->client->getId($getIdParams));
|
||||
$result = (yield $this->client->getCredentialsForIdentity([
|
||||
'IdentityId' => $id['IdentityId'],
|
||||
] + $params));
|
||||
|
||||
yield new Credentials(
|
||||
$result['Credentials']['AccessKeyId'],
|
||||
$result['Credentials']['SecretKey'],
|
||||
$result['Credentials']['SessionToken'],
|
||||
(int) $result['Credentials']['Expiration']->format('U')
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
public function updateLogin($key, $value)
|
||||
{
|
||||
$this->logins[$key] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue