summaryrefslogtreecommitdiff
path: root/vendor/aws/aws-sdk-php/src/Token/SsoTokenProvider.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/aws/aws-sdk-php/src/Token/SsoTokenProvider.php')
-rw-r--r--vendor/aws/aws-sdk-php/src/Token/SsoTokenProvider.php20
1 files changed, 8 insertions, 12 deletions
diff --git a/vendor/aws/aws-sdk-php/src/Token/SsoTokenProvider.php b/vendor/aws/aws-sdk-php/src/Token/SsoTokenProvider.php
index 7d8f4b4..83a0e2c 100644
--- a/vendor/aws/aws-sdk-php/src/Token/SsoTokenProvider.php
+++ b/vendor/aws/aws-sdk-php/src/Token/SsoTokenProvider.php
@@ -18,11 +18,9 @@ class SsoTokenProvider implements RefreshableTokenProviderInterface
private $ssoOidcClient;
/**
- * Constructs a new SSO token object, with the specified AWS
- * token
- *
- * @param string $token Security token to use
- * @param int $expires UNIX timestamp for when the token expires
+ * Constructs a new SsoTokenProvider object, which will fetch a token from an authenticated SSO profile
+ * @param string $ssoProfileName The name of the profile that contains the sso_session key
+ * @param int $filename Name of the config file to sso profile from
*/
public function __construct($ssoProfileName, $filename = null, $ssoOidcClient = null) {
$profileName = getenv(self::ENV_PROFILE) ?: 'default';
@@ -42,7 +40,7 @@ class SsoTokenProvider implements RefreshableTokenProviderInterface
{
return Promise\Coroutine::of(function () {
if (!@is_readable($this->filename)) {
- throw new TokenException("Cannot read token from $this->filename");
+ throw new TokenException("Cannot read profiles from $this->filename");
}
$profiles = self::loadProfiles($this->filename);
if (!isset($profiles[$this->ssoProfileName])) {
@@ -160,7 +158,7 @@ class SsoTokenProvider implements RefreshableTokenProviderInterface
{
return self::getHomeDir()
. '/.aws/sso/cache/'
- . utf8_encode(sha1($sso_session))
+ . mb_convert_encoding(sha1($sso_session), "UTF-8")
. ".json";
}
@@ -186,12 +184,10 @@ class SsoTokenProvider implements RefreshableTokenProviderInterface
);
}
- try {
- $expiration = strtotime($tokenData['expiresAt']);
- } catch (\Exception $e) {
+ $expiration = strtotime($tokenData['expiresAt']);
+ if ($expiration === false) {
throw new TokenException("Cached SSO token returned an invalid expiration");
- }
- if ($expiration > time()) {
+ } elseif ($expiration < time()) {
throw new TokenException("Cached SSO token returned an expired token");
}
return $tokenData;