| @@ -13,8 +13,9 @@ | ||
| 13 | 13 | private $secret; |
| 14 | 14 | private $token; |
| 15 | 15 | private $expires; |
| 16 | 16 | private $accountId; |
| 17 | + private $source; | |
| 17 | 18 | /** |
| 18 | 19 | * Constructs a new BasicAWSCredentials object, with the specified AWS |
| 19 | 20 | * access key and AWS secret key |
| 20 | 21 | * |
| @@ -22,9 +23,9 @@ | ||
| 22 | 23 | * @param string $secret AWS secret access key |
| 23 | 24 | * @param string $token Security token to use |
| 24 | 25 | * @param int $expires UNIX timestamp for when credentials expire |
| 25 | 26 | */ |
| 26 | - public function __construct($key, $secret, $token = null, $expires = null, $accountId = null) | |
| 27 | + public function __construct($key, $secret, $token = null, $expires = null, $accountId = null, $source = CredentialSources::STATIC) | |
| 27 | 28 | { |
| 28 | 29 | $this->key = \trim((string) $key); |
| 29 | 30 | $this->secret = \trim((string) $secret); |
| 30 | 31 | $this->token = $token; |
| @@ -29,12 +30,13 @@ | ||
| 29 | 30 | $this->secret = \trim((string) $secret); |
| 30 | 31 | $this->token = $token; |
| 31 | 32 | $this->expires = $expires; |
| 32 | 33 | $this->accountId = $accountId; |
| 34 | + $this->source = $source ?? CredentialSources::STATIC; | |
| 33 | 35 | } |
| 34 | 36 | public static function __set_state(array $state) |
| 35 | 37 | { |
| 36 | - return new self($state['key'], $state['secret'], $state['token'], $state['expires'], $state['accountId']); | |
| 38 | + return new self($state['key'], $state['secret'], $state['token'], $state['expires'], $state['accountId'], $state['source'] ?? null); | |
| 37 | 39 | } |
| 38 | 40 | public function getAccessKeyId() |
| 39 | 41 | { |
| 40 | 42 | return $this->key; |
| @@ -58,11 +60,15 @@ | ||
| 58 | 60 | public function getAccountId() |
| 59 | 61 | { |
| 60 | 62 | return $this->accountId; |
| 61 | 63 | } |
| 64 | + public function getSource() | |
| 65 | + { | |
| 66 | + return $this->source; | |
| 67 | + } | |
| 62 | 68 | public function toArray() |
| 63 | 69 | { |
| 64 | - return ['key' => $this->key, 'secret' => $this->secret, 'token' => $this->token, 'expires' => $this->expires, 'accountId' => $this->accountId]; | |
| 70 | + return ['key' => $this->key, 'secret' => $this->secret, 'token' => $this->token, 'expires' => $this->expires, 'accountId' => $this->accountId, 'source' => $this->source]; | |
| 65 | 71 | } |
| 66 | 72 | public function serialize() |
| 67 | 73 | { |
| 68 | 74 | return \json_encode($this->__serialize()); |
| @@ -81,9 +87,10 @@ | ||
| 81 | 87 | $this->key = $data['key']; |
| 82 | 88 | $this->secret = $data['secret']; |
| 83 | 89 | $this->token = $data['token']; |
| 84 | 90 | $this->expires = $data['expires']; |
| 85 | - $this->accountId = $data['accountId']; | |
| 91 | + $this->accountId = $data['accountId'] ?? null; | |
| 92 | + $this->source = $data['source'] ?? null; | |
| 86 | 93 | } |
| 87 | 94 | /** |
| 88 | 95 | * Internal-only. Used when IMDS is unreachable |
| 89 | 96 | * or returns expires credentials. |