diff options
Diffstat (limited to 'vendor/aws/aws-sdk-php/src/Token')
-rw-r--r-- | vendor/aws/aws-sdk-php/src/Token/ParsesIniTrait.php | 12 | ||||
-rw-r--r-- | vendor/aws/aws-sdk-php/src/Token/SsoTokenProvider.php | 20 |
2 files changed, 14 insertions, 18 deletions
diff --git a/vendor/aws/aws-sdk-php/src/Token/ParsesIniTrait.php b/vendor/aws/aws-sdk-php/src/Token/ParsesIniTrait.php index 64afdb5..b96a6d9 100644 --- a/vendor/aws/aws-sdk-php/src/Token/ParsesIniTrait.php +++ b/vendor/aws/aws-sdk-php/src/Token/ParsesIniTrait.php @@ -9,15 +9,15 @@ trait ParsesIniTrait private static function loadProfiles($filename) { $profileData = \Aws\parse_ini_file($filename, true, INI_SCANNER_RAW); - $configFilename = self::getHomeDir() . '/.aws/config'; - $configProfileData = \Aws\parse_ini_file($configFilename, true, INI_SCANNER_RAW); - foreach ($configProfileData as $name => $profile) { + if (is_readable($configFilename)) { + $configProfiles = \Aws\parse_ini_file($configFilename, true, INI_SCANNER_RAW); + $profileData = array_merge($configProfiles, $profileData); + } + foreach ($profileData as $name => $profile) { // standardize config profile names $name = str_replace('profile ', '', $name); - if (!isset($profileData[$name])) { - $profileData[$name] = $profile; - } + $profileData[$name] = $profile; } return $profileData; 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; |