Fixed bug that decoded sts token failed when optional header SecurityToken is empty. (#1415)

This commit is contained in:
Abel 2020-03-13 08:53:16 +08:00 committed by GitHub
parent 9a54586dd4
commit 6cd7c860f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 9 deletions

View File

@ -8,6 +8,7 @@
- [#1405](https://github.com/hyperf/hyperf/pull/1405) Fixed attributes are not right, when the model has property `hidden`.
- [#1410](https://github.com/hyperf/hyperf/pull/1410) Fixed tracer cannot trace the call chains of redis connection that created by `Hyperf\Redis\RedisFactory`.
- [#1415](https://github.com/hyperf/hyperf/pull/1415) Fixed bug that decoded sts token failed when optional header `SecurityToken` is empty.
# v1.1.19 - 2020-03-05

View File

@ -54,9 +54,6 @@ class Client implements ClientInterface
public function __construct(ContainerInterface $container)
{
/**
* @var GuzzleClientFactory $clientFactory
*/
$clientFactory = $container->get(GuzzleClientFactory::class);
$this->client = $clientFactory->create();
$this->config = $container->get(ConfigInterface::class);
@ -78,13 +75,15 @@ class Client implements ClientInterface
$accessKey = $this->config->get('aliyun_acm.access_key', '');
$secretKey = $this->config->get('aliyun_acm.secret_key', '');
$ecsRamRole = (string) $this->config->get('aliyun_acm.ecs_ram_role', '');
$securityToken = null;
$securityToken = [];
if (empty($accessKey) && ! empty($ecsRamRole)) {
$securityCredentials = $this->getSecurityCredentialsWithEcsRamRole($ecsRamRole);
if (! empty($securityCredentials)) {
$accessKey = $securityCredentials['AccessKeyId'];
$secretKey = $securityCredentials['AccessKeySecret'];
$securityToken = $securityCredentials['SecurityToken'];
$securityToken = [
'Spas-SecurityToken' => $securityCredentials['SecurityToken'],
];
}
}
@ -105,13 +104,12 @@ class Client implements ClientInterface
// Get config
$response = $client->get("http://{$server}:8080/diamond-server/config.co", [
'headers' => [
'headers' => array_merge([
'Spas-AccessKey' => $accessKey,
'timeStamp' => $timestamp,
'Spas-Signature' => $sign,
'Spas-SecurityToken' => $securityToken ?? '',
'Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8',
],
], $securityToken),
'query' => [
'tenant' => $namespace,
'dataId' => $dataId,

View File

@ -17,8 +17,8 @@ use Hyperf\ConfigAliyunAcm\PipeMessage;
use Hyperf\Contract\ConfigInterface;
use Hyperf\Contract\StdoutLoggerInterface;
use Hyperf\Event\Contract\ListenerInterface;
use Hyperf\Process\Event\PipeMessage as UserProcessPipeMessage;
use Hyperf\Framework\Event\OnPipeMessage;
use Hyperf\Process\Event\PipeMessage as UserProcessPipeMessage;
class OnPipeMessageListener implements ListenerInterface
{