处理 vendor 依赖错误问题
This commit is contained in:
93
Server/application/common/view/tpl/dispatch_jump.tpl
Normal file
93
Server/application/common/view/tpl/dispatch_jump.tpl
Normal file
@@ -0,0 +1,93 @@
|
||||
{__NOLAYOUT__}<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>跳转提示</title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
background-color: #fff;
|
||||
font-family: "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
line-height: 20px;
|
||||
color: #333333;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.system-message {
|
||||
padding: 24px 48px;
|
||||
margin: 100px auto;
|
||||
max-width: 600px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.system-message h1 {
|
||||
font-size: 36px;
|
||||
line-height: 40px;
|
||||
margin-bottom: 12px;
|
||||
font-weight: 200;
|
||||
text-align: center;
|
||||
}
|
||||
.system-message .success, .system-message .error {
|
||||
line-height: 1.8em;
|
||||
font-size: 16px;
|
||||
text-align: center;
|
||||
}
|
||||
.system-message .detail {
|
||||
font-size: 12px;
|
||||
line-height: 20px;
|
||||
margin-top: 12px;
|
||||
text-align: center;
|
||||
}
|
||||
.system-message .jump {
|
||||
text-align: center;
|
||||
padding-top: 10px;
|
||||
}
|
||||
.system-message .success {
|
||||
color: #27ae60;
|
||||
}
|
||||
.system-message .error {
|
||||
color: #e74c3c;
|
||||
}
|
||||
.system-message .jump a {
|
||||
color: #333;
|
||||
text-decoration: none;
|
||||
}
|
||||
.system-message .jump a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="system-message">
|
||||
<?php switch ($code) {?>
|
||||
<?php case 1:?>
|
||||
<h1>:)</h1>
|
||||
<p class="success"><?php echo(strip_tags($msg));?></p>
|
||||
<?php break;?>
|
||||
<?php case 0:?>
|
||||
<h1>:(</h1>
|
||||
<p class="error"><?php echo(strip_tags($msg));?></p>
|
||||
<?php break;?>
|
||||
<?php } ?>
|
||||
<p class="detail"></p>
|
||||
<p class="jump">
|
||||
页面自动 <a id="href" href="<?php echo($url);?>">跳转</a> 等待时间: <b id="wait"><?php echo($wait);?></b>
|
||||
</p>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
(function(){
|
||||
var wait = document.getElementById('wait'),
|
||||
href = document.getElementById('href').href;
|
||||
var interval = setInterval(function(){
|
||||
var time = --wait.innerHTML;
|
||||
if(time <= 0) {
|
||||
location.href = href;
|
||||
clearInterval(interval);
|
||||
}
|
||||
}, 1000);
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -29,25 +29,14 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
|
||||
*/
|
||||
protected $items = [];
|
||||
|
||||
|
||||
/**
|
||||
* The delimiter (alternative to a '.') to be used.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $delimiter = '.';
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Dot instance
|
||||
*
|
||||
* @param mixed $items
|
||||
* @param string $delimiter
|
||||
*/
|
||||
public function __construct($items = [], $delimiter = '.')
|
||||
public function __construct($items = [])
|
||||
{
|
||||
$this->items = $this->getArrayItems($items);
|
||||
$this->delimiter = strlen($delimiter) ? $delimiter : '.';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,7 +104,7 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
|
||||
}
|
||||
|
||||
$items = &$this->items;
|
||||
$segments = explode($this->delimiter, $key);
|
||||
$segments = explode('.', $key);
|
||||
$lastSegment = array_pop($segments);
|
||||
|
||||
foreach ($segments as $segment) {
|
||||
@@ -159,10 +148,6 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
|
||||
$items = $this->items;
|
||||
}
|
||||
|
||||
if (!func_num_args()) {
|
||||
$delimiter = $this->delimiter;
|
||||
}
|
||||
|
||||
foreach ($items as $key => $value) {
|
||||
if (is_array($value) && !empty($value)) {
|
||||
$flatten = array_merge(
|
||||
@@ -194,13 +179,13 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
|
||||
return $this->items[$key];
|
||||
}
|
||||
|
||||
if (strpos($key, $this->delimiter) === false) {
|
||||
if (strpos($key, '.') === false) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
$items = $this->items;
|
||||
|
||||
foreach (explode($this->delimiter, $key) as $segment) {
|
||||
foreach (explode('.', $key) as $segment) {
|
||||
if (!is_array($items) || !$this->exists($items, $segment)) {
|
||||
return $default;
|
||||
}
|
||||
@@ -249,7 +234,7 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (explode($this->delimiter, $key) as $segment) {
|
||||
foreach (explode('.', $key) as $segment) {
|
||||
if (!is_array($items) || !$this->exists($items, $segment)) {
|
||||
return false;
|
||||
}
|
||||
@@ -461,7 +446,7 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
|
||||
|
||||
$items = &$this->items;
|
||||
|
||||
foreach (explode($this->delimiter, $keys) as $key) {
|
||||
foreach (explode('.', $keys) as $key) {
|
||||
if (!isset($items[$key]) || !is_array($items[$key])) {
|
||||
$items[$key] = [];
|
||||
}
|
||||
@@ -615,7 +600,6 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return $this->items;
|
||||
|
||||
@@ -11,14 +11,13 @@ use Adbar\Dot;
|
||||
|
||||
if (! function_exists('dot')) {
|
||||
/**
|
||||
* Create a new Dot object with the given items and optional delimiter
|
||||
* Create a new Dot object with the given items
|
||||
*
|
||||
* @param mixed $items
|
||||
* @param string $delimiter
|
||||
* @param mixed $items
|
||||
* @return \Adbar\Dot
|
||||
*/
|
||||
function dot($items, $delimiter = '.')
|
||||
function dot($items)
|
||||
{
|
||||
return new Dot($items, $delimiter);
|
||||
return new Dot($items);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 1.2.0 - 2024-10-17
|
||||
|
||||
- Refactor all credentials providers.
|
||||
|
||||
## 1.1.3 - 2020-12-24
|
||||
|
||||
- Require guzzle ^6.3|^7.0
|
||||
|
||||
@@ -1,57 +1,41 @@
|
||||
[English](/README.md) | 简体中文
|
||||
|
||||

|
||||
|
||||
# Alibaba Cloud Credentials for PHP
|
||||
|
||||
[](https://github.com/aliyun/credentials-php/actions/workflows/ci.yml)
|
||||
[](https://codecov.io/gh/aliyun/credentials-php)
|
||||
[](https://packagist.org/packages/alibabacloud/credentials)
|
||||
[](https://packagist.org/packages/alibabacloud/credentials)
|
||||
[](https://packagist.org/packages/alibabacloud/credentials)
|
||||
[](https://packagist.org/packages/alibabacloud/credentials)
|
||||
[](https://codecov.io/gh/aliyun/credentials-php)
|
||||
[](https://travis-ci.org/aliyun/credentials-php)
|
||||
[](https://ci.appveyor.com/project/aliyun/credentials-php)
|
||||
|
||||
|
||||

|
||||
|
||||
|
||||
Alibaba Cloud Credentials for PHP 是帮助 PHP 开发者管理凭据的工具。
|
||||
|
||||
## 先决条件
|
||||
|
||||
## 先决条件
|
||||
您的系统需要满足[先决条件](/docs/zh-CN/0-Prerequisites.md),包括 PHP> = 5.6。 我们强烈建议使用cURL扩展,并使用TLS后端编译cURL 7.16.2+。
|
||||
|
||||
|
||||
## 安装依赖
|
||||
|
||||
如果已在系统上[全局安装 Composer](https://getcomposer.org/doc/00-intro.md#globally),请直接在项目目录中运行以下内容来安装 Alibaba Cloud Credentials for PHP 作为依赖项:
|
||||
|
||||
```sh
|
||||
```
|
||||
composer require alibabacloud/credentials
|
||||
```
|
||||
|
||||
> 一些用户可能由于网络问题无法安装,可以使用[阿里云 Composer 全量镜像](https://developer.aliyun.com/composer)。
|
||||
|
||||
请看[安装](/docs/zh-CN/1-Installation.md)有关通过 Composer 和其他方式安装的详细信息。
|
||||
|
||||
## 快速使用
|
||||
|
||||
## 快速使用
|
||||
在您开始之前,您需要注册阿里云帐户并获取您的[凭证](https://usercenter.console.aliyun.com/#/manage/ak)。
|
||||
|
||||
### 凭证类型
|
||||
|
||||
#### 使用默认凭据链
|
||||
当您在初始化凭据客户端不传入任何参数时,Credentials工具会使用默认凭据链方式初始化客户端。默认凭据的读取逻辑请参见[默认凭据链](#默认凭证提供程序链)。
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
|
||||
// Chain Provider if no Parameter
|
||||
$client = new Credential();
|
||||
|
||||
$credential = $client->getCredential();
|
||||
$credential->getAccessKeyId();
|
||||
$credential->getAccessKeySecret();
|
||||
$credential->getSecurityToken();
|
||||
```
|
||||
|
||||
#### AccessKey
|
||||
|
||||
通过[用户信息管理][ak]设置 access_key,它们具有该账户完全的权限,请妥善保管。有时出于安全考虑,您不能把具有完全访问权限的主账户 AccessKey 交于一个项目的开发者使用,您可以[创建RAM子账户][ram]并为子账户[授权][permissions],使用RAM子用户的 AccessKey 来进行API调用。
|
||||
@@ -60,19 +44,20 @@ $credential->getSecurityToken();
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
use AlibabaCloud\Credentials\Credential\Config;
|
||||
|
||||
// Access Key
|
||||
$config = new Config([
|
||||
'type' => 'access_key',
|
||||
'accessKeyId' => '<access_key_id>',
|
||||
'accessKeySecret' => '<access_key_secret>',
|
||||
]);
|
||||
$client = new Credential($config);
|
||||
|
||||
$credential = $client->getCredential();
|
||||
// Chain Provider if no Parameter
|
||||
$credential = new Credential();
|
||||
$credential->getAccessKeyId();
|
||||
$credential->getAccessKeySecret();
|
||||
|
||||
// Access Key
|
||||
$ak = new Credential([
|
||||
'type' => 'access_key',
|
||||
'access_key_id' => '<access_key_id>',
|
||||
'access_key_secret' => '<access_key_secret>',
|
||||
]);
|
||||
$ak->getAccessKeyId();
|
||||
$ak->getAccessKeySecret();
|
||||
```
|
||||
|
||||
#### STS
|
||||
@@ -83,256 +68,102 @@ $credential->getAccessKeySecret();
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
use AlibabaCloud\Credentials\Credential\Config;
|
||||
|
||||
$config = new Config([
|
||||
'type' => 'sts',
|
||||
'accessKeyId' => '<access_key_id>',
|
||||
'accessKeySecret' => '<access_key_secret>',
|
||||
'securityToken' => '<security_token>',
|
||||
$sts = new Credential([
|
||||
'type' => 'sts',
|
||||
'access_key_id' => '<access_key_id>',
|
||||
'accessKey_secret' => '<accessKey_secret>',
|
||||
'security_token' => '<security_token>',
|
||||
]);
|
||||
$client = new Credential($config);
|
||||
|
||||
$credential = $client->getCredential();
|
||||
$credential->getAccessKeyId();
|
||||
$credential->getAccessKeySecret();
|
||||
$credential->getSecurityToken();
|
||||
$sts->getAccessKeyId();
|
||||
$sts->getAccessKeySecret();
|
||||
$sts->getSecurityToken();
|
||||
```
|
||||
|
||||
#### RamRoleArn
|
||||
|
||||
通过指定RAM角色的ARN(Alibabacloud Resource Name),Credentials工具可以帮助开发者前往STS换取STS Token。您也可以通过为 `Policy` 赋值来限制RAM角色到一个更小的权限集合。
|
||||
通过指定[RAM角色][RAM Role],让凭证自动申请维护 STS Token。你可以通过为 `Policy` 赋值来限制获取到的 STS Token 的权限。
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
use AlibabaCloud\Credentials\Credential\Config;
|
||||
|
||||
$config = new Config([
|
||||
'type' => 'ram_role_arn',
|
||||
'accessKeyId' => '<access_key_id>',
|
||||
'accessKeySecret' => '<access_key_secret>',
|
||||
// 要扮演的RAM角色ARN,示例值:acs:ram::123456789012****:role/adminrole,可以通过环境变量ALIBABA_CLOUD_ROLE_ARN设置role_arn
|
||||
'roleArn' => '<role_arn>',
|
||||
// 角色会话名称,可以通过环境变量ALIBABA_CLOUD_ROLE_SESSION_NAME设置role_session_name
|
||||
'roleSessionName' => '<role_session_name>',
|
||||
// 设置更小的权限策略,非必填。示例值:{"Statement": [{"Action": ["*"],"Effect": "Allow","Resource": ["*"]}],"Version":"1"}
|
||||
'policy' => '',
|
||||
// 设置session过期时间,非必填。
|
||||
'roleSessionExpiration' => 3600,
|
||||
$ramRoleArn = new Credential([
|
||||
'type' => 'ram_role_arn',
|
||||
'access_key_id' => '<access_key_id>',
|
||||
'access_key_secret' => '<access_key_secret>',
|
||||
'role_arn' => '<role_arn>',
|
||||
'role_session_name' => '<role_session_name>',
|
||||
'policy' => '',
|
||||
]);
|
||||
$client = new Credential($config);
|
||||
|
||||
$credential = $client->getCredential();
|
||||
$credential->getAccessKeyId();
|
||||
$credential->getAccessKeySecret();
|
||||
$credential->getSecurityToken();
|
||||
$ramRoleArn->getAccessKeyId();
|
||||
$ramRoleArn->getAccessKeySecret();
|
||||
$ramRoleArn->getRoleArn();
|
||||
$ramRoleArn->getRoleSessionName();
|
||||
$ramRoleArn->getPolicy();
|
||||
```
|
||||
|
||||
#### EcsRamRole
|
||||
|
||||
ECS和ECI实例均支持绑定实例RAM角色,当在实例中使用Credentials工具时,将自动获取实例绑定的RAM角色,并通过访问元数据服务获取RAM角色的STS Token,以完成凭据客户端的初始化。
|
||||
|
||||
实例元数据服务器支持加固模式和普通模式两种访问方式,Credentials工具默认使用加固模式(IMDSv2)获取访问凭据。若使用加固模式时发生异常,您可以通过设置disableIMDSv1来执行不同的异常处理逻辑:
|
||||
|
||||
- 当值为false(默认值)时,会使用普通模式继续获取访问凭据。
|
||||
|
||||
- 当值为true时,表示只能使用加固模式获取访问凭据,会抛出异常。
|
||||
|
||||
服务端是否支持IMDSv2,取决于您在服务器的配置。
|
||||
通过指定角色名称,让凭证自动申请维护 STS Token
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
use AlibabaCloud\Credentials\Credential\Config;
|
||||
|
||||
$config = new Config([
|
||||
'type' => 'ecs_ram_role',
|
||||
// 选填,该ECS角色的角色名称,不填会自动获取,但是建议加上以减少请求次数,可以通过环境变量ALIBABA_CLOUD_ECS_METADATA设置role_name
|
||||
'roleName' => '<role_name>',
|
||||
// 选填,是否强制关闭IMDSv1,即必须使用IMDSv2加固模式,可以通过环境变量ALIBABA_CLOUD_IMDSV1_DISABLED设置
|
||||
'disableIMDSv1' => true,
|
||||
$ecsRamRole = new Credential([
|
||||
'type' => 'ecs_ram_role',
|
||||
'role_name' => '<role_name>',
|
||||
]);
|
||||
$client = new Credential($config);
|
||||
|
||||
$credential = $client->getCredential();
|
||||
$credential->getAccessKeyId();
|
||||
$credential->getAccessKeySecret();
|
||||
$credential->getSecurityToken();
|
||||
$ecsRamRole->getRoleName();
|
||||
// Note: `role_name` is optional. It will be retrieved automatically if not set. It is highly recommended to set it up to reduce requests.
|
||||
```
|
||||
|
||||
#### OIDCRoleArn
|
||||
#### RsaKeyPair
|
||||
|
||||
在容器服务 Kubernetes 版中设置了Worker节点RAM角色后,对应节点内的Pod中的应用也就可以像ECS上部署的应用一样,通过元数据服务(Meta Data Server)获取关联角色的STS Token。但如果容器集群上部署的是不可信的应用(比如部署您的客户提交的应用,代码也没有对您开放),您可能并不希望它们能通过元数据服务获取Worker节点关联实例RAM角色的STS Token。为了避免影响云上资源的安全,同时又能让这些不可信的应用安全地获取所需的 STS Token,实现应用级别的权限最小化,您可以使用RRSA(RAM Roles for Service Account)功能。阿里云容器集群会为不同的应用Pod创建和挂载相应的服务账户OIDC Token文件,并将相关配置信息注入到环境变量中,Credentials工具通过获取环境变量的配置信息,调用STS服务的AssumeRoleWithOIDC - OIDC角色SSO时获取扮演角色的临时身份凭证接口换取绑定角色的STS Token。详情请参见[通过RRSA配置ServiceAccount的RAM权限实现Pod权限隔离](https://help.aliyun.com/zh/ack/ack-managed-and-ack-dedicated/user-guide/use-rrsa-to-authorize-pods-to-access-different-cloud-services#task-2142941)。
|
||||
通过指定公钥Id和私钥文件,让凭证自动申请维护 AccessKey。仅支持日本站。
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
use AlibabaCloud\Credentials\Credential\Config;
|
||||
|
||||
$config = new Config([
|
||||
'type' => 'oidc_role_arn',
|
||||
// OIDC提供商ARN,可以通过环境变量ALIBABA_CLOUD_OIDC_PROVIDER_ARN设置oidc_provider_arn
|
||||
'oidcProviderArn' => '<oidc_provider_arn>',
|
||||
// OIDC Token文件路径,可以通过环境变量ALIBABA_CLOUD_OIDC_TOKEN_FILE设置oidc_token_file_path
|
||||
'oidcTokenFilePath' => '<oidc_token_file_path>',
|
||||
// 要扮演的RAM角色ARN,示例值:acs:ram::123456789012****:role/adminrole,可以通过环境变量ALIBABA_CLOUD_ROLE_ARN设置role_arn
|
||||
'roleArn' => '<role_arn>',
|
||||
// 角色会话名称,可以通过环境变量ALIBABA_CLOUD_ROLE_SESSION_NAME设置role_session_name
|
||||
'roleSessionName' => '<role_session_name>',
|
||||
// 设置更小的权限策略,非必填。示例值:{"Statement": [{"Action": ["*"],"Effect": "Allow","Resource": ["*"]}],"Version":"1"}
|
||||
'policy' => '',
|
||||
# 设置session过期时间
|
||||
'roleSessionExpiration' => 3600,
|
||||
$rsaKeyPair = new Credential([
|
||||
'type' => 'rsa_key_pair',
|
||||
'public_key_id' => '<public_key_id>',
|
||||
'private_key_file' => '<private_key_file>',
|
||||
]);
|
||||
$client = new Credential($config);
|
||||
|
||||
$credential = $client->getCredential();
|
||||
$credential->getAccessKeyId();
|
||||
$credential->getAccessKeySecret();
|
||||
$credential->getSecurityToken();
|
||||
```
|
||||
|
||||
#### Credentials URI
|
||||
|
||||
通过指定提供凭证的自定义网络服务地址,让凭证自动申请维护 STS Token。
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
use AlibabaCloud\Credentials\Credential\Config;
|
||||
|
||||
$config = new Config([
|
||||
'type' => 'credentials_uri',
|
||||
// 凭证的 URI,格式为http://local_or_remote_uri/,可以通过环境变量ALIBABA_CLOUD_CREDENTIALS_URI设置credentials_uri
|
||||
'credentialsURI' => '<credentials_uri>',
|
||||
]);
|
||||
$client = new Credential($config);
|
||||
|
||||
$credential = $client->getCredential();
|
||||
$credential->getAccessKeyId();
|
||||
$credential->getAccessKeySecret();
|
||||
$credential->getSecurityToken();
|
||||
$rsaKeyPair->getPublicKeyId();
|
||||
$rsaKeyPair->getPrivateKey();
|
||||
```
|
||||
|
||||
#### Bearer Token
|
||||
|
||||
目前只有云呼叫中心 CCC 这款产品支持 Bearer Token 的凭据初始化方式。
|
||||
如呼叫中心(CCC)需用此凭证,请自行申请维护 Bearer Token。
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
use AlibabaCloud\Credentials\Credential\Config;
|
||||
|
||||
$config = new Config([
|
||||
'type' => 'bearer',
|
||||
// 填入您的Bearer Token
|
||||
'bearerToken' => '<bearer_token>',
|
||||
$bearerToken = new Credential([
|
||||
'type' => 'bearer_token',
|
||||
'bearer_token' => '<bearer_token>',
|
||||
]);
|
||||
$client = new Credential($config);
|
||||
|
||||
$credential = $client->getCredential();
|
||||
$credential->getBearerToken();
|
||||
$bearerToken->getBearerToken();
|
||||
$bearerToken->getSignature();
|
||||
```
|
||||
|
||||
## 默认凭证提供程序链
|
||||
默认凭证提供程序链查找可用的凭证,寻找顺序如下:
|
||||
|
||||
当您的程序开发环境和生产环境采用不同的凭据类型,常见做法是在代码中获取当前环境信息,编写获取不同凭据的分支代码。借助Credentials工具的默认凭据链,您可以用同一套代码,通过程序之外的配置来控制不同环境下的凭据获取方式。当您在不传入参数的情况下,直接使用$credential = new Credential();初始化凭据客户端时,阿里云SDK将会尝试按照如下顺序查找相关凭据信息。
|
||||
### 1. 环境凭证
|
||||
程序首先会在环境变量里寻找环境凭证,如果定义了 `ALIBABA_CLOUD_ACCESS_KEY_ID` 和 `ALIBABA_CLOUD_ACCESS_KEY_SECRET` 环境变量且不为空,程序将使用他们创建默认凭证。
|
||||
|
||||
### 1. 使用环境变量
|
||||
|
||||
Credentials工具会优先在环境变量中获取凭据信息。
|
||||
|
||||
- 如果系统环境变量 `ALIBABA_CLOUD_ACCESS_KEY_ID`(密钥Key) 和 `ALIBABA_CLOUD_ACCESS_KEY_SECRET`(密钥Value) 不为空,Credentials工具会优先使用它们作为默认凭据。
|
||||
|
||||
- 如果系统环境变量 `ALIBABA_CLOUD_ACCESS_KEY_ID`(密钥Key)、`ALIBABA_CLOUD_ACCESS_KEY_SECRET`(密钥Value)、`ALIBABA_CLOUD_SECURITY_TOKEN`(Token)均不为空,Credentials工具会优先使用STS Token作为默认凭据。
|
||||
|
||||
### 2. 使用OIDC RAM角色
|
||||
若不存在优先级更高的凭据信息,Credentials工具会在环境变量中获取如下内容:
|
||||
|
||||
`ALIBABA_CLOUD_ROLE_ARN`:RAM角色名称ARN;
|
||||
|
||||
`ALIBABA_CLOUD_OIDC_PROVIDER_ARN`:OIDC提供商ARN;
|
||||
|
||||
`ALIBABA_CLOUD_OIDC_TOKEN_FILE`:OIDC Token文件路径;
|
||||
|
||||
若以上三个环境变量都已设置内容,Credentials将会使用变量内容调用STS服务的[AssumeRoleWithOIDC - OIDC角色SSO时获取扮演角色的临时身份凭证](https://help.aliyun.com/zh/ram/developer-reference/api-sts-2015-04-01-assumerolewithoidc)接口换取STS Token作为默认凭据。
|
||||
|
||||
### 3. 使用 Aliyun CLI 工具的 config.json 配置文件
|
||||
|
||||
若不存在优先级更高的凭据信息,Credentials工具会优先在如下位置查找 `config.json` 文件是否存在:
|
||||
Linux系统:`~/.aliyun/config.json`
|
||||
Windows系统: `C:\Users\USER_NAME\.aliyun\config.json`
|
||||
如果文件存在,程序将会使用配置文件中 `current` 指定的凭据信息初始化凭据客户端。当然,您也可以通过环境变量 `ALIBABA_CLOUD_PROFILE` 来指定凭据信息,例如设置 `ALIBABA_CLOUD_PROFILE` 的值为 `AK`。
|
||||
|
||||
在config.json配置文件中每个module的值代表了不同的凭据信息获取方式:
|
||||
|
||||
- AK:使用用户的Access Key作为凭据信息;
|
||||
- RamRoleArn:使用RAM角色的ARN来获取凭据信息;
|
||||
- EcsRamRole:利用ECS绑定的RAM角色来获取凭据信息;
|
||||
- OIDC:通过OIDC ARN和OIDC Token来获取凭据信息;
|
||||
- ChainableRamRoleArn:采用角色链的方式,通过指定JSON文件中的其他凭据,以重新获取新的凭据信息。
|
||||
|
||||
配置示例信息如下:
|
||||
|
||||
```json
|
||||
{
|
||||
"current": "AK",
|
||||
"profiles": [
|
||||
{
|
||||
"name": "AK",
|
||||
"mode": "AK",
|
||||
"access_key_id": "access_key_id",
|
||||
"access_key_secret": "access_key_secret"
|
||||
},
|
||||
{
|
||||
"name": "RamRoleArn",
|
||||
"mode": "RamRoleArn",
|
||||
"access_key_id": "access_key_id",
|
||||
"access_key_secret": "access_key_secret",
|
||||
"ram_role_arn": "ram_role_arn",
|
||||
"ram_session_name": "ram_session_name",
|
||||
"expired_seconds": 3600,
|
||||
"sts_region": "cn-hangzhou"
|
||||
},
|
||||
{
|
||||
"name": "EcsRamRole",
|
||||
"mode": "EcsRamRole",
|
||||
"ram_role_name": "ram_role_name"
|
||||
},
|
||||
{
|
||||
"name": "OIDC",
|
||||
"mode": "OIDC",
|
||||
"ram_role_arn": "ram_role_arn",
|
||||
"oidc_token_file": "path/to/oidc/file",
|
||||
"oidc_provider_arn": "oidc_provider_arn",
|
||||
"ram_session_name": "ram_session_name",
|
||||
"expired_seconds": 3600,
|
||||
"sts_region": "cn-hangzhou"
|
||||
},
|
||||
{
|
||||
"name": "ChainableRamRoleArn",
|
||||
"mode": "ChainableRamRoleArn",
|
||||
"source_profile": "AK",
|
||||
"ram_role_arn": "ram_role_arn",
|
||||
"ram_session_name": "ram_session_name",
|
||||
"expired_seconds": 3600,
|
||||
"sts_region": "cn-hangzhou"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 4. 使用配置文件
|
||||
>
|
||||
> 如果用户主目录存在默认文件 `~/.alibabacloud/credentials` (Windows 为 `C:\Users\USER_NAME\.alibabacloud\credentials`),程序会自动创建指定类型和名称的凭证。您也可通过环境变量 `ALIBABA_CLOUD_CREDENTIALS_FILE` 指定配置文件路径。如果文件存在,程序将会使用配置文件中 default 指定的凭据信息初始化凭据客户端。当然,您也可以通过环境变量 `ALIBABA_CLOUD_PROFILE` 来指定凭据信息,例如设置 `ALIBABA_CLOUD_PROFILE` 的值为 `client1`。
|
||||
|
||||
配置示例信息如下:
|
||||
### 2. 配置文件
|
||||
> 如果用户主目录存在默认文件 `~/.alibabacloud/credentials` (Windows 为 `C:\Users\USER_NAME\.alibabacloud\credentials`),程序会自动创建指定类型和名称的凭证。默认文件可以不存在,但解析错误会抛出异常。 凭证名称不分大小写,若凭证同名,后者会覆盖前者。不同的项目、工具之间可以共用这个配置文件,因为超出项目之外,也不会被意外提交到版本控制。Windows 上可以使用环境变量引用到主目录 %UserProfile%。类 Unix 的系统可以使用环境变量 $HOME 或 ~ (tilde)。 可以通过定义 `ALIBABA_CLOUD_CREDENTIALS_FILE` 环境变量修改默认文件的路径。
|
||||
|
||||
```ini
|
||||
[default]
|
||||
@@ -352,72 +183,68 @@ role_arn = role_arn
|
||||
role_session_name = session_name
|
||||
|
||||
[project3]
|
||||
type=oidc_role_arn # 认证方式为 oidc_role_arn
|
||||
oidc_provider_arn=oidc_provider_arn
|
||||
oidc_token_file_path=oidc_token_file_path
|
||||
role_arn=role_arn
|
||||
role_session_name=session_name
|
||||
type = rsa_key_pair # 认证方式为 rsa_key_pair
|
||||
public_key_id = publicKeyId # Public Key ID
|
||||
private_key_file = /your/pk.pem # Private Key 文件
|
||||
```
|
||||
|
||||
### 5. 使用 ECS 实例RAM角色
|
||||
### 3. 实例 RAM 角色
|
||||
如果定义了环境变量 `ALIBABA_CLOUD_ECS_METADATA` 且不为空,程序会将该环境变量的值作为角色名称,请求 `http://100.100.100.200/latest/meta-data/ram/security-credentials/` 获取临时安全凭证作为默认凭证。
|
||||
|
||||
若不存在优先级更高的凭据信息,Credentials工具将通过环境变量获取ALIBABA_CLOUD_ECS_METADATA(ECS实例RAM角色名称)的值。若该变量的值存在,程序将采用加固模式(IMDSv2)访问ECS的元数据服务(Meta Data Server),以获取ECS实例RAM角色的STS Token作为默认凭据信息。在使用加固模式时若发生异常,将使用普通模式兜底来获取访问凭据。您也可以通过设置环境变量ALIBABA_CLOUD_IMDSV1_DISABLED,执行不同的异常处理逻辑:
|
||||
### 自定义凭证提供程序链
|
||||
可通过自定义程序链代替默认程序链的寻找顺序,也可以自行编写闭包传入提供者。
|
||||
```php
|
||||
<?php
|
||||
|
||||
- 当值为false时,会使用普通模式继续获取访问凭据。
|
||||
use AlibabaCloud\Credentials\Providers\ChainProvider;
|
||||
|
||||
- 当值为true时,表示只能使用加固模式获取访问凭据,会抛出异常。
|
||||
|
||||
服务端是否支持IMDSv2,取决于您在服务器的配置。
|
||||
|
||||
### 6. 使用外部服务 Credentials URI
|
||||
|
||||
若不存在优先级更高的凭据信息,Credentials工具会在环境变量中获取ALIBABA_CLOUD_CREDENTIALS_URI,若存在,程序将请求该URI地址,获取临时安全凭证作为默认凭据信息。
|
||||
|
||||
外部服务响应结构应如下:
|
||||
|
||||
```json
|
||||
{
|
||||
"Code": "Success",
|
||||
"AccessKeyId": "AccessKeyId",
|
||||
"AccessKeySecret": "AccessKeySecret",
|
||||
"SecurityToken": "SecurityToken",
|
||||
"Expiration": "2024-10-26T03:46:38Z"
|
||||
}
|
||||
ChainProvider::set(
|
||||
ChainProvider::ini(),
|
||||
ChainProvider::env(),
|
||||
ChainProvider::instance()
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
## 文档
|
||||
|
||||
* [先决条件](/docs/zh-CN/0-Prerequisites.md)
|
||||
* [安装](/docs/zh-CN/1-Installation.md)
|
||||
|
||||
## 问题
|
||||
|
||||
## 问题
|
||||
[提交 Issue](https://github.com/aliyun/credentials-php/issues/new/choose),不符合指南的问题可能会立即关闭。
|
||||
|
||||
## 发行说明
|
||||
|
||||
## 发行说明
|
||||
每个版本的详细更改记录在[发行说明](/CHANGELOG.md)中。
|
||||
|
||||
## 贡献
|
||||
|
||||
## 贡献
|
||||
提交 Pull Request 之前请阅读[贡献指南](/CONTRIBUTING.md)。
|
||||
|
||||
## 相关
|
||||
|
||||
## 相关
|
||||
* [OpenAPI 开发者门户][open-api]
|
||||
* [Packagist][packagist]
|
||||
* [Composer][composer]
|
||||
* [Guzzle中文文档][guzzle-docs]
|
||||
* [最新源码][latest-release]
|
||||
|
||||
## 许可证
|
||||
|
||||
## 许可证
|
||||
[Apache-2.0](/LICENSE.md)
|
||||
|
||||
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
|
||||
|
||||
[open-api]: https://api.aliyun.com
|
||||
|
||||
[open-api]: https://next.api.aliyun.com
|
||||
[latest-release]: https://github.com/aliyun/credentials-php
|
||||
[guzzle-docs]: https://guzzle-cn.readthedocs.io/zh_CN/latest/request-options.html
|
||||
[composer]: https://getcomposer.org
|
||||
[packagist]: https://packagist.org/packages/alibabacloud/credentials
|
||||
[home]: https://home.console.aliyun.com
|
||||
[aliyun]: https://www.aliyun.com
|
||||
[cURL]: http://php.net/manual/zh/book.curl.php
|
||||
[OPCache]: http://php.net/manual/zh/book.opcache.php
|
||||
[xdebug]: http://xdebug.org
|
||||
[OpenSSL]: http://php.net/manual/zh/book.openssl.php
|
||||
|
||||
361
Server/vendor/alibabacloud/credentials/README.md
vendored
361
Server/vendor/alibabacloud/credentials/README.md
vendored
@@ -1,59 +1,41 @@
|
||||
English | [简体中文](/README-zh-CN.md)
|
||||
|
||||

|
||||
|
||||
# Alibaba Cloud Credentials for PHP
|
||||
|
||||
[](https://github.com/aliyun/credentials-php/actions/workflows/ci.yml)
|
||||
[](https://codecov.io/gh/aliyun/credentials-php)
|
||||
[](https://packagist.org/packages/alibabacloud/credentials)
|
||||
[](https://packagist.org/packages/alibabacloud/credentials)
|
||||
[](https://packagist.org/packages/alibabacloud/credentials)
|
||||
[](https://packagist.org/packages/alibabacloud/credentials)
|
||||
[](https://codecov.io/gh/aliyun/credentials-php)
|
||||
[](https://travis-ci.org/aliyun/credentials-php)
|
||||
[](https://ci.appveyor.com/project/aliyun/credentials-php)
|
||||
|
||||
|
||||

|
||||
|
||||
|
||||
Alibaba Cloud Credentials for PHP is a tool that helps PHP developers manage their credentials.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
## Prerequisites
|
||||
Your system needs to meet [Prerequisites](/docs/zh-CN/0-Prerequisites.md), including PHP> = 5.6. We strongly recommend using the cURL extension and compiling cURL 7.16.2+ using the TLS backend.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
If you have [Globally Install Composer](https://getcomposer.org/doc/00-intro.md#globally) on your system, install Alibaba Cloud Credentials for PHP as a dependency by running the following directly in the project directory:
|
||||
|
||||
```sh
|
||||
```
|
||||
composer require alibabacloud/credentials
|
||||
```
|
||||
|
||||
> Some users may not be able to install due to network problems, you can switch to the [Alibaba Cloud Composer Mirror](https://developer.aliyun.com/composer).
|
||||
|
||||
See [Installation](/docs/zh-CN/1-Installation.md) for details on installing through Composer and other means.
|
||||
|
||||
## Quick Examples
|
||||
|
||||
## Quick Examples
|
||||
Before you begin, you need to sign up for an Alibaba Cloud account and retrieve your [Credentials](https://usercenter.console.aliyun.com/#/manage/ak).
|
||||
|
||||
### Credential Type
|
||||
|
||||
#### Default credential provider chain
|
||||
|
||||
If you do not specify a method to initialize a Credentials client, the default credential provider chain is used. For more information, see the Default credential provider chain section of this topic.
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
|
||||
// Chain Provider if no Parameter
|
||||
// Do not specify a method to initialize a Credentials client.
|
||||
$client = new Credential();
|
||||
|
||||
$credential = $client->getCredential();
|
||||
$credential->getAccessKeyId();
|
||||
$credential->getAccessKeySecret();
|
||||
$credential->getSecurityToken();
|
||||
```
|
||||
|
||||
#### AccessKey
|
||||
|
||||
Setup access_key credential through [User Information Management][ak], it have full authority over the account, please keep it safe. Sometimes for security reasons, you cannot hand over a primary account AccessKey with full access to the developer of a project. You may create a sub-account [RAM Sub-account][ram] , grant its [authorization][permissions],and use the AccessKey of RAM Sub-account.
|
||||
@@ -62,19 +44,20 @@ Setup access_key credential through [User Information Management][ak], it have f
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
use AlibabaCloud\Credentials\Credential\Config;
|
||||
|
||||
// Access Key
|
||||
$config = new Config([
|
||||
'type' => 'access_key',
|
||||
'accessKeyId' => '<access_key_id>',
|
||||
'accessKeySecret' => '<access_key_secret>',
|
||||
]);
|
||||
$client = new Credential($config);
|
||||
|
||||
$credential = $client->getCredential();
|
||||
// Chain Provider if no Parameter
|
||||
$credential = new Credential();
|
||||
$credential->getAccessKeyId();
|
||||
$credential->getAccessKeySecret();
|
||||
|
||||
// Access Key
|
||||
$ak = new Credential([
|
||||
'type' => 'access_key',
|
||||
'access_key_id' => '<access_key_id>',
|
||||
'access_key_secret' => '<access_key_secret>',
|
||||
]);
|
||||
$ak->getAccessKeyId();
|
||||
$ak->getAccessKeySecret();
|
||||
```
|
||||
|
||||
#### STS
|
||||
@@ -85,20 +68,16 @@ Create a temporary security credential by applying Temporary Security Credential
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
use AlibabaCloud\Credentials\Credential\Config;
|
||||
|
||||
$config = new Config([
|
||||
'type' => 'sts',
|
||||
'accessKeyId' => '<access_key_id>',
|
||||
'accessKeySecret' => '<access_key_secret>',
|
||||
'securityToken' => '<security_token>',
|
||||
$sts = new Credential([
|
||||
'type' => 'sts',
|
||||
'access_key_id' => '<access_key_id>',
|
||||
'accessKey_secret' => '<accessKey_secret>',
|
||||
'security_token' => '<security_token>',
|
||||
]);
|
||||
$client = new Credential($config);
|
||||
|
||||
$credential = $client->getCredential();
|
||||
$credential->getAccessKeyId();
|
||||
$credential->getAccessKeySecret();
|
||||
$credential->getSecurityToken();
|
||||
$sts->getAccessKeyId();
|
||||
$sts->getAccessKeySecret();
|
||||
$sts->getSecurityToken();
|
||||
```
|
||||
|
||||
#### RamRoleArn
|
||||
@@ -109,116 +88,56 @@ By specifying [RAM Role][RAM Role], the credential will be able to automatically
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
use AlibabaCloud\Credentials\Credential\Config;
|
||||
|
||||
$config = new Config([
|
||||
'type' => 'ram_role_arn',
|
||||
'accessKeyId' => '<access_key_id>',
|
||||
'accessKeySecret' => '<access_key_secret>',
|
||||
// Specify the ARN of the RAM role to be assumed. Example: acs:ram::123456789012****:role/adminrole.
|
||||
'roleArn' => '<role_arn>',
|
||||
// Specify the name of the role session.
|
||||
'roleSessionName' => '<role_session_name>',
|
||||
// Optional. Specify limited permissions for the RAM role. Example: {"Statement": [{"Action": ["*"],"Effect": "Allow","Resource": ["*"]}],"Version":"1"}.
|
||||
'policy' => '',
|
||||
// Optional. Specify the expiration of the session
|
||||
'roleSessionExpiration' => 3600,
|
||||
$ramRoleArn = new Credential([
|
||||
'type' => 'ram_role_arn',
|
||||
'access_key_id' => '<access_key_id>',
|
||||
'access_key_secret' => '<access_key_secret>',
|
||||
'role_arn' => '<role_arn>',
|
||||
'role_session_name' => '<role_session_name>',
|
||||
'policy' => '',
|
||||
]);
|
||||
$client = new Credential($config);
|
||||
|
||||
$credential = $client->getCredential();
|
||||
$credential->getAccessKeyId();
|
||||
$credential->getAccessKeySecret();
|
||||
$credential->getSecurityToken();
|
||||
$ramRoleArn->getAccessKeyId();
|
||||
$ramRoleArn->getAccessKeySecret();
|
||||
$ramRoleArn->getRoleArn();
|
||||
$ramRoleArn->getRoleSessionName();
|
||||
$ramRoleArn->getPolicy();
|
||||
```
|
||||
|
||||
#### EcsRamRole
|
||||
|
||||
Both ECS and ECI instances support binding instance RAM roles. When the Credentials tool is used in an instance, the RAM role bound to the instance will be automatically obtained, and the STS Token of the RAM role will be obtained by accessing the metadata service to complete the initialization of the credential client.
|
||||
|
||||
The instance metadata server supports two access modes: hardened mode and normal mode. The Credentials tool uses hardened mode (IMDSv2) by default to obtain access credentials. If an exception occurs when using hardened mode, you can set disableIMDSv1 to perform different exception handling logic:
|
||||
|
||||
- When the value is false (default value), the normal mode will continue to be used to obtain access credentials.
|
||||
|
||||
- When the value is true, it means that only hardened mode can be used to obtain access credentials, and an exception will be thrown.
|
||||
|
||||
Whether the server supports IMDSv2 depends on your configuration on the server.
|
||||
By specifying the role name, the credential will be able to automatically request maintenance of STS Token.
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
use AlibabaCloud\Credentials\Credential\Config;
|
||||
|
||||
$config = new Config([
|
||||
'type' => 'ecs_ram_role',
|
||||
// Optional. Specify the name of the RAM role of the ECS instance. If you do not specify this parameter, its value is automatically obtained. To reduce the number of requests, we recommend that you specify this parameter.
|
||||
'roleName' => '<role_name>',
|
||||
//Optional, whether to forcibly disable IMDSv1, that is, to use IMDSv2 hardening mode, which can be set by the environment variable ALIBABA_CLOUD_IMDSV1_DISABLED
|
||||
'disableIMDSv1' => true,
|
||||
$ecsRamRole = new Credential([
|
||||
'type' => 'ecs_ram_role',
|
||||
'role_name' => '<role_name>',
|
||||
]);
|
||||
$client = new Credential($config);
|
||||
|
||||
$credential = $client->getCredential();
|
||||
$credential->getAccessKeyId();
|
||||
$credential->getAccessKeySecret();
|
||||
$credential->getSecurityToken();
|
||||
$ecsRamRole->getRoleName();
|
||||
// Note: `role_name` is optional. It will be retrieved automatically if not set. It is highly recommended to set it up to reduce requests.
|
||||
```
|
||||
|
||||
#### OIDCRoleArn
|
||||
#### RsaKeyPair
|
||||
|
||||
By specifying the public key Id and the private key file, the credential will be able to automatically request maintenance of the AccessKey before sending the request. Only Japan station is supported.
|
||||
|
||||
After you attach a RAM role to a worker node in an Container Service for Kubernetes, applications in the pods on the worker node can use the metadata server to obtain an STS token the same way in which applications on ECS instances do. However, if an untrusted application is deployed on the worker node, such as an application that is submitted by your customer and whose code is unavailable to you, you may not want the application to use the metadata server to obtain an STS token of the RAM role attached to the worker node. To ensure the security of cloud resources and enable untrusted applications to securely obtain required STS tokens, you can use the RAM Roles for Service Accounts (RRSA) feature to grant minimum necessary permissions to an application. In this case, the ACK cluster creates a service account OpenID Connect (OIDC) token file, associates the token file with a pod, and then injects relevant environment variables into the pod. Then, the Credentials tool uses the environment variables to call the AssumeRoleWithOIDC operation of STS and obtains an STS token of the RAM role. For more information about the RRSA feature, see [Use RRSA to authorize different pods to access different cloud services](https://www.alibabacloud.com/help/en/ack/ack-managed-and-ack-dedicated/user-guide/use-rrsa-to-authorize-pods-to-access-different-cloud-services#task-2142941).
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
use AlibabaCloud\Credentials\Credential\Config;
|
||||
|
||||
$config = new Config([
|
||||
'type' => 'oidc_role_arn',
|
||||
// Specify the ARN of the OIDC IdP by specifying the ALIBABA_CLOUD_OIDC_PROVIDER_ARN environment variable.
|
||||
'oidcProviderArn' => '<oidc_provider_arn>',
|
||||
// Specify the path of the OIDC token file by specifying the ALIBABA_CLOUD_OIDC_TOKEN_FILE environment variable.
|
||||
'oidcTokenFilePath' => '<oidc_token_file_path>',
|
||||
// Specify the ARN of the RAM role by specifying the ALIBABA_CLOUD_ROLE_ARN environment variable.
|
||||
'roleArn' => '<role_arn>',
|
||||
// Specify the role session name by specifying the ALIBABA_CLOUD_ROLE_SESSION_NAME environment variable.
|
||||
'roleSessionName' => '<role_session_name>',
|
||||
// Optional. Specify limited permissions for the RAM role. Example: {"Statement": [{"Action": ["*"],"Effect": "Allow","Resource": ["*"]}],"Version":"1"}.
|
||||
'policy' => '',
|
||||
// Optional. Specify the validity period of the session.
|
||||
'roleSessionExpiration' => 3600,
|
||||
$rsaKeyPair = new Credential([
|
||||
'type' => 'rsa_key_pair',
|
||||
'public_key_id' => '<public_key_id>',
|
||||
'private_key_file' => '<private_key_file>',
|
||||
]);
|
||||
$client = new Credential($config);
|
||||
|
||||
$credential = $client->getCredential();
|
||||
$credential->getAccessKeyId();
|
||||
$credential->getAccessKeySecret();
|
||||
$credential->getSecurityToken();
|
||||
```
|
||||
|
||||
#### Credentials URI
|
||||
|
||||
By specifying the url, the credential will be able to automatically request maintenance of STS Token.
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
use AlibabaCloud\Credentials\Credential\Config;
|
||||
|
||||
$config = new Config([
|
||||
'type' => 'credentials_uri',
|
||||
// Format: http url. `credentialsURI` can be replaced by setting environment variable: ALIBABA_CLOUD_CREDENTIALS_URI
|
||||
'credentialsURI' => '<credentials_uri>',
|
||||
]);
|
||||
$client = new Credential($config);
|
||||
|
||||
$credential = $client->getCredential();
|
||||
$credential->getAccessKeyId();
|
||||
$credential->getAccessKeySecret();
|
||||
$credential->getSecurityToken();
|
||||
$rsaKeyPair->getPublicKeyId();
|
||||
$rsaKeyPair->getPrivateKey();
|
||||
```
|
||||
|
||||
#### Bearer Token
|
||||
@@ -229,110 +148,24 @@ If credential is required by the Cloud Call Centre (CCC), please apply for Beare
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
use AlibabaCloud\Credentials\Credential\Config;
|
||||
|
||||
$config = new Config([
|
||||
'type' => 'bearer',
|
||||
'bearerToken' => '<bearer_token>',
|
||||
$bearerToken = new Credential([
|
||||
'type' => 'bearer_token',
|
||||
'bearer_token' => '<bearer_token>',
|
||||
]);
|
||||
$client = new Credential($config);
|
||||
|
||||
$credential = $client->getCredential();
|
||||
$credential->getBearerToken();
|
||||
$bearerToken->getBearerToken();
|
||||
$bearerToken->getSignature();
|
||||
```
|
||||
|
||||
## Default credential provider chain
|
||||
|
||||
If you want to use different types of credentials in the development and production environments of your application, you generally need to obtain the environment information from the code and write code branches to obtain different credentials for the development and production environments. The default credential provider chain of the Credentials tool allows you to use the same code to obtain credentials for different environments based on configurations independent of the application. If you use $credential = new Credential(); to initialize a Credentials client without specifying an initialization method, the Credentials tool obtains the credential information in the following order:
|
||||
The default credential provider chain looks for available credentials, looking in the following order:
|
||||
|
||||
### 1. Environmental certificate
|
||||
The program first looks for environment credentials in the environment variable. If the `ALIBABA_CLOUD_ACCESS_KEY_ID` and `ALIBABA_CLOUD_ACCESS_KEY_SECRET` environment variables are defined and not empty, the program will use them to create default credentials.
|
||||
|
||||
Look for environment credentials in environment variable.
|
||||
- If the `ALIBABA_CLOUD_ACCESS_KEY_ID` and `ALIBABA_CLOUD_ACCESS_KEY_SECRET` environment variables are defined and are not empty, the program will use them to create default credentials.
|
||||
- If the `ALIBABA_CLOUD_ACCESS_KEY_ID`, `ALIBABA_CLOUD_ACCESS_KEY_SECRET` and `ALIBABA_CLOUD_SECURITY_TOKEN` environment variables are defined and are not empty, the program will use them to create temporary security credentials(STS). Note: This token has an expiration time, it is recommended to use it in a temporary environment.
|
||||
### 2. Configuration file
|
||||
> If the user's home directory has the default file `~/.alibabacloud/credentials` (Windows is `C:\Users\USER_NAME\.alibabacloud\credentials`), the program will automatically create credentials with the specified type and name. The default file may not exist, but parsing errors will throw an exception. The voucher name is not case sensitive. If the voucher has the same name, the latter will overwrite the former. This configuration file can be shared between different projects and tools, and it will not be accidentally submitted to version control because it is outside the project. Environment variables can be referenced to the home directory %UserProfile% on Windows. Unix-like systems can use the environment variable $HOME or ~ (tilde). The path to the default file can be modified by defining the `ALIBABA_CLOUD_CREDENTIALS_FILE` environment variable.
|
||||
|
||||
### 2. The RAM role of an OIDC IdP
|
||||
|
||||
If no credentials are found in the previous step, the Credentials tool obtains the values of the following environment variables:
|
||||
|
||||
`ALIBABA_CLOUD_ROLE_ARN`: the ARN of the RAM role.
|
||||
|
||||
`ALIBABA_CLOUD_OIDC_PROVIDER_ARN`: the ARN of the OIDC IdP.
|
||||
|
||||
`ALIBABA_CLOUD_OIDC_TOKEN_FILE`: the path of the OIDC token file.
|
||||
|
||||
If the preceding three environment variables are specified, the Credentials tool uses the environment variables to call the [AssumeRoleWithOIDC](https://www.alibabacloud.com/help/en/ram/developer-reference/api-sts-2015-04-01-assumerolewithoidc) operation of STS to obtain an STS token as the default credential.
|
||||
|
||||
### 3. Using the config.json Configuration File of Aliyun CLI Tool
|
||||
If there is no higher-priority credential information, the Credentials tool will first check the following locations to see if the config.json file exists:
|
||||
|
||||
Linux system: `~/.aliyun/config.json`
|
||||
Windows system: `C:\Users\USER_NAME\.aliyun\config.json`
|
||||
If the file exists, the program will use the credential information specified by `current` in the configuration file to initialize the credentials client. Of course, you can also use the environment variable `ALIBABA_CLOUD_PROFILE` to specify the credential information, for example by setting the value of `ALIBABA_CLOUD_PROFILE` to `AK`.
|
||||
|
||||
In the config.json configuration file, the value of each module represents different ways to obtain credential information:
|
||||
|
||||
- AK: Use the Access Key of the user as credential information;
|
||||
- RamRoleArn: Use the ARN of the RAM role to obtain credential information;
|
||||
- EcsRamRole: Use the RAM role bound to the ECS to obtain credential information;
|
||||
- OIDC: Obtain credential information through OIDC ARN and OIDC Token;
|
||||
- ChainableRamRoleArn: Use the role chaining method to obtain new credential information by specifying other credentials in the JSON file.
|
||||
|
||||
The configuration example information is as follows:
|
||||
|
||||
```json
|
||||
{
|
||||
"current": "AK",
|
||||
"profiles": [
|
||||
{
|
||||
"name": "AK",
|
||||
"mode": "AK",
|
||||
"access_key_id": "access_key_id",
|
||||
"access_key_secret": "access_key_secret"
|
||||
},
|
||||
{
|
||||
"name": "RamRoleArn",
|
||||
"mode": "RamRoleArn",
|
||||
"access_key_id": "access_key_id",
|
||||
"access_key_secret": "access_key_secret",
|
||||
"ram_role_arn": "ram_role_arn",
|
||||
"ram_session_name": "ram_session_name",
|
||||
"expired_seconds": 3600,
|
||||
"sts_region": "cn-hangzhou"
|
||||
},
|
||||
{
|
||||
"name": "EcsRamRole",
|
||||
"mode": "EcsRamRole",
|
||||
"ram_role_name": "ram_role_name"
|
||||
},
|
||||
{
|
||||
"name": "OIDC",
|
||||
"mode": "OIDC",
|
||||
"ram_role_arn": "ram_role_arn",
|
||||
"oidc_token_file": "path/to/oidc/file",
|
||||
"oidc_provider_arn": "oidc_provider_arn",
|
||||
"ram_session_name": "ram_session_name",
|
||||
"expired_seconds": 3600,
|
||||
"sts_region": "cn-hangzhou"
|
||||
},
|
||||
{
|
||||
"name": "ChainableRamRoleArn",
|
||||
"mode": "ChainableRamRoleArn",
|
||||
"source_profile": "AK",
|
||||
"ram_role_arn": "ram_role_arn",
|
||||
"ram_session_name": "ram_session_name",
|
||||
"expired_seconds": 3600,
|
||||
"sts_region": "cn-hangzhou"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 4. Configuration file
|
||||
>
|
||||
> If the user's home directory has the default file `~/.alibabacloud/credentials` (Windows is `C:\Users\USER_NAME\.alibabacloud\credentials`), the program will automatically create credentials with the specified type and name. You can also specify the configuration file path by configuring the `ALIBABA_CLOUD_CREDENTIALS_FILE` environment variable. If the configuration file exists, the application initializes a Credentials client by using the credential information that is specified by default in the configuration file. You can also configure the `ALIBABA_CLOUD_PROFILE` environment variable to modify the default credential information that is read.
|
||||
|
||||
Configuration example:
|
||||
```ini
|
||||
[default]
|
||||
type = access_key # Authentication method is access_key
|
||||
@@ -351,72 +184,68 @@ role_arn = role_arn
|
||||
role_session_name = session_name
|
||||
|
||||
[project3]
|
||||
type=oidc_role_arn # Authentication method is oidc_role_arn
|
||||
oidc_provider_arn=oidc_provider_arn
|
||||
oidc_token_file_path=oidc_token_file_path
|
||||
role_arn=role_arn
|
||||
role_session_name=session_name
|
||||
type = rsa_key_pair # Authentication method is rsa_key_pair
|
||||
public_key_id = publicKeyId # Public Key ID
|
||||
private_key_file = /your/pk.pem # Private Key File
|
||||
```
|
||||
|
||||
### 5. Instance RAM role
|
||||
### 3. Instance RAM role
|
||||
If the environment variable `ALIBABA_CLOUD_ECS_METADATA` is defined and not empty, the program will take the value of the environment variable as the role name and request `http://100.100.100.200/latest/meta-data/ram/security-credentials/` to get the temporary Security credentials are used as default credentials.
|
||||
|
||||
If there is no credential information with a higher priority, the Credentials tool will obtain the value of ALIBABA_CLOUD_ECS_METADATA (ECS instance RAM role name) through the environment variable. If the value of this variable exists, the program will use the hardened mode (IMDSv2) to access the metadata service (Meta Data Server) of ECS to obtain the STS Token of the ECS instance RAM role as the default credential information. If an exception occurs when using the hardened mode, the normal mode will be used as a fallback to obtain access credentials. You can also set the environment variable ALIBABA_CLOUD_IMDSV1_DISABLED to perform different exception handling logic:
|
||||
### Custom credential provider chain
|
||||
You can replace the default order of the program chain by customizing the program chain, or you can write the closure to the provider.
|
||||
```php
|
||||
<?php
|
||||
|
||||
- When the value is false, the normal mode will continue to obtain access credentials.
|
||||
use AlibabaCloud\Credentials\Providers\ChainProvider;
|
||||
|
||||
- When the value is true, it means that only the hardened mode can be used to obtain access credentials, and an exception will be thrown.
|
||||
|
||||
Whether the server supports IMDSv2 depends on your configuration on the server.
|
||||
|
||||
### 6. Using External Service Credentials URI
|
||||
|
||||
If there are no higher-priority credential information, the Credentials tool will obtain the `ALIBABA_CLOUD_CREDENTIALS_URI` from the environment variables. If it exists, the program will request the URI address to obtain temporary security credentials as the default credential information.
|
||||
|
||||
The external service response structure should be as follows:
|
||||
|
||||
```json
|
||||
{
|
||||
"Code": "Success",
|
||||
"AccessKeyId": "AccessKeyId",
|
||||
"AccessKeySecret": "AccessKeySecret",
|
||||
"SecurityToken": "SecurityToken",
|
||||
"Expiration": "2024-10-26T03:46:38Z"
|
||||
}
|
||||
ChainProvider::set(
|
||||
ChainProvider::ini(),
|
||||
ChainProvider::env(),
|
||||
ChainProvider::instance()
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
## Documentation
|
||||
|
||||
* [Prerequisites](/docs/zh-CN/0-Prerequisites.md)
|
||||
* [Installation](/docs/zh-CN/1-Installation.md)
|
||||
|
||||
## Issue
|
||||
|
||||
## Issue
|
||||
[Submit Issue](https://github.com/aliyun/credentials-php/issues/new/choose), Problems that do not meet the guidelines may close immediately.
|
||||
|
||||
## Release notes
|
||||
|
||||
## Release notes
|
||||
Detailed changes for each version are recorded in the [Release Notes](/CHANGELOG.md).
|
||||
|
||||
## Contribution
|
||||
|
||||
## Contribution
|
||||
Please read the [Contribution Guide](/CONTRIBUTING.md) before submitting a Pull Request.
|
||||
|
||||
## Related
|
||||
|
||||
## Related
|
||||
* [OpenAPI Developer Portal][open-api]
|
||||
* [Packagist][packagist]
|
||||
* [Composer][composer]
|
||||
* [Guzzle Doc][guzzle-docs]
|
||||
* [Latest Release][latest-release]
|
||||
|
||||
## License
|
||||
|
||||
## License
|
||||
[Apache-2.0](/LICENSE.md)
|
||||
|
||||
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
|
||||
|
||||
[open-api]: https://api.alibabacloud.com
|
||||
|
||||
[open-api]: https://next.api.aliyun.com
|
||||
[latest-release]: https://github.com/aliyun/credentials-php
|
||||
[guzzle-docs]: http://docs.guzzlephp.org/en/stable/request-options.html
|
||||
[composer]: https://getcomposer.org
|
||||
[packagist]: https://packagist.org/packages/alibabacloud/credentials
|
||||
[home]: https://home.console.aliyun.com
|
||||
[aliyun]: https://www.aliyun.com
|
||||
[cURL]: https://www.php.net/manual/en/book.curl.php
|
||||
[OPCache]: http://php.net/manual/en/book.opcache.php
|
||||
[xdebug]: http://xdebug.org
|
||||
[OpenSSL]: http://php.net/manual/en/book.openssl.php
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
"ext-sockets": "*",
|
||||
"drupal/coder": "^8.3",
|
||||
"symfony/dotenv": "^3.4",
|
||||
"phpunit/phpunit": "^5.7|^6.6|^9.3",
|
||||
"phpunit/phpunit": "^4.8.35|^5.4.3",
|
||||
"monolog/monolog": "^1.24",
|
||||
"composer/composer": "^1.8",
|
||||
"mikey179/vfsstream": "^1.6",
|
||||
@@ -68,10 +68,7 @@
|
||||
},
|
||||
"config": {
|
||||
"preferred-install": "dist",
|
||||
"optimize-autoloader": true,
|
||||
"allow-plugins": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||
}
|
||||
"optimize-autoloader": true
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
|
||||
@@ -2,12 +2,9 @@
|
||||
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use AlibabaCloud\Credentials\Utils\Filter;
|
||||
use AlibabaCloud\Credentials\Credential\CredentialModel;
|
||||
use AlibabaCloud\Credentials\Signature\ShaHmac1Signature;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Use the AccessKey to complete the authentication.
|
||||
*/
|
||||
class AccessKeyCredential implements CredentialsInterface
|
||||
@@ -32,7 +29,7 @@ class AccessKeyCredential implements CredentialsInterface
|
||||
{
|
||||
Filter::accessKey($access_key_id, $access_key_secret);
|
||||
|
||||
$this->accessKeyId = $access_key_id;
|
||||
$this->accessKeyId = $access_key_id;
|
||||
$this->accessKeySecret = $access_key_secret;
|
||||
}
|
||||
|
||||
@@ -72,15 +69,4 @@ class AccessKeyCredential implements CredentialsInterface
|
||||
{
|
||||
return '';
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getCredential()
|
||||
{
|
||||
return new CredentialModel([
|
||||
'accessKeyId' => $this->accessKeyId,
|
||||
'accessKeySecret' => $this->accessKeySecret,
|
||||
'type' => 'access_key',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use AlibabaCloud\Credentials\Utils\Filter;
|
||||
use AlibabaCloud\Credentials\Credential\CredentialModel;
|
||||
use AlibabaCloud\Credentials\Signature\BearerTokenSignature;
|
||||
|
||||
/**
|
||||
@@ -20,13 +18,13 @@ class BearerTokenCredential implements CredentialsInterface
|
||||
/**
|
||||
* BearerTokenCredential constructor.
|
||||
*
|
||||
* @param $bearer_token
|
||||
* @param $bearerToken
|
||||
*/
|
||||
public function __construct($bearer_token)
|
||||
public function __construct($bearerToken)
|
||||
{
|
||||
Filter::bearerToken($bearer_token);
|
||||
Filter::bearerToken($bearerToken);
|
||||
|
||||
$this->bearerToken = $bearer_token;
|
||||
$this->bearerToken = $bearerToken;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,16 +50,4 @@ class BearerTokenCredential implements CredentialsInterface
|
||||
{
|
||||
return new BearerTokenSignature();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getCredential()
|
||||
{
|
||||
return new CredentialModel([
|
||||
'bearerToken' => $this->bearerToken,
|
||||
'type' => 'bearer',
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,188 +3,153 @@
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use AlibabaCloud\Credentials\Credential\Config;
|
||||
use AlibabaCloud\Credentials\Credential\CredentialModel;
|
||||
use AlibabaCloud\Credentials\Providers\DefaultCredentialsProvider;
|
||||
use AlibabaCloud\Credentials\Providers\EcsRamRoleCredentialsProvider;
|
||||
use AlibabaCloud\Credentials\Providers\OIDCRoleArnCredentialsProvider;
|
||||
use AlibabaCloud\Credentials\Providers\RamRoleArnCredentialsProvider;
|
||||
use AlibabaCloud\Credentials\Providers\RsaKeyPairCredentialsProvider;
|
||||
use AlibabaCloud\Credentials\Providers\StaticAKCredentialsProvider;
|
||||
use AlibabaCloud\Credentials\Providers\StaticSTSCredentialsProvider;
|
||||
use AlibabaCloud\Credentials\Providers\URLCredentialsProvider;
|
||||
use AlibabaCloud\Credentials\Utils\Helper;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
use ReflectionClass;
|
||||
use ReflectionException;
|
||||
use ReflectionParameter;
|
||||
|
||||
/**
|
||||
* Class Credential
|
||||
*
|
||||
* @package AlibabaCloud\Credentials
|
||||
*
|
||||
* @mixin AccessKeyCredential
|
||||
* @mixin BearerTokenCredential
|
||||
* @mixin EcsRamRoleCredential
|
||||
* @mixin RamRoleArnCredential
|
||||
* @mixin RsaKeyPairCredential
|
||||
*/
|
||||
class Credential
|
||||
{
|
||||
|
||||
/**
|
||||
* Version of the Client
|
||||
* @var array
|
||||
*/
|
||||
const VERSION = '1.1.5';
|
||||
protected $config = [];
|
||||
|
||||
/**
|
||||
* @var Config
|
||||
* @var array
|
||||
*/
|
||||
protected $config;
|
||||
protected $types = [
|
||||
'access_key' => AccessKeyCredential::class,
|
||||
'sts' => StsCredential::class,
|
||||
'ecs_ram_role' => EcsRamRoleCredential::class,
|
||||
'ram_role_arn' => RamRoleArnCredential::class,
|
||||
'rsa_key_pair' => RsaKeyPairCredential::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var CredentialsInterface
|
||||
* @var AccessKeyCredential|BearerTokenCredential|EcsRamRoleCredential|RamRoleArnCredential|RsaKeyPairCredential
|
||||
*/
|
||||
protected $credential;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* Credential constructor.
|
||||
*
|
||||
* @param array|Config $config
|
||||
*
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function __construct($config = [])
|
||||
{
|
||||
if (\is_array($config)) {
|
||||
if (empty($config)) {
|
||||
$this->config = null;
|
||||
} else {
|
||||
$this->config = new Config($this->parseConfig($config));
|
||||
}
|
||||
} else {
|
||||
$this->config = $config;
|
||||
if ($config instanceof Config) {
|
||||
$config = $this->parse($config);
|
||||
}
|
||||
if ($config !== []) {
|
||||
$this->config = array_change_key_case($config);
|
||||
$this->parseConfig();
|
||||
} else {
|
||||
$this->credential = Credentials::get()->getCredential();
|
||||
}
|
||||
$this->credential = $this->getCredentials($this->config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $config
|
||||
* @param Config $config
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function parseConfig($config)
|
||||
private function parse($config)
|
||||
{
|
||||
$res = [];
|
||||
foreach (\array_change_key_case($config) as $key => $value) {
|
||||
$res[Helper::snakeToCamelCase($key)] = $value;
|
||||
$config = get_object_vars($config);
|
||||
$res = [];
|
||||
foreach ($config as $key => $value) {
|
||||
$res[$this->toUnderScore($key)] = $value;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Credentials getter.
|
||||
*
|
||||
* @param Config $config
|
||||
* @return CredentialsInterface
|
||||
*
|
||||
*/
|
||||
private function getCredentials($config)
|
||||
private function toUnderScore($str)
|
||||
{
|
||||
if (is_null($config)) {
|
||||
return new CredentialsProviderWrap('default', new DefaultCredentialsProvider());
|
||||
}
|
||||
switch ($config->type) {
|
||||
case 'access_key':
|
||||
$provider = new StaticAKCredentialsProvider([
|
||||
'accessKeyId' => $config->accessKeyId,
|
||||
'accessKeySecret' => $config->accessKeySecret,
|
||||
]);
|
||||
return new CredentialsProviderWrap('access_key', $provider);
|
||||
case 'sts':
|
||||
$provider = new StaticSTSCredentialsProvider([
|
||||
'accessKeyId' => $config->accessKeyId,
|
||||
'accessKeySecret' => $config->accessKeySecret,
|
||||
'securityToken' => $config->securityToken,
|
||||
]);
|
||||
return new CredentialsProviderWrap('sts', $provider);
|
||||
case 'bearer':
|
||||
return new BearerTokenCredential($config->bearerToken);
|
||||
case 'ram_role_arn':
|
||||
if (!is_null($config->securityToken) && $config->securityToken !== '') {
|
||||
$innerProvider = new StaticSTSCredentialsProvider([
|
||||
'accessKeyId' => $config->accessKeyId,
|
||||
'accessKeySecret' => $config->accessKeySecret,
|
||||
'securityToken' => $config->securityToken,
|
||||
]);
|
||||
} else {
|
||||
$innerProvider = new StaticAKCredentialsProvider([
|
||||
'accessKeyId' => $config->accessKeyId,
|
||||
'accessKeySecret' => $config->accessKeySecret,
|
||||
]);
|
||||
}
|
||||
$provider = new RamRoleArnCredentialsProvider([
|
||||
'credentialsProvider' => $innerProvider,
|
||||
'roleArn' => $config->roleArn,
|
||||
'roleSessionName' => $config->roleSessionName,
|
||||
'policy' => $config->policy,
|
||||
'durationSeconds' => $config->roleSessionExpiration,
|
||||
'externalId' => $config->externalId,
|
||||
'stsEndpoint' => $config->STSEndpoint,
|
||||
], [
|
||||
'connectTimeout' => $config->connectTimeout,
|
||||
'readTimeout' => $config->readTimeout,
|
||||
]);
|
||||
return new CredentialsProviderWrap('ram_role_arn', $provider);
|
||||
case 'rsa_key_pair':
|
||||
$provider = new RsaKeyPairCredentialsProvider([
|
||||
'publicKeyId' => $config->publicKeyId,
|
||||
'privateKeyFile' => $config->privateKeyFile,
|
||||
'durationSeconds' => $config->roleSessionExpiration,
|
||||
'stsEndpoint' => $config->STSEndpoint,
|
||||
], [
|
||||
'connectTimeout' => $config->connectTimeout,
|
||||
'readTimeout' => $config->readTimeout,
|
||||
]);
|
||||
return new CredentialsProviderWrap('rsa_key_pair', $provider);
|
||||
case 'ecs_ram_role':
|
||||
$provider = new EcsRamRoleCredentialsProvider([
|
||||
'roleName' => $config->roleName,
|
||||
'disableIMDSv1' => $config->disableIMDSv1,
|
||||
], [
|
||||
'connectTimeout' => $config->connectTimeout,
|
||||
'readTimeout' => $config->readTimeout,
|
||||
]);
|
||||
return new CredentialsProviderWrap('ecs_ram_role', $provider);
|
||||
case 'oidc_role_arn':
|
||||
$provider = new OIDCRoleArnCredentialsProvider([
|
||||
'roleArn' => $config->roleArn,
|
||||
'oidcProviderArn' => $config->oidcProviderArn,
|
||||
'oidcTokenFilePath' => $config->oidcTokenFilePath,
|
||||
'roleSessionName' => $config->roleSessionName,
|
||||
'policy' => $config->policy,
|
||||
'durationSeconds' => $config->roleSessionExpiration,
|
||||
'stsEndpoint' => $config->STSEndpoint,
|
||||
], [
|
||||
'connectTimeout' => $config->connectTimeout,
|
||||
'readTimeout' => $config->readTimeout,
|
||||
]);
|
||||
return new CredentialsProviderWrap('oidc_role_arn', $provider);
|
||||
case "credentials_uri":
|
||||
$provider = new URLCredentialsProvider([
|
||||
'credentialsURI' => $config->credentialsURI,
|
||||
], [
|
||||
'connectTimeout' => $config->connectTimeout,
|
||||
'readTimeout' => $config->readTimeout,
|
||||
]);
|
||||
return new CredentialsProviderWrap('credentials_uri', $provider);
|
||||
default:
|
||||
throw new InvalidArgumentException('Unsupported credential type option: ' . $config->type . ', support: access_key, sts, bearer, ecs_ram_role, ram_role_arn, rsa_key_pair, oidc_role_arn, credentials_uri');
|
||||
}
|
||||
$dstr = preg_replace_callback('/([A-Z]+)/', function ($matchs) {
|
||||
return '_' . strtolower($matchs[0]);
|
||||
}, $str);
|
||||
return trim(preg_replace('/_{2,}/', '_', $dstr), '_');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CredentialModel
|
||||
* @throws RuntimeException
|
||||
* @throws GuzzleException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
private function parseConfig()
|
||||
{
|
||||
if (!isset($this->config['type'])) {
|
||||
throw new InvalidArgumentException('Missing required type option');
|
||||
}
|
||||
|
||||
$this->type = $this->config['type'];
|
||||
if (!isset($this->types[$this->type])) {
|
||||
throw new InvalidArgumentException(
|
||||
'Invalid type option, support: ' .
|
||||
implode(', ', array_keys($this->types))
|
||||
);
|
||||
}
|
||||
|
||||
$class = new ReflectionClass($this->types[$this->type]);
|
||||
$parameters = [];
|
||||
/**
|
||||
* @var $parameter ReflectionParameter
|
||||
*/
|
||||
foreach ($class->getConstructor()->getParameters() as $parameter) {
|
||||
$parameters[] = $this->getValue($parameter);
|
||||
}
|
||||
|
||||
$this->credential = $class->newInstance(...$parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ReflectionParameter $parameter
|
||||
*
|
||||
* @return string|array
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
protected function getValue(ReflectionParameter $parameter)
|
||||
{
|
||||
if ($parameter->name === 'config' || $parameter->name === 'credential') {
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
foreach ($this->config as $key => $value) {
|
||||
if (strtolower($parameter->name) === $key) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
if ($parameter->isDefaultValueAvailable()) {
|
||||
return $parameter->getDefaultValue();
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException("Missing required {$parameter->name} option in config for {$this->type}");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AccessKeyCredential|BearerTokenCredential|EcsRamRoleCredential|RamRoleArnCredential|RsaKeyPairCredential
|
||||
*/
|
||||
public function getCredential()
|
||||
{
|
||||
return $this->credential->getCredential();
|
||||
return $this->credential;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,68 +157,17 @@ class Credential
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
return $this->config->toMap();
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use getCredential() instead
|
||||
*
|
||||
* @return string
|
||||
* @throws RuntimeException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->credential->getCredential()->getType();
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use getCredential() instead
|
||||
*
|
||||
* @return string
|
||||
* @throws RuntimeException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getAccessKeyId()
|
||||
{
|
||||
return $this->credential->getCredential()->getAccessKeyId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use getCredential() instead
|
||||
*
|
||||
* @return string
|
||||
* @throws RuntimeException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getAccessKeySecret()
|
||||
{
|
||||
return $this->credential->getCredential()->getAccessKeySecret();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use getCredential() instead
|
||||
*
|
||||
* @return string
|
||||
* @throws RuntimeException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getSecurityToken()
|
||||
{
|
||||
return $this->credential->getCredential()->getSecurityToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use getCredential() instead
|
||||
*
|
||||
* @return string
|
||||
* @throws RuntimeException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getBearerToken()
|
||||
{
|
||||
return $this->credential->getCredential()->getBearerToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
|
||||
@@ -2,269 +2,49 @@
|
||||
|
||||
namespace AlibabaCloud\Credentials\Credential;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class Config extends Model
|
||||
class Config
|
||||
{
|
||||
public function validate()
|
||||
{
|
||||
}
|
||||
public function toMap()
|
||||
{
|
||||
$res = [];
|
||||
if (null !== $this->accessKeyId) {
|
||||
$res['accessKeyId'] = $this->accessKeyId;
|
||||
}
|
||||
if (null !== $this->accessKeySecret) {
|
||||
$res['accessKeySecret'] = $this->accessKeySecret;
|
||||
}
|
||||
if (null !== $this->securityToken) {
|
||||
$res['securityToken'] = $this->securityToken;
|
||||
}
|
||||
if (null !== $this->bearerToken) {
|
||||
$res['bearerToken'] = $this->bearerToken;
|
||||
}
|
||||
if (null !== $this->durationSeconds) {
|
||||
$res['durationSeconds'] = $this->durationSeconds;
|
||||
}
|
||||
if (null !== $this->roleArn) {
|
||||
$res['roleArn'] = $this->roleArn;
|
||||
}
|
||||
if (null !== $this->policy) {
|
||||
$res['policy'] = $this->policy;
|
||||
}
|
||||
if (null !== $this->roleSessionExpiration) {
|
||||
$res['roleSessionExpiration'] = $this->roleSessionExpiration;
|
||||
}
|
||||
if (null !== $this->roleSessionName) {
|
||||
$res['roleSessionName'] = $this->roleSessionName;
|
||||
}
|
||||
if (null !== $this->publicKeyId) {
|
||||
$res['publicKeyId'] = $this->publicKeyId;
|
||||
}
|
||||
if (null !== $this->privateKeyFile) {
|
||||
$res['privateKeyFile'] = $this->privateKeyFile;
|
||||
}
|
||||
if (null !== $this->roleName) {
|
||||
$res['roleName'] = $this->roleName;
|
||||
}
|
||||
if (null !== $this->credentialsURI) {
|
||||
$res['credentialsURI'] = $this->credentialsURI;
|
||||
}
|
||||
if (null !== $this->type) {
|
||||
$res['type'] = $this->type;
|
||||
}
|
||||
if (null !== $this->STSEndpoint) {
|
||||
$res['STSEndpoint'] = $this->STSEndpoint;
|
||||
}
|
||||
if (null !== $this->externalId) {
|
||||
$res['externalId'] = $this->externalId;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return Config
|
||||
*/
|
||||
public static function fromMap($map = [])
|
||||
{
|
||||
$model = new self();
|
||||
if (isset($map['accessKeyId'])) {
|
||||
$model->accessKeyId = $map['accessKeyId'];
|
||||
}
|
||||
if (isset($map['accessKeySecret'])) {
|
||||
$model->accessKeySecret = $map['accessKeySecret'];
|
||||
}
|
||||
if (isset($map['securityToken'])) {
|
||||
$model->securityToken = $map['securityToken'];
|
||||
}
|
||||
if (isset($map['bearerToken'])) {
|
||||
$model->bearerToken = $map['bearerToken'];
|
||||
}
|
||||
if (isset($map['durationSeconds'])) {
|
||||
$model->durationSeconds = $map['durationSeconds'];
|
||||
}
|
||||
if (isset($map['roleArn'])) {
|
||||
$model->roleArn = $map['roleArn'];
|
||||
}
|
||||
if (isset($map['policy'])) {
|
||||
$model->policy = $map['policy'];
|
||||
}
|
||||
if (isset($map['roleSessionExpiration'])) {
|
||||
$model->roleSessionExpiration = $map['roleSessionExpiration'];
|
||||
}
|
||||
if (isset($map['roleSessionName'])) {
|
||||
$model->roleSessionName = $map['roleSessionName'];
|
||||
}
|
||||
if (isset($map['publicKeyId'])) {
|
||||
$model->publicKeyId = $map['publicKeyId'];
|
||||
}
|
||||
if (isset($map['privateKeyFile'])) {
|
||||
$model->privateKeyFile = $map['privateKeyFile'];
|
||||
}
|
||||
if (isset($map['roleName'])) {
|
||||
$model->roleName = $map['roleName'];
|
||||
}
|
||||
if (isset($map['credentialsURI'])) {
|
||||
$model->credentialsURI = $map['credentialsURI'];
|
||||
}
|
||||
if (isset($map['type'])) {
|
||||
$model->type = $map['type'];
|
||||
}
|
||||
if (isset($map['STSEndpoint'])) {
|
||||
$model->STSEndpoint = $map['STSEndpoint'];
|
||||
}
|
||||
if (isset($map['externalId'])) {
|
||||
$model->externalId = $map['externalId'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description credential type
|
||||
* @example access_key
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'default';
|
||||
|
||||
/**
|
||||
* @description accesskey id
|
||||
* @var string
|
||||
*/
|
||||
public $accessKeyId;
|
||||
public $accessKeyId = "";
|
||||
|
||||
/**
|
||||
* @description accesskey secret
|
||||
* @var string
|
||||
*/
|
||||
public $accessKeySecret;
|
||||
public $accessKeySecret = "";
|
||||
|
||||
/**
|
||||
* @description security token
|
||||
* @var string
|
||||
*/
|
||||
public $securityToken;
|
||||
public $securityToken = "";
|
||||
|
||||
/**
|
||||
* @description bearer token
|
||||
* @var string
|
||||
*/
|
||||
public $bearerToken;
|
||||
public $bearerToken = "";
|
||||
|
||||
/**
|
||||
* @description role name
|
||||
* @var string
|
||||
*/
|
||||
public $roleName;
|
||||
public $roleName = "";
|
||||
|
||||
/**
|
||||
* @description role arn
|
||||
* @var string
|
||||
*/
|
||||
public $roleArn;
|
||||
public $roleArn = "";
|
||||
|
||||
/**
|
||||
* @description oidc provider arn
|
||||
* @var string
|
||||
*/
|
||||
public $oidcProviderArn;
|
||||
public $roleSessionName = "";
|
||||
|
||||
/**
|
||||
* @description oidc token file path
|
||||
* @var string
|
||||
*/
|
||||
public $oidcTokenFilePath;
|
||||
public $host = "";
|
||||
|
||||
/**
|
||||
* @description role session expiration
|
||||
* @example 3600
|
||||
* @var int
|
||||
*/
|
||||
public $roleSessionExpiration;
|
||||
public $publicKeyId = "";
|
||||
|
||||
/**
|
||||
* @description role session name
|
||||
* @var string
|
||||
*/
|
||||
public $roleSessionName;
|
||||
public $privateKeyFile = "";
|
||||
|
||||
/**
|
||||
* @description role arn policy
|
||||
* @var string
|
||||
*/
|
||||
public $policy;
|
||||
public $readTimeout = 0;
|
||||
|
||||
/**
|
||||
* @description external id for ram role arn
|
||||
* @var string
|
||||
*/
|
||||
public $externalId;
|
||||
public $connectTimeout = 0;
|
||||
|
||||
/**
|
||||
* @description sts endpoint
|
||||
* @var string
|
||||
*/
|
||||
public $STSEndpoint;
|
||||
|
||||
public $publicKeyId;
|
||||
|
||||
public $privateKeyFile;
|
||||
|
||||
/**
|
||||
* @description read timeout
|
||||
* @var int
|
||||
*/
|
||||
public $readTimeout;
|
||||
|
||||
/**
|
||||
* @description connection timeout
|
||||
* @var int
|
||||
*/
|
||||
public $connectTimeout;
|
||||
|
||||
/**
|
||||
* @description disable IMDS v1
|
||||
* @var bool
|
||||
*/
|
||||
public $disableIMDSv1;
|
||||
|
||||
/**
|
||||
* @description credentials URI
|
||||
* @var string
|
||||
*/
|
||||
public $credentialsURI;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public $metadataTokenDuration;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public $durationSeconds;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public $host;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public $expiration;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public $certFile = "";
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public $certPassword = "";
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public $proxy;
|
||||
public $proxy = "";
|
||||
|
||||
public $expiration = 0;
|
||||
|
||||
public function __construct($config)
|
||||
{
|
||||
foreach ($config as $k => $v) {
|
||||
$this->{$k} = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,143 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace AlibabaCloud\Credentials\Credential;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class CredentialModel extends Model
|
||||
{
|
||||
public function validate()
|
||||
{
|
||||
}
|
||||
public function toMap()
|
||||
{
|
||||
$res = [];
|
||||
if (null !== $this->accessKeyId) {
|
||||
$res['accessKeyId'] = $this->accessKeyId;
|
||||
}
|
||||
if (null !== $this->accessKeySecret) {
|
||||
$res['accessKeySecret'] = $this->accessKeySecret;
|
||||
}
|
||||
if (null !== $this->securityToken) {
|
||||
$res['securityToken'] = $this->securityToken;
|
||||
}
|
||||
if (null !== $this->bearerToken) {
|
||||
$res['bearerToken'] = $this->bearerToken;
|
||||
}
|
||||
if (null !== $this->type) {
|
||||
$res['type'] = $this->type;
|
||||
}
|
||||
if (null !== $this->providerName) {
|
||||
$res['providerName'] = $this->providerName;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return CredentialModel
|
||||
*/
|
||||
public static function fromMap($map = [])
|
||||
{
|
||||
$model = new self();
|
||||
if (isset($map['accessKeyId'])) {
|
||||
$model->accessKeyId = $map['accessKeyId'];
|
||||
}
|
||||
if (isset($map['accessKeySecret'])) {
|
||||
$model->accessKeySecret = $map['accessKeySecret'];
|
||||
}
|
||||
if (isset($map['securityToken'])) {
|
||||
$model->securityToken = $map['securityToken'];
|
||||
}
|
||||
if (isset($map['bearerToken'])) {
|
||||
$model->bearerToken = $map['bearerToken'];
|
||||
}
|
||||
if (isset($map['type'])) {
|
||||
$model->type = $map['type'];
|
||||
}
|
||||
if(isset($map['providerName'])){
|
||||
$model->providerName = $map['providerName'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description accesskey id
|
||||
* @var string
|
||||
*/
|
||||
public $accessKeyId;
|
||||
|
||||
/**
|
||||
* @description accesskey secret
|
||||
* @var string
|
||||
*/
|
||||
public $accessKeySecret;
|
||||
|
||||
/**
|
||||
* @description security token
|
||||
* @var string
|
||||
*/
|
||||
public $securityToken;
|
||||
|
||||
/**
|
||||
* @description bearer token
|
||||
* @var string
|
||||
*/
|
||||
public $bearerToken;
|
||||
|
||||
/**
|
||||
* @description type
|
||||
* @example access_key
|
||||
* @var string
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* @description provider name
|
||||
* @example cli_profile/static_ak
|
||||
* @var string
|
||||
*/
|
||||
public $providerName;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAccessKeyId()
|
||||
{
|
||||
return $this->accessKeyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAccessKeySecret()
|
||||
{
|
||||
return $this->accessKeySecret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSecurityToken()
|
||||
{
|
||||
return $this->securityToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBearerToken()
|
||||
{
|
||||
return $this->bearerToken;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function getProviderName()
|
||||
{
|
||||
return $this->providerName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Credential;
|
||||
|
||||
use AlibabaCloud\Credentials\Providers\Credentials;
|
||||
|
||||
use function PHPUnit\Framework\isNull;
|
||||
|
||||
class RefreshResult
|
||||
{
|
||||
|
||||
/**
|
||||
* RefreshResult constructor.
|
||||
* @param Credentials $params
|
||||
* @param int $staleTime
|
||||
* @param int $prefetchTime
|
||||
*/
|
||||
public function __construct($credentials = null, $staleTime = PHP_INT_MAX, $prefetchTime = PHP_INT_MAX)
|
||||
{
|
||||
$this->credentials = $credentials;
|
||||
$this->staleTime = $staleTime;
|
||||
$this->prefetchTime = $prefetchTime;
|
||||
}
|
||||
public function validate() {}
|
||||
public function toMap()
|
||||
{
|
||||
$res = [];
|
||||
if (null !== $this->staleTime) {
|
||||
$res['staleTime'] = $this->staleTime;
|
||||
}
|
||||
if (null !== $this->prefetchTime) {
|
||||
$res['prefetchTime'] = $this->prefetchTime;
|
||||
}
|
||||
if (null !== $this->credentials) {
|
||||
$res['credentials'] = $this->credentials;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return RefreshResult
|
||||
*/
|
||||
public static function fromMap($map = [])
|
||||
{
|
||||
$model = new self();
|
||||
if (isset($map['staleTime'])) {
|
||||
$model->staleTime = $map['staleTime'];
|
||||
}
|
||||
if (isset($map['prefetchTime'])) {
|
||||
$model->staleTime = $map['prefetchTime'];
|
||||
}
|
||||
if (isset($map['credentials'])) {
|
||||
$model->staleTime = $map['credentials'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description staleTime
|
||||
* @var int
|
||||
*/
|
||||
public $staleTime;
|
||||
|
||||
/**
|
||||
* @description prefetchTime
|
||||
* @var int
|
||||
*/
|
||||
public $prefetchTime;
|
||||
|
||||
/**
|
||||
* @description credentials
|
||||
* @var Credentials
|
||||
*/
|
||||
public $credentials;
|
||||
|
||||
|
||||
/**
|
||||
* @return Credentials
|
||||
*/
|
||||
public function credentials()
|
||||
{
|
||||
return $this->credentials;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public function staleTime()
|
||||
{
|
||||
return $this->staleTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public function prefetchTime()
|
||||
{
|
||||
return $this->prefetchTime;
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,6 @@
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use AlibabaCloud\Credentials\Providers\ChainProvider;
|
||||
use AlibabaCloud\Credentials\Utils\Filter;
|
||||
use AlibabaCloud\Credentials\Utils\MockTrait;
|
||||
use ReflectionException;
|
||||
use RuntimeException;
|
||||
|
||||
@@ -101,4 +99,4 @@ class Credentials
|
||||
|
||||
self::$credentials[\strtolower($name)] = \array_change_key_case($credential);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use AlibabaCloud\Credentials\Credential\CredentialModel;
|
||||
use AlibabaCloud\Credentials\Signature\SignatureInterface;
|
||||
|
||||
/**
|
||||
* @internal This class is intended for internal use within the package.
|
||||
* Interface CredentialsInterface
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
@@ -14,19 +12,12 @@ use AlibabaCloud\Credentials\Signature\SignatureInterface;
|
||||
interface CredentialsInterface
|
||||
{
|
||||
/**
|
||||
* @deprecated
|
||||
* @return string
|
||||
*/
|
||||
public function __toString();
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return SignatureInterface
|
||||
*/
|
||||
public function getSignature();
|
||||
|
||||
/**
|
||||
* @return CredentialModel
|
||||
*/
|
||||
public function getCredential();
|
||||
}
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use AlibabaCloud\Credentials\Credential\CredentialModel;
|
||||
use AlibabaCloud\Credentials\Providers\CredentialsProvider;
|
||||
|
||||
/**
|
||||
* @internal This class is intended for internal use within the package.
|
||||
* Class CredentialsProviderWrap
|
||||
*
|
||||
* @package AlibabaCloud\Credentials
|
||||
*/
|
||||
class CredentialsProviderWrap implements CredentialsInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $typeName;
|
||||
|
||||
/**
|
||||
* @var CredentialsProvider
|
||||
*/
|
||||
private $credentialsProvider;
|
||||
|
||||
/**
|
||||
* CLIProfileCredentialsProvider constructor.
|
||||
*
|
||||
* @param string $typeName
|
||||
* @param CredentialsProvider $credentialsProvider
|
||||
*/
|
||||
public function __construct($typeName, $credentialsProvider)
|
||||
{
|
||||
$this->typeName = $typeName;
|
||||
$this->credentialsProvider = $credentialsProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getCredential()
|
||||
{
|
||||
$credentials = $this->credentialsProvider->getCredentials();
|
||||
return new CredentialModel([
|
||||
'accessKeyId' => $credentials->getAccessKeyId(),
|
||||
'accessKeySecret' => $credentials->getAccessKeySecret(),
|
||||
'securityToken' => $credentials->getSecurityToken(),
|
||||
'type' => $this->typeName,
|
||||
'providerName' => $credentials->getProviderName(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param array $arguments
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($name, $arguments)
|
||||
{
|
||||
return $this->credentialsProvider->$name($arguments);
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return "credentialsProviderWrap#$this->typeName";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ShaHmac1Signature
|
||||
*/
|
||||
public function getSignature()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -2,18 +2,15 @@
|
||||
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use AlibabaCloud\Credentials\Providers\EcsRamRoleCredentialsProvider;
|
||||
use AlibabaCloud\Credentials\Credential\CredentialModel;
|
||||
use AlibabaCloud\Credentials\Signature\ShaHmac1Signature;
|
||||
use AlibabaCloud\Credentials\Providers\EcsRamRoleProvider;
|
||||
use AlibabaCloud\Credentials\Request\Request;
|
||||
use AlibabaCloud\Credentials\Utils\Filter;
|
||||
use AlibabaCloud\Credentials\Signature\ShaHmac1Signature;
|
||||
use Exception;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Use the RAM role of an ECS instance to complete the authentication.
|
||||
*/
|
||||
class EcsRamRoleCredential implements CredentialsInterface
|
||||
@@ -24,33 +21,16 @@ class EcsRamRoleCredential implements CredentialsInterface
|
||||
*/
|
||||
private $roleName;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*/
|
||||
private $disableIMDSv1;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $metadataTokenDuration;
|
||||
|
||||
|
||||
/**
|
||||
* EcsRamRoleCredential constructor.
|
||||
*
|
||||
* @param $role_name
|
||||
*/
|
||||
public function __construct($role_name = null, $disable_imdsv1 = false, $metadata_token_duration = 21600)
|
||||
public function __construct($role_name = null)
|
||||
{
|
||||
Filter::roleName($role_name);
|
||||
|
||||
$this->roleName = $role_name;
|
||||
|
||||
Filter::disableIMDSv1($disable_imdsv1);
|
||||
|
||||
$this->disableIMDSv1 = $disable_imdsv1;
|
||||
|
||||
$this->metadataTokenDuration = $metadata_token_duration;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,8 +56,8 @@ class EcsRamRoleCredential implements CredentialsInterface
|
||||
public function getRoleNameFromMeta()
|
||||
{
|
||||
$options = [
|
||||
'http_errors' => false,
|
||||
'timeout' => 1,
|
||||
'http_errors' => false,
|
||||
'timeout' => 1,
|
||||
'connect_timeout' => 1,
|
||||
];
|
||||
|
||||
@@ -95,7 +75,7 @@ class EcsRamRoleCredential implements CredentialsInterface
|
||||
throw new RuntimeException('Error retrieving credentials from result: ' . $result->getBody());
|
||||
}
|
||||
|
||||
$role_name = (string) $result;
|
||||
$role_name = (string)$result;
|
||||
if (!$role_name) {
|
||||
throw new RuntimeException('Error retrieving credentials from result is empty');
|
||||
}
|
||||
@@ -130,18 +110,13 @@ class EcsRamRoleCredential implements CredentialsInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AlibabaCloud\Credentials\Providers\Credentials
|
||||
* @return StsCredential
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
protected function getSessionCredential()
|
||||
{
|
||||
$params = [
|
||||
"roleName" => $this->roleName,
|
||||
'disableIMDSv1' => $this->disableIMDSv1,
|
||||
'metadataTokenDuration' => $this->metadataTokenDuration,
|
||||
];
|
||||
return (new EcsRamRoleCredentialsProvider($params))->getCredentials();
|
||||
return (new EcsRamRoleProvider($this))->get();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,27 +148,4 @@ class EcsRamRoleCredential implements CredentialsInterface
|
||||
{
|
||||
return $this->getSessionCredential()->getExpiration();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDisableIMDSv1()
|
||||
{
|
||||
return $this->disableIMDSv1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getCredential()
|
||||
{
|
||||
$credentials = $this->getSessionCredential();
|
||||
return new CredentialModel([
|
||||
'accessKeyId' => $credentials->getAccessKeyId(),
|
||||
'accessKeySecret' => $credentials->getAccessKeySecret(),
|
||||
'securityToken' => $credentials->getSecurityToken(),
|
||||
'type' => 'ecs_ram_role',
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
134
Server/vendor/alibabacloud/credentials/src/Filter.php
vendored
Normal file
134
Server/vendor/alibabacloud/credentials/src/Filter.php
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
class Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @return string
|
||||
*/
|
||||
public static function credentialName($name)
|
||||
{
|
||||
if (!is_string($name)) {
|
||||
throw new InvalidArgumentException('Name must be a string');
|
||||
}
|
||||
|
||||
if ($name === '') {
|
||||
throw new InvalidArgumentException('Name cannot be empty');
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $bearerToken
|
||||
*
|
||||
* @return mixed
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function bearerToken($bearerToken)
|
||||
{
|
||||
if (!is_string($bearerToken)) {
|
||||
throw new InvalidArgumentException('Bearer Token must be a string');
|
||||
}
|
||||
|
||||
if ($bearerToken === '') {
|
||||
throw new InvalidArgumentException('Bearer Token cannot be empty');
|
||||
}
|
||||
|
||||
return $bearerToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $publicKeyId
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function publicKeyId($publicKeyId)
|
||||
{
|
||||
if (!is_string($publicKeyId)) {
|
||||
throw new InvalidArgumentException('public_key_id must be a string');
|
||||
}
|
||||
|
||||
if ($publicKeyId === '') {
|
||||
throw new InvalidArgumentException('public_key_id cannot be empty');
|
||||
}
|
||||
|
||||
return $publicKeyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $privateKeyFile
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function privateKeyFile($privateKeyFile)
|
||||
{
|
||||
if (!is_string($privateKeyFile)) {
|
||||
throw new InvalidArgumentException('private_key_file must be a string');
|
||||
}
|
||||
|
||||
if ($privateKeyFile === '') {
|
||||
throw new InvalidArgumentException('private_key_file cannot be empty');
|
||||
}
|
||||
|
||||
return $privateKeyFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $role_name
|
||||
*/
|
||||
public static function roleName($role_name)
|
||||
{
|
||||
if ($role_name === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_string($role_name)) {
|
||||
throw new InvalidArgumentException('role_name must be a string');
|
||||
}
|
||||
|
||||
if ($role_name === '') {
|
||||
throw new InvalidArgumentException('role_name cannot be empty');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $accessKeyId
|
||||
* @param string $accessKeySecret
|
||||
*/
|
||||
public static function accessKey($accessKeyId, $accessKeySecret)
|
||||
{
|
||||
if (!is_string($accessKeyId)) {
|
||||
throw new InvalidArgumentException('access_key_id must be a string');
|
||||
}
|
||||
|
||||
if ($accessKeyId === '') {
|
||||
throw new InvalidArgumentException('access_key_id cannot be empty');
|
||||
}
|
||||
|
||||
if (!is_string($accessKeySecret)) {
|
||||
throw new InvalidArgumentException('access_key_secret must be a string');
|
||||
}
|
||||
|
||||
if ($accessKeySecret === '') {
|
||||
throw new InvalidArgumentException('access_key_secret cannot be empty');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $expiration
|
||||
*/
|
||||
public static function expiration($expiration)
|
||||
{
|
||||
if (!is_int($expiration)) {
|
||||
throw new InvalidArgumentException('expiration must be a int');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Utils;
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
use Closure;
|
||||
|
||||
/**
|
||||
* Class Helper
|
||||
*
|
||||
* @package AlibabaCloud\Credentials\Utils
|
||||
* @package AlibabaCloud\Credentials
|
||||
*/
|
||||
class Helper
|
||||
{
|
||||
@@ -53,10 +51,6 @@ class Helper
|
||||
if (!$open_basedir) {
|
||||
return true;
|
||||
}
|
||||
if (0 === strpos($filename, vfsStream::SCHEME)) {
|
||||
// 虚拟文件忽略
|
||||
return true;
|
||||
}
|
||||
|
||||
$dirs = explode(PATH_SEPARATOR, $open_basedir);
|
||||
|
||||
@@ -205,47 +199,4 @@ class Helper
|
||||
dump(...$parameters);
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Snake to camel case.
|
||||
*
|
||||
* @param string $str
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function snakeToCamelCase($str)
|
||||
{
|
||||
$components = explode('_', $str);
|
||||
$camelCaseStr = $components[0];
|
||||
for ($i = 1; $i < count($components); $i++) {
|
||||
$camelCaseStr .= ucfirst($components[$i]);
|
||||
}
|
||||
return $camelCaseStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user agent.
|
||||
*
|
||||
* @param string $userAgent
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getUserAgent()
|
||||
{
|
||||
return sprintf('AlibabaCloud (%s; %s) PHP/%s Credentials/%s TeaDSL/1', PHP_OS, \PHP_SAPI, PHP_VERSION, Credential::VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arrays
|
||||
* @param string $key
|
||||
*
|
||||
* @return mix
|
||||
*/
|
||||
public static function unsetReturnNull(array $arrays, $key)
|
||||
{
|
||||
if(isset($arrays[$key])) {
|
||||
return $arrays[$key];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Utils;
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use Exception;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use GuzzleHttp\Handler\MockHandler;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use GuzzleHttp\Middleware;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
/**
|
||||
* Trait MockTrait
|
||||
*
|
||||
* @package AlibabaCloud\Credentials\Utils
|
||||
* @package AlibabaCloud\Credentials
|
||||
*/
|
||||
trait MockTrait
|
||||
{
|
||||
@@ -22,11 +21,6 @@ trait MockTrait
|
||||
*/
|
||||
private static $mockQueue = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private static $history = [];
|
||||
|
||||
/**
|
||||
* @var MockHandler
|
||||
*/
|
||||
@@ -52,14 +46,6 @@ trait MockTrait
|
||||
self::$mock = new MockHandler(self::$mockQueue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MockHandler
|
||||
*/
|
||||
public static function getHandlerHistory()
|
||||
{
|
||||
return Middleware::history(self::$history);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
* @param RequestInterface $request
|
||||
@@ -109,12 +95,4 @@ trait MockTrait
|
||||
{
|
||||
return self::$mock;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getHistroy()
|
||||
{
|
||||
return self::$history;
|
||||
}
|
||||
}
|
||||
@@ -1,187 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Providers;
|
||||
|
||||
use AlibabaCloud\Credentials\Utils\Helper;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* @internal This class is intended for internal use within the package.
|
||||
* Class CLIProfileCredentialsProvider
|
||||
*
|
||||
* @package AlibabaCloud\Credentials\Providers
|
||||
*/
|
||||
class CLIProfileCredentialsProvider implements CredentialsProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $profileName;
|
||||
|
||||
/**
|
||||
* @var CredentialsProvider
|
||||
*/
|
||||
private $credentialsProvider;
|
||||
|
||||
|
||||
/**
|
||||
* CLIProfileCredentialsProvider constructor.
|
||||
*
|
||||
* @param array $params
|
||||
*/
|
||||
public function __construct(array $params = [])
|
||||
{
|
||||
$this->filterProfileName($params);
|
||||
}
|
||||
|
||||
private function filterProfileName(array $params)
|
||||
{
|
||||
if (Helper::envNotEmpty('ALIBABA_CLOUD_PROFILE')) {
|
||||
$this->profileName = Helper::env('ALIBABA_CLOUD_PROFILE');
|
||||
}
|
||||
|
||||
if (isset($params['profileName'])) {
|
||||
$this->profileName = $params['profileName'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
private function shouldReloadCredentialsProvider()
|
||||
{
|
||||
if (is_null($this->credentialsProvider)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CredentialsProvider
|
||||
*/
|
||||
protected function reloadCredentialsProvider($profileFile, $profileName)
|
||||
{
|
||||
if (!Helper::inOpenBasedir($profileFile)) {
|
||||
throw new RuntimeException('Unable to open credentials file: ' . $profileFile);
|
||||
}
|
||||
|
||||
if (!\is_readable($profileFile) || !\is_file($profileFile)) {
|
||||
throw new RuntimeException('Credentials file is not readable: ' . $profileFile);
|
||||
}
|
||||
|
||||
$jsonContent = \file_get_contents($profileFile);
|
||||
$fileArray = json_decode($jsonContent, true);
|
||||
|
||||
if (\is_array($fileArray) && !empty($fileArray)) {
|
||||
if (is_null($profileName) || $profileName === '') {
|
||||
$profileName = $fileArray['current'];
|
||||
}
|
||||
if (isset($fileArray['profiles'])) {
|
||||
foreach ($fileArray['profiles'] as $profile) {
|
||||
if (Helper::unsetReturnNull($profile, 'name') === $profileName) {
|
||||
switch (Helper::unsetReturnNull($profile, 'mode')) {
|
||||
case 'AK':
|
||||
return new StaticAKCredentialsProvider([
|
||||
'accessKeyId' => Helper::unsetReturnNull($profile, 'access_key_id'),
|
||||
'accessKeySecret' => Helper::unsetReturnNull($profile, 'access_key_secret'),
|
||||
]);
|
||||
case 'RamRoleArn':
|
||||
$innerProvider = new StaticAKCredentialsProvider([
|
||||
'accessKeyId' => Helper::unsetReturnNull($profile, 'access_key_id'),
|
||||
'accessKeySecret' => Helper::unsetReturnNull($profile, 'access_key_secret'),
|
||||
]);
|
||||
return new RamRoleArnCredentialsProvider([
|
||||
'credentialsProvider' => $innerProvider,
|
||||
'roleArn' => Helper::unsetReturnNull($profile, 'ram_role_arn'),
|
||||
'roleSessionName' => Helper::unsetReturnNull($profile, 'ram_session_name'),
|
||||
'durationSeconds' => Helper::unsetReturnNull($profile, 'expired_seconds'),
|
||||
'policy' => Helper::unsetReturnNull($profile, 'policy'),
|
||||
'externalId' => Helper::unsetReturnNull($profile, 'external_id'),
|
||||
'stsRegionId' => Helper::unsetReturnNull($profile, 'sts_region'),
|
||||
'enableVpc' => Helper::unsetReturnNull($profile, 'enable_vpc'),
|
||||
]);
|
||||
case 'EcsRamRole':
|
||||
return new EcsRamRoleCredentialsProvider([
|
||||
'roleName' => Helper::unsetReturnNull($profile, 'ram_role_name'),
|
||||
]);
|
||||
case 'OIDC':
|
||||
return new OIDCRoleArnCredentialsProvider([
|
||||
'roleArn' => Helper::unsetReturnNull($profile, 'ram_role_arn'),
|
||||
'oidcProviderArn' => Helper::unsetReturnNull($profile, 'oidc_provider_arn'),
|
||||
'oidcTokenFilePath' => Helper::unsetReturnNull($profile, 'oidc_token_file'),
|
||||
'roleSessionName' => Helper::unsetReturnNull($profile, 'ram_session_name'),
|
||||
'durationSeconds' => Helper::unsetReturnNull($profile, 'expired_seconds'),
|
||||
'policy' => Helper::unsetReturnNull($profile, 'policy'),
|
||||
'stsRegionId' => Helper::unsetReturnNull($profile, 'sts_region'),
|
||||
'enableVpc' => Helper::unsetReturnNull($profile, 'enable_vpc'),
|
||||
]);
|
||||
case 'ChainableRamRoleArn':
|
||||
$previousProvider = $this->reloadCredentialsProvider($profileFile, Helper::unsetReturnNull($profile, 'source_profile'));
|
||||
return new RamRoleArnCredentialsProvider([
|
||||
'credentialsProvider' => $previousProvider,
|
||||
'roleArn' => Helper::unsetReturnNull($profile, 'ram_role_arn'),
|
||||
'roleSessionName' => Helper::unsetReturnNull($profile, 'ram_session_name'),
|
||||
'durationSeconds' => Helper::unsetReturnNull($profile, 'expired_seconds'),
|
||||
'policy' => Helper::unsetReturnNull($profile, 'policy'),
|
||||
'externalId' => Helper::unsetReturnNull($profile, 'external_id'),
|
||||
'stsRegionId' => Helper::unsetReturnNull($profile, 'sts_region'),
|
||||
'enableVpc' => Helper::unsetReturnNull($profile, 'enable_vpc'),
|
||||
]);
|
||||
default:
|
||||
throw new RuntimeException('Unsupported credential mode from CLI credentials file: ' . Helper::unsetReturnNull($profile, 'mode'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new RuntimeException('Failed to get credential from CLI credentials file: ' . $profileFile);
|
||||
}
|
||||
/**
|
||||
* Get credential.
|
||||
*
|
||||
* @return Credentials
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getCredentials()
|
||||
{
|
||||
if (Helper::envNotEmpty('ALIBABA_CLOUD_CLI_PROFILE_DISABLED') && Helper::env('ALIBABA_CLOUD_CLI_PROFILE_DISABLED') === true) {
|
||||
throw new RuntimeException('CLI credentials file is disabled');
|
||||
}
|
||||
$cliProfileFile = self::getDefaultFile();
|
||||
if ($this->shouldReloadCredentialsProvider()) {
|
||||
$this->credentialsProvider = $this->reloadCredentialsProvider($cliProfileFile, $this->profileName);
|
||||
}
|
||||
|
||||
$credentials = $this->credentialsProvider->getCredentials();
|
||||
return new Credentials([
|
||||
'accessKeyId' => $credentials->getAccessKeyId(),
|
||||
'accessKeySecret' => $credentials->getAccessKeySecret(),
|
||||
'securityToken' => $credentials->getSecurityToken(),
|
||||
'providerName' => $this->getProviderName() . '/' . $this->credentialsProvider->getProviderName(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default credential file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getDefaultFile()
|
||||
{
|
||||
return Helper::getHomeDirectory() .
|
||||
DIRECTORY_SEPARATOR .
|
||||
'.aliyun' .
|
||||
DIRECTORY_SEPARATOR .
|
||||
'config.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProviderName()
|
||||
{
|
||||
return 'cli_profile';
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,12 @@
|
||||
namespace AlibabaCloud\Credentials\Providers;
|
||||
|
||||
use AlibabaCloud\Credentials\Credentials;
|
||||
use AlibabaCloud\Credentials\Utils\Helper;
|
||||
use AlibabaCloud\Credentials\Helper;
|
||||
use Closure;
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Class ChainProvider
|
||||
*
|
||||
* @package AlibabaCloud\Credentials\Providers
|
||||
@@ -185,4 +184,4 @@ class ChainProvider
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Providers;
|
||||
|
||||
/**
|
||||
* @internal This class is intended for internal use within the package.
|
||||
* Class Credentials
|
||||
*
|
||||
* @package AlibabaCloud\Credentials\Providers
|
||||
*/
|
||||
class Credentials
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $accessKeyId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $accessKeySecret;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $securityToken;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $expiration;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $providerName;
|
||||
|
||||
public function __construct($config = [])
|
||||
{
|
||||
if (!empty($config)) {
|
||||
foreach ($config as $k => $v) {
|
||||
$this->{$k} = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAccessKeyId()
|
||||
{
|
||||
return $this->accessKeyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAccessKeySecret()
|
||||
{
|
||||
return $this->accessKeySecret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSecurityToken()
|
||||
{
|
||||
return $this->securityToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getExpiration()
|
||||
{
|
||||
return $this->expiration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProviderName()
|
||||
{
|
||||
return $this->providerName;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Providers;
|
||||
|
||||
|
||||
/**
|
||||
* @internal This class is intended for internal use within the package.
|
||||
* Interface CredentialsInterface
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
interface CredentialsProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* @return Credentials
|
||||
*/
|
||||
public function getCredentials();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProviderName();
|
||||
}
|
||||
@@ -1,175 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Providers;
|
||||
|
||||
use AlibabaCloud\Credentials\Utils\Filter;
|
||||
use AlibabaCloud\Credentials\Utils\Helper;
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @internal This class is intended for internal use within the package.
|
||||
* Class DefaultCredentialsProvider
|
||||
*
|
||||
* @package AlibabaCloud\Credentials\Providers
|
||||
*/
|
||||
class DefaultCredentialsProvider implements CredentialsProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private static $defaultProviders = [];
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $reuseLastProviderEnabled;
|
||||
|
||||
/**
|
||||
* @var CredentialsProvider
|
||||
*/
|
||||
private $lastUsedCredentialsProvider;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private static $customChain = [];
|
||||
|
||||
/**
|
||||
* DefaultCredentialsProvider constructor.
|
||||
* @param array $params
|
||||
*/
|
||||
public function __construct(array $params = [])
|
||||
{
|
||||
$this->filterReuseLastProviderEnabled($params);
|
||||
$this->createDefaultChain();
|
||||
Filter::reuseLastProviderEnabled($this->reuseLastProviderEnabled);
|
||||
}
|
||||
|
||||
private function filterReuseLastProviderEnabled(array $params)
|
||||
{
|
||||
$this->reuseLastProviderEnabled = true;
|
||||
if (isset($params['reuseLastProviderEnabled'])) {
|
||||
$this->reuseLastProviderEnabled = $params['reuseLastProviderEnabled'];
|
||||
}
|
||||
}
|
||||
|
||||
private function createDefaultChain()
|
||||
{
|
||||
self::$defaultProviders = [
|
||||
new EnvironmentVariableCredentialsProvider(),
|
||||
];
|
||||
if (
|
||||
Helper::envNotEmpty('ALIBABA_CLOUD_ROLE_ARN')
|
||||
&& Helper::envNotEmpty('ALIBABA_CLOUD_OIDC_PROVIDER_ARN')
|
||||
&& Helper::envNotEmpty('ALIBABA_CLOUD_OIDC_TOKEN_FILE')
|
||||
) {
|
||||
array_push(
|
||||
self::$defaultProviders,
|
||||
new OIDCRoleArnCredentialsProvider()
|
||||
);
|
||||
}
|
||||
array_push(
|
||||
self::$defaultProviders,
|
||||
new CLIProfileCredentialsProvider()
|
||||
);
|
||||
array_push(
|
||||
self::$defaultProviders,
|
||||
new ProfileCredentialsProvider()
|
||||
);
|
||||
array_push(
|
||||
self::$defaultProviders,
|
||||
new EcsRamRoleCredentialsProvider()
|
||||
);
|
||||
if (Helper::envNotEmpty('ALIBABA_CLOUD_CREDENTIALS_URI')) {
|
||||
array_push(
|
||||
self::$defaultProviders,
|
||||
new URLCredentialsProvider()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CredentialsProvider ...$providers
|
||||
*/
|
||||
public static function set(...$providers)
|
||||
{
|
||||
if (empty($providers)) {
|
||||
throw new InvalidArgumentException('No providers in chain');
|
||||
}
|
||||
|
||||
foreach ($providers as $provider) {
|
||||
if (!$provider instanceof CredentialsProvider) {
|
||||
throw new InvalidArgumentException('Providers must all be CredentialsProvider');
|
||||
}
|
||||
}
|
||||
|
||||
self::$customChain = $providers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public static function hasCustomChain()
|
||||
{
|
||||
return (bool) self::$customChain;
|
||||
}
|
||||
|
||||
public static function flush()
|
||||
{
|
||||
self::$customChain = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get credential.
|
||||
*
|
||||
* @return Credentials
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getCredentials()
|
||||
{
|
||||
if ($this->reuseLastProviderEnabled && !is_null($this->lastUsedCredentialsProvider)) {
|
||||
$credentials = $this->lastUsedCredentialsProvider->getCredentials();
|
||||
return new Credentials([
|
||||
'accessKeyId' => $credentials->getAccessKeyId(),
|
||||
'accessKeySecret' => $credentials->getAccessKeySecret(),
|
||||
'securityToken' => $credentials->getSecurityToken(),
|
||||
'providerName' => $this->getProviderName() . '/' . $this->lastUsedCredentialsProvider->getProviderName(),
|
||||
]);
|
||||
}
|
||||
|
||||
$providerChain = array_merge(
|
||||
self::$customChain,
|
||||
self::$defaultProviders
|
||||
);
|
||||
|
||||
$exceptionMessages = [];
|
||||
|
||||
foreach ($providerChain as $provider) {
|
||||
try {
|
||||
$credentials = $provider->getCredentials();
|
||||
$this->lastUsedCredentialsProvider = $provider;
|
||||
return new Credentials([
|
||||
'accessKeyId' => $credentials->getAccessKeyId(),
|
||||
'accessKeySecret' => $credentials->getAccessKeySecret(),
|
||||
'securityToken' => $credentials->getSecurityToken(),
|
||||
'providerName' => $this->getProviderName() . '/' . $provider->getProviderName(),
|
||||
]);
|
||||
} catch (Exception $exception) {
|
||||
array_push($exceptionMessages, basename(str_replace('\\', '/', get_class($provider))) . ': ' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
throw new RuntimeException('Unable to load credentials from any of the providers in the chain: ' . implode(', ', $exceptionMessages));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getProviderName()
|
||||
{
|
||||
return "default";
|
||||
}
|
||||
}
|
||||
@@ -1,276 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Providers;
|
||||
|
||||
use AlibabaCloud\Credentials\Utils\Helper;
|
||||
use AlibabaCloud\Credentials\Utils\Filter;
|
||||
use AlibabaCloud\Credentials\Request\Request;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
use AlibabaCloud\Credentials\Credential\RefreshResult;
|
||||
|
||||
/**
|
||||
* @internal This class is intended for internal use within the package.
|
||||
* Class EcsRamRoleCredentialsProvider
|
||||
*
|
||||
* @package AlibabaCloud\Credentials\Providers
|
||||
*/
|
||||
class EcsRamRoleCredentialsProvider extends SessionCredentialsProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $metadataHost = 'http://100.100.100.200';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $ecsUri = '/latest/meta-data/ram/security-credentials/';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $metadataTokenUri = '/latest/api/token';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $roleName;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*/
|
||||
private $disableIMDSv1 = false;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $metadataTokenDuration = 21600;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $connectTimeout = 1;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $readTimeout = 1;
|
||||
|
||||
|
||||
/**
|
||||
* EcsRamRoleCredentialsProvider constructor.
|
||||
*
|
||||
* @param array $params
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct(array $params = [], array $options = [])
|
||||
{
|
||||
$this->filterOptions($options);
|
||||
$this->filterRoleName($params);
|
||||
$this->filterDisableECSIMDSv1($params);
|
||||
Filter::roleName($this->roleName);
|
||||
Filter::disableIMDSv1($this->disableIMDSv1);
|
||||
}
|
||||
|
||||
private function filterOptions(array $options)
|
||||
{
|
||||
if (isset($options['connectTimeout'])) {
|
||||
$this->connectTimeout = $options['connectTimeout'];
|
||||
}
|
||||
|
||||
if (isset($options['readTimeout'])) {
|
||||
$this->readTimeout = $options['readTimeout'];
|
||||
}
|
||||
|
||||
Filter::timeout($this->connectTimeout, $this->readTimeout);
|
||||
}
|
||||
|
||||
private function filterRoleName(array $params)
|
||||
{
|
||||
if (Helper::envNotEmpty('ALIBABA_CLOUD_ECS_METADATA')) {
|
||||
$this->roleName = Helper::env('ALIBABA_CLOUD_ECS_METADATA');
|
||||
}
|
||||
|
||||
if (isset($params['roleName'])) {
|
||||
$this->roleName = $params['roleName'];
|
||||
}
|
||||
}
|
||||
|
||||
private function filterDisableECSIMDSv1($params)
|
||||
{
|
||||
if (Helper::envNotEmpty('ALIBABA_CLOUD_IMDSV1_DISABLED')) {
|
||||
$this->disableIMDSv1 = Helper::env('ALIBABA_CLOUD_IMDSV1_DISABLED') === true ? true : false;
|
||||
}
|
||||
|
||||
if (isset($params['disableIMDSv1'])) {
|
||||
$this->disableIMDSv1 = $params['disableIMDSv1'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get credentials by request.
|
||||
*
|
||||
* @return RefreshResult
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function refreshCredentials()
|
||||
{
|
||||
if (Helper::envNotEmpty('ALIBABA_CLOUD_ECS_METADATA_DISABLED') && Helper::env('ALIBABA_CLOUD_ECS_METADATA_DISABLED') === true) {
|
||||
throw new RuntimeException('IMDS credentials is disabled');
|
||||
}
|
||||
|
||||
if (is_null($this->roleName) || $this->roleName === '') {
|
||||
$this->roleName = $this->getRoleNameFromMeta();
|
||||
}
|
||||
|
||||
$url = $this->metadataHost . $this->ecsUri . $this->roleName;
|
||||
$options = Request::commonOptions();
|
||||
$options['read_timeout'] = $this->readTimeout;
|
||||
$options['connect_timeout'] = $this->connectTimeout;
|
||||
|
||||
$metadataToken = $this->getMetadataToken();
|
||||
if (!is_null($metadataToken)) {
|
||||
$options['headers']['X-aliyun-ecs-metadata-token'] = $metadataToken;
|
||||
}
|
||||
|
||||
$result = Request::createClient()->request('GET', $url, $options);
|
||||
|
||||
if ($result->getStatusCode() === 404) {
|
||||
throw new InvalidArgumentException('The role was not found in the instance' . (string) $result);
|
||||
}
|
||||
|
||||
if ($result->getStatusCode() !== 200) {
|
||||
throw new RuntimeException('Error refreshing credentials from IMDS, statusCode: ' . $result->getStatusCode() . ', result: ' . (string) $result);
|
||||
}
|
||||
|
||||
$credentials = $result->toArray();
|
||||
|
||||
if (!isset($credentials['AccessKeyId']) || !isset($credentials['AccessKeySecret']) || !isset($credentials['SecurityToken'])) {
|
||||
throw new RuntimeException('Error retrieving credentials from IMDS result:' . $result->toJson());
|
||||
}
|
||||
|
||||
if (!isset($credentials['Code']) || $credentials['Code'] !== 'Success') {
|
||||
throw new RuntimeException('Error retrieving credentials from IMDS result, Code is not Success:' . $result->toJson());
|
||||
}
|
||||
|
||||
return new RefreshResult(new Credentials([
|
||||
'accessKeyId' => $credentials['AccessKeyId'],
|
||||
'accessKeySecret' => $credentials['AccessKeySecret'],
|
||||
'securityToken' => $credentials['SecurityToken'],
|
||||
'expiration' => \strtotime($credentials['Expiration']),
|
||||
'providerName' => $this->getProviderName(),
|
||||
]), $this->getStaleTime(strtotime($credentials["Expiration"])), $this->getPrefetchTime(strtotime($credentials["Expiration"])));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
private function getRoleNameFromMeta()
|
||||
{
|
||||
$options = Request::commonOptions();
|
||||
$options['read_timeout'] = $this->readTimeout;
|
||||
$options['connect_timeout'] = $this->connectTimeout;
|
||||
|
||||
$metadataToken = $this->getMetadataToken();
|
||||
if (!is_null($metadataToken)) {
|
||||
$options['headers']['X-aliyun-ecs-metadata-token'] = $metadataToken;
|
||||
}
|
||||
|
||||
$result = Request::createClient()->request(
|
||||
'GET',
|
||||
'http://100.100.100.200/latest/meta-data/ram/security-credentials/',
|
||||
$options
|
||||
);
|
||||
|
||||
if ($result->getStatusCode() === 404) {
|
||||
throw new InvalidArgumentException('The role name was not found in the instance' . (string) $result);
|
||||
}
|
||||
|
||||
if ($result->getStatusCode() !== 200) {
|
||||
throw new RuntimeException('Error retrieving role name from result: ' . (string) $result);
|
||||
}
|
||||
|
||||
$role_name = (string) $result;
|
||||
if (!$role_name) {
|
||||
throw new RuntimeException('Error retrieving role name from result is empty');
|
||||
}
|
||||
|
||||
return $role_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get metadata token by request.
|
||||
*
|
||||
* @return string
|
||||
* @throws RuntimeException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
private function getMetadataToken()
|
||||
{
|
||||
$url = $this->metadataHost . $this->metadataTokenUri;
|
||||
$options = Request::commonOptions();
|
||||
$options['read_timeout'] = $this->readTimeout;
|
||||
$options['connect_timeout'] = $this->connectTimeout;
|
||||
$options['headers']['X-aliyun-ecs-metadata-token-ttl-seconds'] = $this->metadataTokenDuration;
|
||||
|
||||
$result = Request::createClient()->request('PUT', $url, $options);
|
||||
|
||||
if ($result->getStatusCode() != 200) {
|
||||
if ($this->disableIMDSv1) {
|
||||
throw new RuntimeException('Failed to get token from ECS Metadata Service. HttpCode= ' . $result->getStatusCode());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return (string) $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public function getPrefetchTime($expiration)
|
||||
{
|
||||
return $expiration <= 0 ?
|
||||
time() + (5 * 60) :
|
||||
time() + (60 * 60);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function key()
|
||||
{
|
||||
return 'ecs_ram_role#roleName#' . $this->roleName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProviderName()
|
||||
{
|
||||
return 'ecs_ram_role';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRoleName()
|
||||
{
|
||||
return $this->roleName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDisableIMDSv1()
|
||||
{
|
||||
return $this->disableIMDSv1;
|
||||
}
|
||||
}
|
||||
94
Server/vendor/alibabacloud/credentials/src/Providers/EcsRamRoleProvider.php
vendored
Normal file
94
Server/vendor/alibabacloud/credentials/src/Providers/EcsRamRoleProvider.php
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Providers;
|
||||
|
||||
use AlibabaCloud\Credentials\Request\Request;
|
||||
use AlibabaCloud\Credentials\StsCredential;
|
||||
use Exception;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use AlibabaCloud\Tea\Response;
|
||||
use InvalidArgumentException;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Class EcsRamRoleProvider
|
||||
*
|
||||
* @package AlibabaCloud\Credentials\Providers
|
||||
*/
|
||||
class EcsRamRoleProvider extends Provider
|
||||
{
|
||||
|
||||
/**
|
||||
* Expiration time slot for temporary security credentials.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $expirationSlot = 10;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $uri = 'http://100.100.100.200/latest/meta-data/ram/security-credentials/';
|
||||
|
||||
/**
|
||||
* Get credential.
|
||||
*
|
||||
* @return StsCredential
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
$result = $this->getCredentialsInCache();
|
||||
|
||||
if ($result === null) {
|
||||
$result = $this->request();
|
||||
|
||||
if (!isset($result['AccessKeyId'], $result['AccessKeySecret'], $result['SecurityToken'])) {
|
||||
throw new RuntimeException($this->error);
|
||||
}
|
||||
|
||||
$this->cache($result->toArray());
|
||||
}
|
||||
|
||||
return new StsCredential(
|
||||
$result['AccessKeyId'],
|
||||
$result['AccessKeySecret'],
|
||||
strtotime($result['Expiration']),
|
||||
$result['SecurityToken']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get credentials by request.
|
||||
*
|
||||
* @return ResponseInterface
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function request()
|
||||
{
|
||||
$credential = $this->credential;
|
||||
$url = $this->uri . $credential->getRoleName();
|
||||
|
||||
$options = [
|
||||
'http_errors' => false,
|
||||
'timeout' => 1,
|
||||
'connect_timeout' => 1,
|
||||
];
|
||||
|
||||
$result = Request::createClient()->request('GET', $url, $options);
|
||||
|
||||
if ($result->getStatusCode() === 404) {
|
||||
$message = 'The role was not found in the instance';
|
||||
throw new InvalidArgumentException($message);
|
||||
}
|
||||
|
||||
if ($result->getStatusCode() !== 200) {
|
||||
throw new RuntimeException('Error retrieving credentials from result: ' . $result->toJson());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Providers;
|
||||
|
||||
use AlibabaCloud\Credentials\Utils\Helper;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* @internal This class is intended for internal use within the package.
|
||||
* Class EnvironmentVariableCredentialsProvider
|
||||
*
|
||||
* @package AlibabaCloud\Credentials\Providers
|
||||
*/
|
||||
class EnvironmentVariableCredentialsProvider implements CredentialsProvider
|
||||
{
|
||||
/**
|
||||
* EnvironmentVariableCredentialsProvider constructor.
|
||||
*/
|
||||
public function __construct() {}
|
||||
|
||||
/**
|
||||
* Get credential.
|
||||
*
|
||||
* @return Credentials
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function getCredentials()
|
||||
{
|
||||
if (Helper::envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_ID')) {
|
||||
$accessKeyId = Helper::env('ALIBABA_CLOUD_ACCESS_KEY_ID');
|
||||
} else {
|
||||
throw new InvalidArgumentException('Access key ID must be specified via environment variable (ALIBABA_CLOUD_ACCESS_KEY_ID)');
|
||||
}
|
||||
|
||||
if (Helper::envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_SECRET')) {
|
||||
$accessKeySecret = Helper::env('ALIBABA_CLOUD_ACCESS_KEY_SECRET');
|
||||
} else {
|
||||
throw new InvalidArgumentException('Access key Secret must be specified via environment variable (ALIBABA_CLOUD_ACCESS_KEY_SECRET)');
|
||||
}
|
||||
|
||||
if (Helper::envNotEmpty('ALIBABA_CLOUD_SECURITY_TOKEN')) {
|
||||
$securityToken = Helper::env('ALIBABA_CLOUD_SECURITY_TOKEN');
|
||||
return new Credentials([
|
||||
'accessKeyId' => $accessKeyId,
|
||||
'accessKeySecret' => $accessKeySecret,
|
||||
'securityToken' => $securityToken,
|
||||
'providerName' => $this->getProviderName(),
|
||||
]);
|
||||
}
|
||||
|
||||
return new Credentials([
|
||||
'accessKeyId' => $accessKeyId,
|
||||
'accessKeySecret' => $accessKeySecret,
|
||||
'providerName' => $this->getProviderName(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getProviderName()
|
||||
{
|
||||
return "env";
|
||||
}
|
||||
}
|
||||
@@ -1,264 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Providers;
|
||||
|
||||
use AlibabaCloud\Credentials\Utils\Helper;
|
||||
use AlibabaCloud\Credentials\Utils\Filter;
|
||||
use AlibabaCloud\Credentials\Request\Request;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
use Exception;
|
||||
use AlibabaCloud\Credentials\Credential\RefreshResult;
|
||||
|
||||
/**
|
||||
* @internal This class is intended for internal use within the package.
|
||||
* Class OIDCRoleArnCredentialsProvider
|
||||
*
|
||||
* @package AlibabaCloud\Credentials\Providers
|
||||
*/
|
||||
class OIDCRoleArnCredentialsProvider extends SessionCredentialsProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $roleArn;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $oidcProviderArn;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $oidcTokenFilePath;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $roleSessionName;
|
||||
|
||||
/**
|
||||
* @description role session expiration
|
||||
* @example 3600
|
||||
* @var int
|
||||
*/
|
||||
private $durationSeconds = 3600;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $policy;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $stsEndpoint;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $connectTimeout = 5;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $readTimeout = 5;
|
||||
|
||||
/**
|
||||
* OIDCRoleArnCredentialsProvider constructor.
|
||||
*
|
||||
* @param array $params
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct(array $params = [], array $options = [])
|
||||
{
|
||||
$this->filterOptions($options);
|
||||
$this->filterRoleArn($params);
|
||||
$this->filterOIDCProviderArn($params);
|
||||
$this->filterOIDCTokenFilePath($params);
|
||||
$this->filterRoleSessionName($params);
|
||||
$this->filterDurationSeconds($params);
|
||||
$this->filterPolicy($params);
|
||||
$this->filterSTSEndpoint($params);
|
||||
}
|
||||
|
||||
private function filterRoleArn(array $params)
|
||||
{
|
||||
if (Helper::envNotEmpty('ALIBABA_CLOUD_ROLE_ARN')) {
|
||||
$this->roleArn = Helper::env('ALIBABA_CLOUD_ROLE_ARN');
|
||||
}
|
||||
|
||||
if (isset($params['roleArn'])) {
|
||||
$this->roleArn = $params['roleArn'];
|
||||
}
|
||||
|
||||
Filter::roleArn($this->roleArn);
|
||||
}
|
||||
|
||||
private function filterOIDCProviderArn(array $params)
|
||||
{
|
||||
if (Helper::envNotEmpty('ALIBABA_CLOUD_OIDC_PROVIDER_ARN')) {
|
||||
$this->oidcProviderArn = Helper::env('ALIBABA_CLOUD_OIDC_PROVIDER_ARN');
|
||||
}
|
||||
|
||||
if (isset($params['oidcProviderArn'])) {
|
||||
$this->oidcProviderArn = $params['oidcProviderArn'];
|
||||
}
|
||||
|
||||
Filter::oidcProviderArn($this->oidcProviderArn);
|
||||
}
|
||||
|
||||
private function filterOIDCTokenFilePath(array $params)
|
||||
{
|
||||
if (Helper::envNotEmpty('ALIBABA_CLOUD_OIDC_TOKEN_FILE')) {
|
||||
$this->oidcTokenFilePath = Helper::env('ALIBABA_CLOUD_OIDC_TOKEN_FILE');
|
||||
}
|
||||
|
||||
if (isset($params['oidcTokenFilePath'])) {
|
||||
$this->oidcTokenFilePath = $params['oidcTokenFilePath'];
|
||||
}
|
||||
|
||||
Filter::oidcTokenFilePath($this->oidcTokenFilePath);
|
||||
}
|
||||
|
||||
private function filterRoleSessionName(array $params)
|
||||
{
|
||||
if (Helper::envNotEmpty('ALIBABA_CLOUD_ROLE_SESSION_NAME')) {
|
||||
$this->roleSessionName = Helper::env('ALIBABA_CLOUD_ROLE_SESSION_NAME');
|
||||
}
|
||||
|
||||
if (isset($params['roleSessionName'])) {
|
||||
$this->roleSessionName = $params['roleSessionName'];
|
||||
}
|
||||
|
||||
if (is_null($this->roleSessionName) || $this->roleSessionName === '') {
|
||||
$this->roleSessionName = 'phpSdkRoleSessionName';
|
||||
}
|
||||
}
|
||||
|
||||
private function filterDurationSeconds(array $params)
|
||||
{
|
||||
if (isset($params['durationSeconds'])) {
|
||||
if (is_int($params['durationSeconds'])) {
|
||||
$this->durationSeconds = $params['durationSeconds'];
|
||||
}
|
||||
}
|
||||
if ($this->durationSeconds < 900) {
|
||||
throw new InvalidArgumentException('Role session expiration should be in the range of 900s - max session duration');
|
||||
}
|
||||
}
|
||||
|
||||
private function filterPolicy(array $params)
|
||||
{
|
||||
if (isset($params['policy'])) {
|
||||
if (is_string($params['policy'])) {
|
||||
$this->policy = $params['policy'];
|
||||
}
|
||||
|
||||
if (is_array($params['policy'])) {
|
||||
$this->policy = json_encode($params['policy']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function filterSTSEndpoint(array $params)
|
||||
{
|
||||
if (Helper::envNotEmpty('ALIBABA_CLOUD_STS_REGION')) {
|
||||
$this->stsEndpoint = 'sts' . Helper::env('ALIBABA_CLOUD_STS_REGION') . '.aliyuncs.com';
|
||||
}
|
||||
|
||||
if (isset($params['stsRegionId'])) {
|
||||
$this->stsEndpoint = 'sts' . $params['stsRegionId'] . '.aliyuncs.com';
|
||||
}
|
||||
|
||||
if (isset($params['stsEndpoint'])) {
|
||||
$this->stsEndpoint = $params['stsEndpoint'];
|
||||
}
|
||||
|
||||
if (is_null($this->stsEndpoint) || $this->stsEndpoint === '') {
|
||||
$this->stsEndpoint = 'sts.aliyuncs.com';
|
||||
}
|
||||
}
|
||||
|
||||
private function filterOptions(array $options)
|
||||
{
|
||||
if (isset($options['connectTimeout'])) {
|
||||
$this->connectTimeout = $options['connectTimeout'];
|
||||
}
|
||||
|
||||
if (isset($options['readTimeout'])) {
|
||||
$this->readTimeout = $options['readTimeout'];
|
||||
}
|
||||
|
||||
Filter::timeout($this->connectTimeout, $this->readTimeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get credentials by request.
|
||||
*
|
||||
* @return RefreshResult
|
||||
* @throws RuntimeException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function refreshCredentials()
|
||||
{
|
||||
$options = Request::commonOptions();
|
||||
$options['read_timeout'] = $this->readTimeout;
|
||||
$options['connect_timeout'] = $this->connectTimeout;
|
||||
|
||||
$options['query']['Action'] = 'AssumeRoleWithOIDC';
|
||||
$options['query']['Version'] = '2015-04-01';
|
||||
$options['query']['Format'] = 'JSON';
|
||||
$options['query']['Timestamp'] = gmdate('Y-m-d\TH:i:s\Z');
|
||||
$options['query']['RoleArn'] = $this->roleArn;
|
||||
$options['query']['OIDCProviderArn'] = $this->oidcProviderArn;
|
||||
try {
|
||||
$oidcToken = file_get_contents($this->oidcTokenFilePath);
|
||||
$options['query']['OIDCToken'] = $oidcToken;
|
||||
} catch (Exception $exception) {
|
||||
throw new InvalidArgumentException($exception->getMessage());
|
||||
}
|
||||
$options['query']['RoleSessionName'] = $this->roleSessionName;
|
||||
$options['query']['DurationSeconds'] = (string) $this->durationSeconds;
|
||||
if (!is_null($this->policy)) {
|
||||
$options['query']['Policy'] = $this->policy;
|
||||
}
|
||||
|
||||
$url = (new Uri())->withScheme('https')->withHost($this->stsEndpoint);
|
||||
|
||||
$result = Request::createClient()->request('POST', $url, $options);
|
||||
|
||||
if ($result->getStatusCode() !== 200) {
|
||||
throw new RuntimeException('Error refreshing credentials from OIDC, statusCode: ' . $result->getStatusCode() . ', result: ' . (string) $result);
|
||||
}
|
||||
|
||||
$json = $result->toArray();
|
||||
$credentials = $json['Credentials'];
|
||||
|
||||
if (!isset($credentials['AccessKeyId']) || !isset($credentials['AccessKeySecret']) || !isset($credentials['SecurityToken'])) {
|
||||
throw new RuntimeException('Error retrieving credentials from OIDC result:' . $result->toJson());
|
||||
}
|
||||
|
||||
return new RefreshResult(new Credentials([
|
||||
'accessKeyId' => $credentials['AccessKeyId'],
|
||||
'accessKeySecret' => $credentials['AccessKeySecret'],
|
||||
'securityToken' => $credentials['SecurityToken'],
|
||||
'expiration' => \strtotime($credentials['Expiration']),
|
||||
'providerName' => $this->getProviderName(),
|
||||
]), $this->getStaleTime(strtotime($credentials['Expiration'])) );
|
||||
}
|
||||
|
||||
public function key()
|
||||
{
|
||||
return 'oidc_role_arn#roleArn#' . $this->roleArn . '#oidcProviderArn#' . $this->oidcProviderArn . '#roleSessionName#' . $this->roleSessionName;
|
||||
}
|
||||
|
||||
public function getProviderName()
|
||||
{
|
||||
return 'oidc_role_arn';
|
||||
}
|
||||
}
|
||||
@@ -1,188 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Providers;
|
||||
|
||||
use AlibabaCloud\Credentials\Utils\Helper;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* @internal This class is intended for internal use within the package.
|
||||
* Class ProfileCredentialsProvider
|
||||
*
|
||||
* @package AlibabaCloud\Credentials\Providers
|
||||
*/
|
||||
class ProfileCredentialsProvider implements CredentialsProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $profileName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $profileFile;
|
||||
|
||||
/**
|
||||
* @var CredentialsProvider
|
||||
*/
|
||||
private $credentialsProvider;
|
||||
|
||||
|
||||
/**
|
||||
* ProfileCredentialsProvider constructor.
|
||||
*
|
||||
* @param array $params
|
||||
*/
|
||||
public function __construct(array $params = [])
|
||||
{
|
||||
$this->filterProfileName($params);
|
||||
$this->filterProfileFile();
|
||||
}
|
||||
|
||||
private function filterProfileName(array $params)
|
||||
{
|
||||
if (Helper::envNotEmpty('ALIBABA_CLOUD_PROFILE')) {
|
||||
$this->profileName = Helper::env('ALIBABA_CLOUD_PROFILE');
|
||||
}
|
||||
|
||||
if (isset($params['profileName'])) {
|
||||
$this->profileName = $params['profileName'];
|
||||
}
|
||||
|
||||
if (is_null($this->profileName) || $this->profileName === '') {
|
||||
$this->profileName = 'default';
|
||||
}
|
||||
}
|
||||
|
||||
private function filterProfileFile()
|
||||
{
|
||||
$this->profileFile = Helper::envNotEmpty('ALIBABA_CLOUD_CREDENTIALS_FILE');
|
||||
|
||||
if (!$this->profileFile) {
|
||||
$this->profileFile = self::getDefaultFile();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
private function shouldReloadCredentialsProvider()
|
||||
{
|
||||
if (is_null($this->credentialsProvider)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CredentialsProvider
|
||||
*/
|
||||
private function reloadCredentialsProvider($profileFile, $profileName)
|
||||
{
|
||||
if (!Helper::inOpenBasedir($profileFile)) {
|
||||
throw new RuntimeException('Unable to open credentials file: ' . $profileFile);
|
||||
}
|
||||
|
||||
if (!\is_readable($profileFile) || !\is_file($profileFile)) {
|
||||
throw new RuntimeException('Credentials file is not readable: ' . $profileFile);
|
||||
}
|
||||
|
||||
$fileArray = \parse_ini_file($profileFile, true);
|
||||
|
||||
if (\is_array($fileArray) && !empty($fileArray)) {
|
||||
$credentialsConfigures = [];
|
||||
foreach (\array_change_key_case($fileArray) as $name => $configures) {
|
||||
if ($name === $profileName) {
|
||||
$credentialsConfigures = $configures;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (\is_array($credentialsConfigures) && !empty($credentialsConfigures)) {
|
||||
switch (Helper::unsetReturnNull($credentialsConfigures, 'type')) {
|
||||
case 'access_key':
|
||||
return new StaticAKCredentialsProvider([
|
||||
'accessKeyId' => Helper::unsetReturnNull($credentialsConfigures, 'access_key_id'),
|
||||
'accessKeySecret' => Helper::unsetReturnNull($credentialsConfigures, 'access_key_secret'),
|
||||
]);
|
||||
case 'ram_role_arn':
|
||||
$innerProvider = new StaticAKCredentialsProvider([
|
||||
'accessKeyId' => Helper::unsetReturnNull($credentialsConfigures, 'access_key_id'),
|
||||
'accessKeySecret' => Helper::unsetReturnNull($credentialsConfigures, 'access_key_secret'),
|
||||
]);
|
||||
return new RamRoleArnCredentialsProvider([
|
||||
'credentialsProvider' => $innerProvider,
|
||||
'roleArn' => Helper::unsetReturnNull($credentialsConfigures, 'role_arn'),
|
||||
'roleSessionName' => Helper::unsetReturnNull($credentialsConfigures, 'role_session_name'),
|
||||
'policy' => Helper::unsetReturnNull($credentialsConfigures, 'policy'),
|
||||
]);
|
||||
case 'ecs_ram_role':
|
||||
return new EcsRamRoleCredentialsProvider([
|
||||
'roleName' => Helper::unsetReturnNull($credentialsConfigures, 'role_name'),
|
||||
]);
|
||||
case 'oidc_role_arn':
|
||||
return new OIDCRoleArnCredentialsProvider([
|
||||
'roleArn' => Helper::unsetReturnNull($credentialsConfigures, 'role_arn'),
|
||||
'oidcProviderArn' => Helper::unsetReturnNull($credentialsConfigures, 'oidc_provider_arn'),
|
||||
'oidcTokenFilePath' => Helper::unsetReturnNull($credentialsConfigures, 'oidc_token_file_path'),
|
||||
'roleSessionName' => Helper::unsetReturnNull($credentialsConfigures, 'role_session_name'),
|
||||
'policy' => Helper::unsetReturnNull($credentialsConfigures, 'policy'),
|
||||
]);
|
||||
case 'rsa_key_pair':
|
||||
return new RsaKeyPairCredentialsProvider([
|
||||
'publicKeyId' => Helper::unsetReturnNull($credentialsConfigures, 'public_key_id'),
|
||||
'privateKeyFile' => Helper::unsetReturnNull($credentialsConfigures, 'private_key_file'),
|
||||
]);
|
||||
default:
|
||||
throw new RuntimeException('Unsupported credential type from credentials file: ' . Helper::unsetReturnNull($credentialsConfigures, 'type'));
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new RuntimeException('Failed to get credential from credentials file: ' . $profileFile);
|
||||
}
|
||||
/**
|
||||
* Get credential.
|
||||
*
|
||||
* @return Credentials
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getCredentials()
|
||||
{
|
||||
if ($this->shouldReloadCredentialsProvider()) {
|
||||
$this->credentialsProvider = $this->reloadCredentialsProvider($this->profileFile, $this->profileName);
|
||||
}
|
||||
|
||||
$credentials = $this->credentialsProvider->getCredentials();
|
||||
return new Credentials([
|
||||
'accessKeyId' => $credentials->getAccessKeyId(),
|
||||
'accessKeySecret' => $credentials->getAccessKeySecret(),
|
||||
'securityToken' => $credentials->getSecurityToken(),
|
||||
'providerName' => $this->getProviderName() . '/' . $this->credentialsProvider->getProviderName(),
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default credential file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getDefaultFile()
|
||||
{
|
||||
return Helper::getHomeDirectory() .
|
||||
DIRECTORY_SEPARATOR .
|
||||
'.alibabacloud' .
|
||||
DIRECTORY_SEPARATOR .
|
||||
'credentials';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProviderName()
|
||||
{
|
||||
return 'profile';
|
||||
}
|
||||
}
|
||||
82
Server/vendor/alibabacloud/credentials/src/Providers/Provider.php
vendored
Normal file
82
Server/vendor/alibabacloud/credentials/src/Providers/Provider.php
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Providers;
|
||||
|
||||
use AlibabaCloud\Credentials\CredentialsInterface;
|
||||
use AlibabaCloud\Credentials\EcsRamRoleCredential;
|
||||
use AlibabaCloud\Credentials\RamRoleArnCredential;
|
||||
use AlibabaCloud\Credentials\RsaKeyPairCredential;
|
||||
|
||||
abstract class Provider
|
||||
{
|
||||
/**
|
||||
* For TSC Duration Seconds
|
||||
*/
|
||||
const DURATION_SECONDS = 3600;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $credentialsCache = [];
|
||||
|
||||
/**
|
||||
* Expiration time slot for temporary security credentials.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $expirationSlot = 180;
|
||||
|
||||
/**
|
||||
* @var RamRoleArnCredential|RsaKeyPairCredential|EcsRamRoleCredential
|
||||
*/
|
||||
protected $credential;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $error = 'Result contains no credentials';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $config = [];
|
||||
|
||||
/**
|
||||
* CredentialTrait constructor.
|
||||
*
|
||||
* @param CredentialsInterface $credential
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct(CredentialsInterface $credential, $config = [])
|
||||
{
|
||||
$this->credential = $credential;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the credentials from the cache in the validity period.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function getCredentialsInCache()
|
||||
{
|
||||
if (isset(self::$credentialsCache[(string)$this->credential])) {
|
||||
$result = self::$credentialsCache[(string)$this->credential];
|
||||
if (\strtotime($result['Expiration']) - \time() >= $this->expirationSlot) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache credentials.
|
||||
*
|
||||
* @param array $credential
|
||||
*/
|
||||
protected function cache(array $credential)
|
||||
{
|
||||
self::$credentialsCache[(string)$this->credential] = $credential;
|
||||
}
|
||||
}
|
||||
@@ -1,317 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Providers;
|
||||
|
||||
use AlibabaCloud\Credentials\Utils\Helper;
|
||||
use AlibabaCloud\Credentials\Utils\Filter;
|
||||
use AlibabaCloud\Credentials\Request\Request;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
use AlibabaCloud\Credentials\Credential\RefreshResult;
|
||||
|
||||
/**
|
||||
* @internal This class is intended for internal use within the package.
|
||||
* Class RamRoleArnCredentialsProvider
|
||||
*
|
||||
* @package AlibabaCloud\Credentials\Providers
|
||||
*/
|
||||
class RamRoleArnCredentialsProvider extends SessionCredentialsProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* @var CredentialsProvider
|
||||
*/
|
||||
private $credentialsProvider;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $roleArn;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $roleSessionName;
|
||||
|
||||
/**
|
||||
* @description role session expiration
|
||||
* @example 3600
|
||||
* @var int
|
||||
*/
|
||||
private $durationSeconds = 3600;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $externalId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $policy;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $stsEndpoint;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $connectTimeout = 5;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $readTimeout = 5;
|
||||
|
||||
/**
|
||||
* RamRoleArnCredentialsProvider constructor.
|
||||
*
|
||||
* @param array $params
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct(array $params = [], array $options = [])
|
||||
{
|
||||
$this->filterOptions($options);
|
||||
$this->filterCredentials($params);
|
||||
$this->filterRoleArn($params);
|
||||
$this->filterRoleSessionName($params);
|
||||
$this->filterDurationSeconds($params);
|
||||
$this->filterPolicy($params);
|
||||
$this->filterExternalId($params);
|
||||
$this->filterSTSEndpoint($params);
|
||||
}
|
||||
|
||||
private function filterRoleArn(array $params)
|
||||
{
|
||||
if (Helper::envNotEmpty('ALIBABA_CLOUD_ROLE_ARN')) {
|
||||
$this->roleArn = Helper::env('ALIBABA_CLOUD_ROLE_ARN');
|
||||
}
|
||||
|
||||
if (isset($params['roleArn'])) {
|
||||
$this->roleArn = $params['roleArn'];
|
||||
}
|
||||
|
||||
Filter::roleArn($this->roleArn);
|
||||
}
|
||||
|
||||
private function filterRoleSessionName(array $params)
|
||||
{
|
||||
if (Helper::envNotEmpty('ALIBABA_CLOUD_ROLE_SESSION_NAME')) {
|
||||
$this->roleSessionName = Helper::env('ALIBABA_CLOUD_ROLE_SESSION_NAME');
|
||||
}
|
||||
|
||||
if (isset($params['roleSessionName'])) {
|
||||
$this->roleSessionName = $params['roleSessionName'];
|
||||
}
|
||||
|
||||
if (is_null($this->roleSessionName) || $this->roleSessionName === '') {
|
||||
$this->roleSessionName = 'phpSdkRoleSessionName';
|
||||
}
|
||||
}
|
||||
|
||||
private function filterDurationSeconds(array $params)
|
||||
{
|
||||
if (isset($params['durationSeconds'])) {
|
||||
if (is_int($params['durationSeconds'])) {
|
||||
$this->durationSeconds = $params['durationSeconds'];
|
||||
}
|
||||
}
|
||||
if ($this->durationSeconds < 900) {
|
||||
throw new InvalidArgumentException('Role session expiration should be in the range of 900s - max session duration');
|
||||
}
|
||||
}
|
||||
|
||||
private function filterPolicy(array $params)
|
||||
{
|
||||
if (isset($params['policy'])) {
|
||||
if (is_string($params['policy'])) {
|
||||
$this->policy = $params['policy'];
|
||||
}
|
||||
|
||||
if (is_array($params['policy'])) {
|
||||
$this->policy = json_encode($params['policy']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function filterExternalId(array $params)
|
||||
{
|
||||
if (isset($params['externalId'])) {
|
||||
if (is_string($params['externalId'])) {
|
||||
$this->externalId = $params['externalId'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function filterSTSEndpoint(array $params)
|
||||
{
|
||||
if (Helper::envNotEmpty('ALIBABA_CLOUD_STS_REGION')) {
|
||||
$this->stsEndpoint = 'sts.' . Helper::env('ALIBABA_CLOUD_STS_REGION') . '.aliyuncs.com';
|
||||
}
|
||||
|
||||
if (isset($params['stsRegionId'])) {
|
||||
$this->stsEndpoint = 'sts.' . $params['stsRegionId'] . '.aliyuncs.com';
|
||||
}
|
||||
|
||||
if (isset($params['stsEndpoint'])) {
|
||||
$this->stsEndpoint = $params['stsEndpoint'];
|
||||
}
|
||||
|
||||
if (is_null($this->stsEndpoint) || $this->stsEndpoint === '') {
|
||||
$this->stsEndpoint = 'sts.aliyuncs.com';
|
||||
}
|
||||
}
|
||||
|
||||
private function filterCredentials(array $params)
|
||||
{
|
||||
if (isset($params['credentialsProvider'])) {
|
||||
if (!($params['credentialsProvider'] instanceof CredentialsProvider)) {
|
||||
throw new InvalidArgumentException('Invalid credentialsProvider option for ram_role_arn');
|
||||
}
|
||||
$this->credentialsProvider = $params['credentialsProvider'];
|
||||
} else if (isset($params['accessKeyId']) && isset($params['accessKeySecret']) && isset($params['securityToken'])) {
|
||||
Filter::accessKey($params['accessKeyId'], $params['accessKeySecret']);
|
||||
Filter::securityToken($params['securityToken']);
|
||||
$this->credentialsProvider = new StaticSTSCredentialsProvider($params);
|
||||
} else if (isset($params['accessKeyId']) && isset($params['accessKeySecret'])) {
|
||||
Filter::accessKey($params['accessKeyId'], $params['accessKeySecret']);
|
||||
$this->credentialsProvider = new StaticAKCredentialsProvider($params);
|
||||
} else {
|
||||
throw new InvalidArgumentException('Missing required credentials option for ram_role_arn');
|
||||
}
|
||||
}
|
||||
|
||||
private function filterOptions(array $options)
|
||||
{
|
||||
if (isset($options['connectTimeout'])) {
|
||||
$this->connectTimeout = $options['connectTimeout'];
|
||||
}
|
||||
|
||||
if (isset($options['readTimeout'])) {
|
||||
$this->readTimeout = $options['readTimeout'];
|
||||
}
|
||||
|
||||
Filter::timeout($this->connectTimeout, $this->readTimeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get credentials by request.
|
||||
*
|
||||
* @return RefreshResult
|
||||
* @throws RuntimeException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function refreshCredentials()
|
||||
{
|
||||
$options = Request::commonOptions();
|
||||
$options['read_timeout'] = $this->readTimeout;
|
||||
$options['connect_timeout'] = $this->connectTimeout;
|
||||
|
||||
$options['query']['Action'] = 'AssumeRole';
|
||||
$options['query']['Version'] = '2015-04-01';
|
||||
$options['query']['Format'] = 'JSON';
|
||||
$options['query']['Timestamp'] = gmdate('Y-m-d\TH:i:s\Z');
|
||||
$options['query']['SignatureMethod'] = 'HMAC-SHA1';
|
||||
$options['query']['SignatureVersion'] = '1.0';
|
||||
$options['query']['SignatureNonce'] = Request::uuid(json_encode($options['query']));
|
||||
$options['query']['RoleArn'] = $this->roleArn;
|
||||
$options['query']['RoleSessionName'] = $this->roleSessionName;
|
||||
$options['query']['DurationSeconds'] = (string) $this->durationSeconds;
|
||||
if (!is_null($this->policy) && $this->policy !== '') {
|
||||
$options['query']['Policy'] = $this->policy;
|
||||
}
|
||||
if (!is_null($this->externalId) && $this->externalId !== '') {
|
||||
$options['query']['ExternalId'] = $this->externalId;
|
||||
}
|
||||
|
||||
$sessionCredentials = $this->credentialsProvider->getCredentials();
|
||||
$options['query']['AccessKeyId'] = $sessionCredentials->getAccessKeyId();
|
||||
if (!is_null($sessionCredentials->getSecurityToken())) {
|
||||
$options['query']['SecurityToken'] = $sessionCredentials->getSecurityToken();
|
||||
}
|
||||
$options['query']['Signature'] = Request::shaHmac1sign(
|
||||
Request::signString('GET', $options['query']),
|
||||
$sessionCredentials->getAccessKeySecret() . '&'
|
||||
);
|
||||
|
||||
$url = (new Uri())->withScheme('https')->withHost($this->stsEndpoint);
|
||||
|
||||
$result = Request::createClient()->request('GET', $url, $options);
|
||||
|
||||
if ($result->getStatusCode() !== 200) {
|
||||
throw new RuntimeException('Error refreshing credentials from RamRoleArn, statusCode: ' . $result->getStatusCode() . ', result: ' . (string) $result);
|
||||
}
|
||||
|
||||
$json = $result->toArray();
|
||||
$credentials = $json['Credentials'];
|
||||
|
||||
if (!isset($credentials['AccessKeyId']) || !isset($credentials['AccessKeySecret']) || !isset($credentials['SecurityToken'])) {
|
||||
throw new RuntimeException('Error retrieving credentials from RamRoleArn result:' . $result->toJson());
|
||||
}
|
||||
|
||||
return new RefreshResult(new Credentials([
|
||||
'accessKeyId' => $credentials['AccessKeyId'],
|
||||
'accessKeySecret' => $credentials['AccessKeySecret'],
|
||||
'securityToken' => $credentials['SecurityToken'],
|
||||
'expiration' => \strtotime($credentials['Expiration']),
|
||||
'providerName' => $this->getProviderName(),
|
||||
]), $this->getStaleTime(strtotime($credentials['Expiration'])));
|
||||
}
|
||||
|
||||
public function key()
|
||||
{
|
||||
$credentials = $this->credentialsProvider->getCredentials();
|
||||
return 'ram_role_arn#credential#' . $credentials->getAccessKeyId() . '#roleArn#' . $this->roleArn . '#roleSessionName#' . $this->roleSessionName;
|
||||
}
|
||||
|
||||
public function getProviderName()
|
||||
{
|
||||
return 'ram_role_arn/' . $this->credentialsProvider->getProviderName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRoleArn()
|
||||
{
|
||||
return $this->roleArn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRoleSessionName()
|
||||
{
|
||||
return $this->roleSessionName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPolicy()
|
||||
{
|
||||
return $this->policy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return string
|
||||
*/
|
||||
public function getOriginalAccessKeyId()
|
||||
{
|
||||
return $this->credentialsProvider->getCredentials()->getAccessKeyId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return string
|
||||
*/
|
||||
public function getOriginalAccessKeySecret()
|
||||
{
|
||||
return $this->credentialsProvider->getCredentials()->getAccessKeySecret();
|
||||
}
|
||||
}
|
||||
49
Server/vendor/alibabacloud/credentials/src/Providers/RamRoleArnProvider.php
vendored
Normal file
49
Server/vendor/alibabacloud/credentials/src/Providers/RamRoleArnProvider.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Providers;
|
||||
|
||||
use AlibabaCloud\Credentials\Request\AssumeRole;
|
||||
use AlibabaCloud\Credentials\StsCredential;
|
||||
use Exception;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use RuntimeException;
|
||||
|
||||
class RamRoleArnProvider extends Provider
|
||||
{
|
||||
|
||||
/**
|
||||
* Get credential.
|
||||
*
|
||||
* @return StsCredential
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
$credential = $this->getCredentialsInCache();
|
||||
|
||||
if (null === $credential) {
|
||||
$result = (new AssumeRole($this->credential))->request();
|
||||
|
||||
if ($result->getStatusCode() !== 200) {
|
||||
throw new RuntimeException(isset($result['Message']) ? $result['Message'] : (string)$result->getBody());
|
||||
}
|
||||
|
||||
if (!isset($result['Credentials']['AccessKeyId'],
|
||||
$result['Credentials']['AccessKeySecret'],
|
||||
$result['Credentials']['SecurityToken'])) {
|
||||
throw new RuntimeException($this->error);
|
||||
}
|
||||
|
||||
$credential = $result['Credentials'];
|
||||
$this->cache($credential);
|
||||
}
|
||||
|
||||
return new StsCredential(
|
||||
$credential['AccessKeyId'],
|
||||
$credential['AccessKeySecret'],
|
||||
strtotime($credential['Expiration']),
|
||||
$credential['SecurityToken']
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,200 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Providers;
|
||||
|
||||
use AlibabaCloud\Credentials\Utils\Helper;
|
||||
use AlibabaCloud\Credentials\Utils\Filter;
|
||||
use AlibabaCloud\Credentials\Request\Request;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use AlibabaCloud\Credentials\Credential\RefreshResult;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @internal This class is intended for internal use within the package.
|
||||
* Class RsaKeyPairCredentialsProvider
|
||||
*
|
||||
* @package AlibabaCloud\Credentials\Providers
|
||||
*/
|
||||
class RsaKeyPairCredentialsProvider extends SessionCredentialsProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $publicKeyId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $privateKey;
|
||||
|
||||
/**
|
||||
* @description role session expiration
|
||||
* @example 3600
|
||||
* @var int
|
||||
*/
|
||||
private $durationSeconds = 3600;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $stsEndpoint;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $connectTimeout = 5;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $readTimeout = 5;
|
||||
|
||||
/**
|
||||
* RsaKeyPairCredentialsProvider constructor.
|
||||
*
|
||||
* @param array $params
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct(array $params = [], array $options = [])
|
||||
{
|
||||
$this->filterOptions($options);
|
||||
$this->filterDurationSeconds($params);
|
||||
$this->filterSTSEndpoint($params);
|
||||
$this->publicKeyId = isset($params['publicKeyId']) ? $params['publicKeyId'] : null;
|
||||
$privateKeyFile = isset($params['privateKeyFile']) ? $params['privateKeyFile'] : null;
|
||||
Filter::publicKeyId($this->publicKeyId);
|
||||
Filter::privateKeyFile($privateKeyFile);
|
||||
|
||||
try {
|
||||
$this->privateKey = file_get_contents($privateKeyFile);
|
||||
} catch (Exception $exception) {
|
||||
throw new InvalidArgumentException($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private function filterOptions(array $options)
|
||||
{
|
||||
if (isset($options['connectTimeout'])) {
|
||||
$this->connectTimeout = $options['connectTimeout'];
|
||||
}
|
||||
|
||||
if (isset($options['readTimeout'])) {
|
||||
$this->readTimeout = $options['readTimeout'];
|
||||
}
|
||||
|
||||
Filter::timeout($this->connectTimeout, $this->readTimeout);
|
||||
}
|
||||
|
||||
private function filterDurationSeconds(array $params)
|
||||
{
|
||||
if (isset($params['durationSeconds'])) {
|
||||
if (is_int($params['durationSeconds'])) {
|
||||
$this->durationSeconds = $params['durationSeconds'];
|
||||
}
|
||||
}
|
||||
if ($this->durationSeconds < 900) {
|
||||
throw new InvalidArgumentException('Role session expiration should be in the range of 900s - max session duration');
|
||||
}
|
||||
}
|
||||
|
||||
private function filterSTSEndpoint(array $params)
|
||||
{
|
||||
if (isset($params['stsEndpoint'])) {
|
||||
$this->stsEndpoint = $params['stsEndpoint'];
|
||||
}
|
||||
|
||||
if (is_null($this->stsEndpoint) || $this->stsEndpoint === '') {
|
||||
$this->stsEndpoint = 'sts.ap-northeast-1.aliyuncs.com';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get credentials by request.
|
||||
*
|
||||
* @return RefreshResult
|
||||
* @throws RuntimeException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function refreshCredentials()
|
||||
{
|
||||
$options = Request::commonOptions();
|
||||
$options['read_timeout'] = $this->readTimeout;
|
||||
$options['connect_timeout'] = $this->connectTimeout;
|
||||
|
||||
$options['query']['Action'] = 'GenerateSessionAccessKey';
|
||||
$options['query']['Version'] = '2015-04-01';
|
||||
$options['query']['Format'] = 'JSON';
|
||||
$options['query']['Timestamp'] = gmdate('Y-m-d\TH:i:s\Z');
|
||||
$options['query']['SignatureMethod'] = 'SHA256withRSA';
|
||||
$options['query']['SignatureType'] = 'PRIVATEKEY';
|
||||
$options['query']['SignatureVersion'] = '1.0';
|
||||
$options['query']['SignatureNonce'] = Request::uuid(json_encode($options['query']));
|
||||
$options['query']['DurationSeconds'] = (string) $this->durationSeconds;
|
||||
$options['query']['AccessKeyId'] = $this->publicKeyId;
|
||||
$options['query']['Signature'] = Request::shaHmac256WithRsasign(
|
||||
Request::signString('GET', $options['query']),
|
||||
$this->privateKey
|
||||
);
|
||||
|
||||
$url = (new Uri())->withScheme('https')->withHost($this->stsEndpoint);
|
||||
|
||||
$result = Request::createClient()->request('GET', $url, $options);
|
||||
|
||||
if ($result->getStatusCode() !== 200) {
|
||||
throw new RuntimeException('Error refreshing credentials from RsaKeyPair, statusCode: ' . $result->getStatusCode() . ', result: ' . (string) $result);
|
||||
}
|
||||
|
||||
$json = $result->toArray();
|
||||
|
||||
if (!isset($json['SessionAccessKey']['SessionAccessKeyId']) || !isset($json['SessionAccessKey']['SessionAccessKeySecret'])) {
|
||||
throw new RuntimeException('Error retrieving credentials from RsaKeyPair result:' . $result->toJson());
|
||||
}
|
||||
|
||||
$credentials = [];
|
||||
$credentials['AccessKeyId'] = $json['SessionAccessKey']['SessionAccessKeyId'];
|
||||
$credentials['AccessKeySecret'] = $json['SessionAccessKey']['SessionAccessKeySecret'];
|
||||
$credentials['Expiration'] = $json['SessionAccessKey']['Expiration'];
|
||||
$credentials['SecurityToken'] = null;
|
||||
|
||||
|
||||
return new RefreshResult(new Credentials([
|
||||
'accessKeyId' => $credentials['AccessKeyId'],
|
||||
'accessKeySecret' => $credentials['AccessKeySecret'],
|
||||
'securityToken' => $credentials['SecurityToken'],
|
||||
'expiration' => \strtotime($credentials['Expiration']),
|
||||
'providerName' => $this->getProviderName(),
|
||||
]), $this->getStaleTime(strtotime($credentials['Expiration'])));
|
||||
}
|
||||
|
||||
public function key()
|
||||
{
|
||||
return 'rsa_key_pair#publicKeyId#' . $this->publicKeyId;
|
||||
}
|
||||
|
||||
public function getProviderName()
|
||||
{
|
||||
return 'rsa_key_pair';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPublicKeyId()
|
||||
{
|
||||
return $this->publicKeyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPrivateKey()
|
||||
{
|
||||
return $this->privateKey;
|
||||
}
|
||||
}
|
||||
53
Server/vendor/alibabacloud/credentials/src/Providers/RsaKeyPairProvider.php
vendored
Normal file
53
Server/vendor/alibabacloud/credentials/src/Providers/RsaKeyPairProvider.php
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Providers;
|
||||
|
||||
use AlibabaCloud\Credentials\Request\GenerateSessionAccessKey;
|
||||
use AlibabaCloud\Credentials\StsCredential;
|
||||
use Exception;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Class RsaKeyPairProvider
|
||||
*
|
||||
* @package AlibabaCloud\Credentials\Providers
|
||||
*/
|
||||
class RsaKeyPairProvider extends Provider
|
||||
{
|
||||
|
||||
/**
|
||||
* Get credential.
|
||||
*
|
||||
*
|
||||
* @return StsCredential
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
$credential = $this->getCredentialsInCache();
|
||||
|
||||
if ($credential === null) {
|
||||
$result = (new GenerateSessionAccessKey($this->credential))->request();
|
||||
|
||||
if ($result->getStatusCode() !== 200) {
|
||||
throw new RuntimeException(isset($result['Message']) ? $result['Message'] : (string)$result->getBody());
|
||||
}
|
||||
|
||||
if (!isset($result['SessionAccessKey']['SessionAccessKeyId'],
|
||||
$result['SessionAccessKey']['SessionAccessKeySecret'])) {
|
||||
throw new RuntimeException($this->error);
|
||||
}
|
||||
|
||||
$credential = $result['SessionAccessKey'];
|
||||
$this->cache($credential);
|
||||
}
|
||||
|
||||
return new StsCredential(
|
||||
$credential['SessionAccessKeyId'],
|
||||
$credential['SessionAccessKeySecret'],
|
||||
strtotime($credential['Expiration'])
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,161 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Providers;
|
||||
|
||||
use AlibabaCloud\Credentials\Credential\RefreshResult;
|
||||
|
||||
abstract class SessionCredentialsProvider implements CredentialsProvider
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $credentialsCache = [];
|
||||
|
||||
/**
|
||||
* Expiration time slot for temporary security credentials.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $expirationSlot = 180;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $error = 'Result contains no credentials';
|
||||
|
||||
/**
|
||||
* Get the credentials from the cache in the validity period.
|
||||
*
|
||||
* @return RefreshResult|null
|
||||
*/
|
||||
protected function getCredentialsInCache()
|
||||
{
|
||||
if (isset(self::$credentialsCache[$this->key()])) {
|
||||
$result = self::$credentialsCache[$this->key()];
|
||||
return $result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache credentials.
|
||||
*
|
||||
* @param RefreshResult $credential
|
||||
*/
|
||||
protected function cache(RefreshResult $credential)
|
||||
{
|
||||
self::$credentialsCache[$this->key()] = $credential;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get credential.
|
||||
*
|
||||
* @return Credentials
|
||||
*/
|
||||
public function getCredentials()
|
||||
{
|
||||
if ($this->cacheIsStale() || $this->shouldInitiateCachePrefetch()) {
|
||||
$result = $this->refreshCache();
|
||||
$this->cache($result);
|
||||
}
|
||||
|
||||
$result = $this->getCredentialsInCache();
|
||||
|
||||
return $result->credentials();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return RefreshResult
|
||||
*/
|
||||
protected function refreshCache()
|
||||
{
|
||||
try {
|
||||
return $this->handleFetchedSuccess($this->refreshCredentials());
|
||||
} catch (\Exception $e) {
|
||||
return $this->handleFetchedFailure($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return RefreshResult
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function handleFetchedFailure(\Exception $e)
|
||||
{
|
||||
$currentCachedValue = $this->getCredentialsInCache();
|
||||
if (is_null($currentCachedValue)) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if (time() < $currentCachedValue->staleTime()) {
|
||||
return $currentCachedValue;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
/**
|
||||
* @return RefreshResult
|
||||
*/
|
||||
protected function handleFetchedSuccess(RefreshResult $value)
|
||||
{
|
||||
$now = time();
|
||||
// 过期时间大于15分钟,不用管
|
||||
if ($now < $value->staleTime()) {
|
||||
return $value;
|
||||
}
|
||||
// 不足或等于15分钟,但未过期,下次会再次刷新
|
||||
if ($now < $value->staleTime() + 15 * 60) {
|
||||
$value->staleTime = $now;
|
||||
return $value;
|
||||
}
|
||||
// 已过期,看缓存,缓存若大于15分钟,返回缓存,若小于15分钟,则稍后重试
|
||||
if (is_null($this->getCredentialsInCache())) {
|
||||
throw new \Exception("The fetched credentials have expired and no cache is available.");
|
||||
} else if ($now < $this->getCredentialsInCache()->staleTime()) {
|
||||
return $this->getCredentialsInCache();
|
||||
} else {
|
||||
// 返回成功,延长有效期 1 分钟
|
||||
$expectation = mt_rand(50, 70);
|
||||
$value->staleTime = time() + $expectation;
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function cacheIsStale()
|
||||
{
|
||||
return is_null($this->getCredentialsInCache()) || time() >= $this->getCredentialsInCache()->staleTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function shouldInitiateCachePrefetch()
|
||||
{
|
||||
return is_null($this->getCredentialsInCache()) || time() >= $this->getCredentialsInCache()->prefetchTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStaleTime($expiration)
|
||||
{
|
||||
return $expiration <= 0 ?
|
||||
time() + (60 * 60) :
|
||||
$expiration - (15 * 60);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return RefreshResult
|
||||
*/
|
||||
abstract function refreshCredentials();
|
||||
|
||||
/**
|
||||
* Get the toString of the credentials provider as the key.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract function key();
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Providers;
|
||||
|
||||
use AlibabaCloud\Credentials\Utils\Helper;
|
||||
use AlibabaCloud\Credentials\Utils\Filter;
|
||||
|
||||
/**
|
||||
* @internal This class is intended for internal use within the package.
|
||||
* Class StaticAKCredentialsProvider
|
||||
*
|
||||
* @package AlibabaCloud\Credentials\Providers
|
||||
*/
|
||||
class StaticAKCredentialsProvider implements CredentialsProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $accessKeyId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $accessKeySecret;
|
||||
|
||||
/**
|
||||
* StaticAKCredentialsProvider constructor.
|
||||
*
|
||||
* @param array $params
|
||||
*/
|
||||
public function __construct(array $params = [])
|
||||
{
|
||||
$this->filterAK($params);
|
||||
}
|
||||
|
||||
private function filterAK(array $params)
|
||||
{
|
||||
if (Helper::envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_ID')) {
|
||||
$this->accessKeyId = Helper::env('ALIBABA_CLOUD_ACCESS_KEY_ID');
|
||||
}
|
||||
|
||||
if (Helper::envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_SECRET')) {
|
||||
$this->accessKeySecret = Helper::env('ALIBABA_CLOUD_ACCESS_KEY_SECRET');
|
||||
}
|
||||
|
||||
if (isset($params['accessKeyId'])) {
|
||||
$this->accessKeyId = $params['accessKeyId'];
|
||||
}
|
||||
if (isset($params['accessKeySecret'])) {
|
||||
$this->accessKeySecret = $params['accessKeySecret'];
|
||||
}
|
||||
|
||||
Filter::accessKey($this->accessKeyId, $this->accessKeySecret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get credential.
|
||||
*
|
||||
* @return Credentials
|
||||
*/
|
||||
public function getCredentials()
|
||||
{
|
||||
return new Credentials([
|
||||
'accessKeyId' => $this->accessKeyId,
|
||||
'accessKeySecret' => $this->accessKeySecret,
|
||||
'providerName' => $this->getProviderName(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getProviderName()
|
||||
{
|
||||
return "static_ak";
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Providers;
|
||||
|
||||
use AlibabaCloud\Credentials\Utils\Helper;
|
||||
use AlibabaCloud\Credentials\Utils\Filter;
|
||||
|
||||
/**
|
||||
* @internal This class is intended for internal use within the package.
|
||||
* Class StaticSTSCredentialsProvider
|
||||
*
|
||||
* @package AlibabaCloud\Credentials\Providers
|
||||
*/
|
||||
class StaticSTSCredentialsProvider implements CredentialsProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $accessKeyId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $accessKeySecret;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $securityToken;
|
||||
|
||||
/**
|
||||
* StaticSTSCredentialsProvider constructor.
|
||||
*
|
||||
* @param array $params
|
||||
*/
|
||||
public function __construct(array $params = [])
|
||||
{
|
||||
$this->filterSTS($params);
|
||||
}
|
||||
|
||||
private function filterSTS(array $params)
|
||||
{
|
||||
if (Helper::envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_ID')) {
|
||||
$this->accessKeyId = Helper::env('ALIBABA_CLOUD_ACCESS_KEY_ID');
|
||||
}
|
||||
|
||||
if (Helper::envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_SECRET')) {
|
||||
$this->accessKeySecret = Helper::env('ALIBABA_CLOUD_ACCESS_KEY_SECRET');
|
||||
}
|
||||
|
||||
if (Helper::envNotEmpty('ALIBABA_CLOUD_SECURITY_TOKEN')) {
|
||||
$this->securityToken = Helper::env('ALIBABA_CLOUD_SECURITY_TOKEN');
|
||||
}
|
||||
|
||||
if (isset($params['accessKeyId'])) {
|
||||
$this->accessKeyId = $params['accessKeyId'];
|
||||
}
|
||||
if (isset($params['accessKeySecret'])) {
|
||||
$this->accessKeySecret = $params['accessKeySecret'];
|
||||
}
|
||||
if (isset($params['securityToken'])) {
|
||||
$this->securityToken = $params['securityToken'];
|
||||
}
|
||||
|
||||
Filter::accessKey($this->accessKeyId, $this->accessKeySecret);
|
||||
Filter::securityToken($this->securityToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get credential.
|
||||
*
|
||||
* @return Credentials
|
||||
*/
|
||||
public function getCredentials()
|
||||
{
|
||||
return new Credentials([
|
||||
'accessKeyId' => $this->accessKeyId,
|
||||
'accessKeySecret' => $this->accessKeySecret,
|
||||
'securityToken' => $this->securityToken,
|
||||
'providerName' => $this->getProviderName(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getProviderName()
|
||||
{
|
||||
return "static_sts";
|
||||
}
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Providers;
|
||||
|
||||
use AlibabaCloud\Credentials\Utils\Helper;
|
||||
use AlibabaCloud\Credentials\Utils\Filter;
|
||||
use AlibabaCloud\Credentials\Request\Request;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
use AlibabaCloud\Credentials\Credential\RefreshResult;
|
||||
|
||||
/**
|
||||
* @internal This class is intended for internal use within the package.
|
||||
* Class URLCredentialsProvider
|
||||
*
|
||||
* @package AlibabaCloud\Credentials\Providers
|
||||
*/
|
||||
class URLCredentialsProvider extends SessionCredentialsProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $credentialsURI;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $connectTimeout = 5;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $readTimeout = 5;
|
||||
|
||||
/**
|
||||
* URLCredentialsProvider constructor.
|
||||
*
|
||||
* @param array $params
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct(array $params = [], array $options = [])
|
||||
{
|
||||
$this->filterOptions($options);
|
||||
$this->filterCredentialsURI($params);
|
||||
}
|
||||
|
||||
private function filterOptions(array $options)
|
||||
{
|
||||
if (isset($options['connectTimeout'])) {
|
||||
$this->connectTimeout = $options['connectTimeout'];
|
||||
}
|
||||
|
||||
if (isset($options['readTimeout'])) {
|
||||
$this->readTimeout = $options['readTimeout'];
|
||||
}
|
||||
|
||||
Filter::timeout($this->connectTimeout, $this->readTimeout);
|
||||
}
|
||||
|
||||
private function filterCredentialsURI(array $params)
|
||||
{
|
||||
if (Helper::envNotEmpty('ALIBABA_CLOUD_CREDENTIALS_URI')) {
|
||||
$this->credentialsURI = Helper::env('ALIBABA_CLOUD_CREDENTIALS_URI');
|
||||
}
|
||||
|
||||
if (isset($params['credentialsURI'])) {
|
||||
$this->credentialsURI = $params['credentialsURI'];
|
||||
}
|
||||
|
||||
Filter::credentialsURI($this->credentialsURI);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get credentials by request.
|
||||
*
|
||||
* @return RefreshResult
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function refreshCredentials()
|
||||
{
|
||||
$options = Request::commonOptions();
|
||||
$options['read_timeout'] = $this->readTimeout;
|
||||
$options['connect_timeout'] = $this->connectTimeout;
|
||||
|
||||
$result = Request::createClient()->request('GET', $this->credentialsURI, $options);
|
||||
|
||||
if ($result->getStatusCode() !== 200) {
|
||||
throw new RuntimeException('Error refreshing credentials from credentialsURI, statusCode: ' . $result->getStatusCode() . ', result: ' . (string) $result);
|
||||
}
|
||||
|
||||
$credentials = $result->toArray();
|
||||
|
||||
if (!isset($credentials['AccessKeyId']) || !isset($credentials['AccessKeySecret']) || !isset($credentials['SecurityToken']) || !isset($credentials['Expiration'])) {
|
||||
throw new RuntimeException('Error retrieving credentials from credentialsURI result:' . $result->toJson());
|
||||
}
|
||||
|
||||
return new RefreshResult(new Credentials([
|
||||
'accessKeyId' => $credentials['AccessKeyId'],
|
||||
'accessKeySecret' => $credentials['AccessKeySecret'],
|
||||
'securityToken' => $credentials['SecurityToken'],
|
||||
'expiration' => \strtotime($credentials['Expiration']),
|
||||
'providerName' => $this->getProviderName(),
|
||||
]), $this->getStaleTime(strtotime($credentials['Expiration'])));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function key()
|
||||
{
|
||||
return 'credential_uri#' . $this->credentialsURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProviderName()
|
||||
{
|
||||
return 'credential_uri';
|
||||
}
|
||||
}
|
||||
@@ -2,16 +2,13 @@
|
||||
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use AlibabaCloud\Credentials\Providers\RamRoleArnCredentialsProvider;
|
||||
use AlibabaCloud\Credentials\Credential\CredentialModel;
|
||||
use AlibabaCloud\Credentials\Providers\RamRoleArnProvider;
|
||||
use AlibabaCloud\Credentials\Signature\ShaHmac1Signature;
|
||||
use AlibabaCloud\Credentials\Utils\Filter;
|
||||
use Exception;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Use the AssumeRole of the RAM account to complete the authentication.
|
||||
*/
|
||||
class RamRoleArnCredential implements CredentialsInterface
|
||||
@@ -60,10 +57,10 @@ class RamRoleArnCredential implements CredentialsInterface
|
||||
|
||||
Filter::accessKey($credential['access_key_id'], $credential['access_key_secret']);
|
||||
|
||||
$this->config = $config;
|
||||
$this->accessKeyId = $credential['access_key_id'];
|
||||
$this->config = $config;
|
||||
$this->accessKeyId = $credential['access_key_id'];
|
||||
$this->accessKeySecret = $credential['access_key_secret'];
|
||||
$this->roleArn = $credential['role_arn'];
|
||||
$this->roleArn = $credential['role_arn'];
|
||||
$this->roleSessionName = $credential['role_session_name'];
|
||||
}
|
||||
|
||||
@@ -180,20 +177,13 @@ class RamRoleArnCredential implements CredentialsInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AlibabaCloud\Credentials\Providers\Credentials
|
||||
* @return StsCredential
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
protected function getSessionCredential()
|
||||
{
|
||||
$params = [
|
||||
'accessKeyId' => $this->accessKeyId,
|
||||
'accessKeySecret' => $this->accessKeyId,
|
||||
'roleArn' => $this->roleArn,
|
||||
'roleSessionName' => $this->roleSessionName,
|
||||
'policy' => $this->policy,
|
||||
];
|
||||
return (new RamRoleArnCredentialsProvider($params))->getCredentials();
|
||||
return (new RamRoleArnProvider($this))->get();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,18 +215,4 @@ class RamRoleArnCredential implements CredentialsInterface
|
||||
{
|
||||
return $this->getSessionCredential()->getExpiration();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getCredential()
|
||||
{
|
||||
$credentials = $this->getSessionCredential();
|
||||
return new CredentialModel([
|
||||
'accessKeyId' => $credentials->getAccessKeyId(),
|
||||
'accessKeySecret' => $credentials->getAccessKeySecret(),
|
||||
'securityToken' => $credentials->getSecurityToken(),
|
||||
'type' => 'ram_role_arn',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
37
Server/vendor/alibabacloud/credentials/src/Request/AssumeRole.php
vendored
Normal file
37
Server/vendor/alibabacloud/credentials/src/Request/AssumeRole.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Request;
|
||||
|
||||
use AlibabaCloud\Credentials\Providers\Provider;
|
||||
use AlibabaCloud\Credentials\RamRoleArnCredential;
|
||||
use AlibabaCloud\Credentials\Signature\ShaHmac1Signature;
|
||||
|
||||
/**
|
||||
* Retrieving assume role credentials.
|
||||
*/
|
||||
class AssumeRole extends Request
|
||||
{
|
||||
/**
|
||||
* AssumeRole constructor.
|
||||
*
|
||||
* @param RamRoleArnCredential $arnCredential
|
||||
*/
|
||||
public function __construct(RamRoleArnCredential $arnCredential)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->signature = new ShaHmac1Signature();
|
||||
$this->credential = $arnCredential;
|
||||
$this->uri = $this->uri->withHost('sts.aliyuncs.com');
|
||||
$this->options['verify'] = false;
|
||||
$this->options['query']['RoleArn'] = $arnCredential->getRoleArn();
|
||||
$this->options['query']['RoleSessionName'] = $arnCredential->getRoleSessionName();
|
||||
$this->options['query']['DurationSeconds'] = Provider::DURATION_SECONDS;
|
||||
$this->options['query']['AccessKeyId'] = $this->credential->getOriginalAccessKeyId();
|
||||
$this->options['query']['Version'] = '2015-04-01';
|
||||
$this->options['query']['Action'] = 'AssumeRole';
|
||||
$this->options['query']['RegionId'] = 'cn-hangzhou';
|
||||
if ($arnCredential->getPolicy()) {
|
||||
$this->options['query']['Policy'] = $arnCredential->getPolicy();
|
||||
}
|
||||
}
|
||||
}
|
||||
33
Server/vendor/alibabacloud/credentials/src/Request/GenerateSessionAccessKey.php
vendored
Normal file
33
Server/vendor/alibabacloud/credentials/src/Request/GenerateSessionAccessKey.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Request;
|
||||
|
||||
use AlibabaCloud\Credentials\Providers\Provider;
|
||||
use AlibabaCloud\Credentials\RsaKeyPairCredential;
|
||||
use AlibabaCloud\Credentials\Signature\ShaHmac256WithRsaSignature;
|
||||
|
||||
/**
|
||||
* Use the RSA key pair to complete the authentication (supported only on Japanese site)
|
||||
*/
|
||||
class GenerateSessionAccessKey extends Request
|
||||
{
|
||||
/**
|
||||
* GenerateSessionAccessKey constructor.
|
||||
*
|
||||
* @param RsaKeyPairCredential $credential
|
||||
*/
|
||||
public function __construct(RsaKeyPairCredential $credential)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->signature = new ShaHmac256WithRsaSignature();
|
||||
$this->credential = $credential;
|
||||
$this->uri = $this->uri->withHost('sts.ap-northeast-1.aliyuncs.com');
|
||||
$this->options['verify'] = false;
|
||||
$this->options['query']['Version'] = '2015-04-01';
|
||||
$this->options['query']['Action'] = 'GenerateSessionAccessKey';
|
||||
$this->options['query']['RegionId'] = 'cn-hangzhou';
|
||||
$this->options['query']['AccessKeyId'] = $credential->getPublicKeyId();
|
||||
$this->options['query']['PublicKeyId'] = $credential->getPublicKeyId();
|
||||
$this->options['query']['DurationSeconds'] = Provider::DURATION_SECONDS;
|
||||
}
|
||||
}
|
||||
@@ -3,16 +3,19 @@
|
||||
namespace AlibabaCloud\Credentials\Request;
|
||||
|
||||
use AlibabaCloud\Credentials\Credentials;
|
||||
use AlibabaCloud\Credentials\Utils\Helper;
|
||||
use AlibabaCloud\Credentials\EcsRamRoleCredential;
|
||||
use AlibabaCloud\Credentials\Helper;
|
||||
use AlibabaCloud\Credentials\RamRoleArnCredential;
|
||||
use AlibabaCloud\Credentials\Signature\ShaHmac1Signature;
|
||||
use AlibabaCloud\Credentials\Signature\ShaHmac256WithRsaSignature;
|
||||
use Exception;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\HandlerStack;
|
||||
use GuzzleHttp\Middleware;
|
||||
use GuzzleHttp\Psr7\Uri;
|
||||
use AlibabaCloud\Tea\Response;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* RESTful RPC Request.
|
||||
*/
|
||||
@@ -25,33 +28,67 @@ class Request
|
||||
const CONNECT_TIMEOUT = 5;
|
||||
|
||||
/**
|
||||
* Request Read Timeout
|
||||
* Request Timeout
|
||||
*/
|
||||
const READ_TIMEOUT = 5;
|
||||
const TIMEOUT = 10;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private static $config = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $options = [];
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
* @var Uri
|
||||
*/
|
||||
public static function commonOptions()
|
||||
public $uri;
|
||||
|
||||
/**
|
||||
* @var EcsRamRoleCredential|RamRoleArnCredential
|
||||
*/
|
||||
protected $credential;
|
||||
|
||||
/**
|
||||
* @var ShaHmac256WithRsaSignature|ShaHmac1Signature
|
||||
*/
|
||||
protected $signature;
|
||||
|
||||
/**
|
||||
* Request constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$options = [];
|
||||
$options['http_errors'] = false;
|
||||
$options['connect_timeout'] = self::CONNECT_TIMEOUT;
|
||||
$options['read_timeout'] = self::READ_TIMEOUT;
|
||||
$options['headers']['User-Agent'] = Helper::getUserAgent();
|
||||
$this->uri = (new Uri())->withScheme('https');
|
||||
$this->options['http_errors'] = false;
|
||||
$this->options['connect_timeout'] = self::CONNECT_TIMEOUT;
|
||||
$this->options['timeout'] = self::TIMEOUT;
|
||||
|
||||
// Turn on debug mode based on environment variable.
|
||||
if (strtolower(Helper::env('DEBUG')) === 'sdk') {
|
||||
$options['debug'] = true;
|
||||
$this->options['debug'] = true;
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ResponseInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function request()
|
||||
{
|
||||
$this->options['query']['Format'] = 'JSON';
|
||||
$this->options['query']['SignatureMethod'] = $this->signature->getMethod();
|
||||
$this->options['query']['SignatureVersion'] = $this->signature->getVersion();
|
||||
$this->options['query']['SignatureNonce'] = self::uuid(json_encode($this->options['query']));
|
||||
$this->options['query']['Timestamp'] = gmdate('Y-m-d\TH:i:s\Z');
|
||||
$this->options['query']['Signature'] = $this->signature->sign(
|
||||
self::signString('GET', $this->options['query']),
|
||||
$this->credential->getOriginalAccessKeySecret() . '&'
|
||||
);
|
||||
return self::createClient()->request('GET', (string)$this->uri, $this->options);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,53 +118,6 @@ class Request
|
||||
return $method . '&%2F&' . self::percentEncode(substr($canonicalized, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $string
|
||||
* @param string $accessKeySecret
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function shaHmac1sign($string, $accessKeySecret)
|
||||
{
|
||||
return base64_encode(hash_hmac('sha1', $string, $accessKeySecret, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $string
|
||||
* @param string $accessKeySecret
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function shaHmac256sign($string, $accessKeySecret)
|
||||
{
|
||||
return base64_encode(hash_hmac('sha256', $string, $accessKeySecret, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $string
|
||||
* @param string $privateKey
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function shaHmac256WithRsasign($string, $privateKey)
|
||||
{
|
||||
$binarySignature = '';
|
||||
try {
|
||||
openssl_sign(
|
||||
$string,
|
||||
$binarySignature,
|
||||
$privateKey,
|
||||
\OPENSSL_ALGO_SHA256
|
||||
);
|
||||
} catch (Exception $exception) {
|
||||
throw new InvalidArgumentException(
|
||||
$exception->getMessage()
|
||||
);
|
||||
}
|
||||
|
||||
return base64_encode($binarySignature);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $string
|
||||
*
|
||||
@@ -150,8 +140,6 @@ class Request
|
||||
{
|
||||
if (Credentials::hasMock()) {
|
||||
$stack = HandlerStack::create(Credentials::getMock());
|
||||
$history = Credentials::getHandlerHistory();
|
||||
$stack->push($history);
|
||||
} else {
|
||||
$stack = HandlerStack::create();
|
||||
}
|
||||
|
||||
@@ -2,16 +2,13 @@
|
||||
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use AlibabaCloud\Credentials\Providers\RsaKeyPairCredentialsProvider;
|
||||
use AlibabaCloud\Credentials\Credential\CredentialModel;
|
||||
use AlibabaCloud\Credentials\Providers\RsaKeyPairProvider;
|
||||
use AlibabaCloud\Credentials\Signature\ShaHmac1Signature;
|
||||
use AlibabaCloud\Credentials\Utils\Filter;
|
||||
use Exception;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Use the RSA key pair to complete the authentication (supported only on Japanese site)
|
||||
*/
|
||||
class RsaKeyPairCredential implements CredentialsInterface
|
||||
@@ -22,11 +19,6 @@ class RsaKeyPairCredential implements CredentialsInterface
|
||||
*/
|
||||
private $publicKeyId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $privateKeyFile;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@@ -50,8 +42,7 @@ class RsaKeyPairCredential implements CredentialsInterface
|
||||
Filter::privateKeyFile($private_key_file);
|
||||
|
||||
$this->publicKeyId = $public_key_id;
|
||||
$this->privateKeyFile = $private_key_file;
|
||||
$this->config = $config;
|
||||
$this->config = $config;
|
||||
try {
|
||||
$this->privateKey = file_get_contents($private_key_file);
|
||||
} catch (Exception $exception) {
|
||||
@@ -126,17 +117,13 @@ class RsaKeyPairCredential implements CredentialsInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AlibabaCloud\Credentials\Providers\Credentials
|
||||
* @return StsCredential
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
protected function getSessionCredential()
|
||||
{
|
||||
$params = [
|
||||
'publicKeyId' => $this->publicKeyId,
|
||||
'privateKeyFile' => $this->privateKeyFile,
|
||||
];
|
||||
return (new RsaKeyPairCredentialsProvider($params))->getCredentials();
|
||||
return (new RsaKeyPairProvider($this))->get();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,18 +155,4 @@ class RsaKeyPairCredential implements CredentialsInterface
|
||||
{
|
||||
return $this->getSessionCredential()->getExpiration();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getCredential()
|
||||
{
|
||||
$credentials = $this->getSessionCredential();
|
||||
return new CredentialModel([
|
||||
'accessKeyId' => $credentials->getAccessKeyId(),
|
||||
'accessKeySecret' => $credentials->getAccessKeySecret(),
|
||||
'securityToken' => $credentials->getSecurityToken(),
|
||||
'type' => 'rsa_key_pair',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,9 @@
|
||||
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use AlibabaCloud\Credentials\Utils\Filter;
|
||||
use AlibabaCloud\Credentials\Credential\CredentialModel;
|
||||
use AlibabaCloud\Credentials\Signature\ShaHmac1Signature;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Use the STS Token to complete the authentication.
|
||||
*/
|
||||
class StsCredential implements CredentialsInterface
|
||||
@@ -45,10 +42,10 @@ class StsCredential implements CredentialsInterface
|
||||
{
|
||||
Filter::accessKey($access_key_id, $access_key_secret);
|
||||
Filter::expiration($expiration);
|
||||
$this->accessKeyId = $access_key_id;
|
||||
$this->accessKeyId = $access_key_id;
|
||||
$this->accessKeySecret = $access_key_secret;
|
||||
$this->expiration = $expiration;
|
||||
$this->securityToken = $security_token;
|
||||
$this->expiration = $expiration;
|
||||
$this->securityToken = $security_token;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,18 +95,4 @@ class StsCredential implements CredentialsInterface
|
||||
{
|
||||
return new ShaHmac1Signature();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getCredential()
|
||||
{
|
||||
return new CredentialModel([
|
||||
'accessKeyId' => $this->accessKeyId,
|
||||
'accessKeySecret' => $this->accessKeySecret,
|
||||
'securityToken' => $this->securityToken,
|
||||
'type' => 'sts',
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,233 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Utils;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Class Filter
|
||||
*
|
||||
* @package AlibabaCloud\Credentials\Utils
|
||||
*/
|
||||
class Filter
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @return string
|
||||
*/
|
||||
public static function credentialName($name)
|
||||
{
|
||||
if (!is_string($name)) {
|
||||
throw new InvalidArgumentException('Name must be a string');
|
||||
}
|
||||
|
||||
if ($name === '') {
|
||||
throw new InvalidArgumentException('Name cannot be empty');
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $bearerToken
|
||||
*
|
||||
* @return mixed
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function bearerToken($bearerToken)
|
||||
{
|
||||
if (!is_string($bearerToken)) {
|
||||
throw new InvalidArgumentException('bearerToken must be a string');
|
||||
}
|
||||
|
||||
if ($bearerToken === '') {
|
||||
throw new InvalidArgumentException('bearerToken cannot be empty');
|
||||
}
|
||||
|
||||
return $bearerToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $publicKeyId
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function publicKeyId($publicKeyId)
|
||||
{
|
||||
if (!is_string($publicKeyId)) {
|
||||
throw new InvalidArgumentException('publicKeyId must be a string');
|
||||
}
|
||||
|
||||
if ($publicKeyId === '') {
|
||||
throw new InvalidArgumentException('publicKeyId cannot be empty');
|
||||
}
|
||||
|
||||
return $publicKeyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $privateKeyFile
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function privateKeyFile($privateKeyFile)
|
||||
{
|
||||
if (!is_string($privateKeyFile)) {
|
||||
throw new InvalidArgumentException('privateKeyFile must be a string');
|
||||
}
|
||||
|
||||
if ($privateKeyFile === '') {
|
||||
throw new InvalidArgumentException('privateKeyFile cannot be empty');
|
||||
}
|
||||
|
||||
return $privateKeyFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $roleName
|
||||
*/
|
||||
public static function roleName($roleName)
|
||||
{
|
||||
if ($roleName === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_string($roleName)) {
|
||||
throw new InvalidArgumentException('roleName must be a string');
|
||||
}
|
||||
|
||||
if ($roleName === '') {
|
||||
throw new InvalidArgumentException('roleName cannot be empty');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean|null $disableIMDSv1
|
||||
*/
|
||||
public static function disableIMDSv1($disableIMDSv1)
|
||||
{
|
||||
if (!is_bool($disableIMDSv1)) {
|
||||
throw new InvalidArgumentException('disableIMDSv1 must be a boolean');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string|null $roleArn
|
||||
*/
|
||||
public static function roleArn($roleArn)
|
||||
{
|
||||
if (is_null($roleArn) || $roleArn === '') {
|
||||
throw new InvalidArgumentException('roleArn cannot be empty');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $roleArn
|
||||
*/
|
||||
public static function oidcProviderArn($oidcProviderArn)
|
||||
{
|
||||
if (is_null($oidcProviderArn) || $oidcProviderArn === '') {
|
||||
throw new InvalidArgumentException('oidcProviderArn cannot be empty');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $roleArn
|
||||
*/
|
||||
public static function oidcTokenFilePath($oidcTokenFilePath)
|
||||
{
|
||||
if (is_null($oidcTokenFilePath) || $oidcTokenFilePath === '') {
|
||||
throw new InvalidArgumentException('oidcTokenFilePath cannot be empty');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $accessKeyId
|
||||
* @param string $accessKeySecret
|
||||
*/
|
||||
public static function accessKey($accessKeyId, $accessKeySecret)
|
||||
{
|
||||
if (!is_string($accessKeyId)) {
|
||||
throw new InvalidArgumentException('accessKeyId must be a string');
|
||||
}
|
||||
|
||||
if ($accessKeyId === '') {
|
||||
throw new InvalidArgumentException('accessKeyId cannot be empty');
|
||||
}
|
||||
|
||||
if (!is_string($accessKeySecret)) {
|
||||
throw new InvalidArgumentException('accessKeySecret must be a string');
|
||||
}
|
||||
|
||||
if ($accessKeySecret === '') {
|
||||
throw new InvalidArgumentException('accessKeySecret cannot be empty');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $securityToken
|
||||
*/
|
||||
public static function securityToken($securityToken)
|
||||
{
|
||||
if (!is_string($securityToken)) {
|
||||
throw new InvalidArgumentException('securityToken must be a string');
|
||||
}
|
||||
|
||||
if ($securityToken === '') {
|
||||
throw new InvalidArgumentException('securityToken cannot be empty');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $expiration
|
||||
*/
|
||||
public static function expiration($expiration)
|
||||
{
|
||||
if (!is_int($expiration)) {
|
||||
throw new InvalidArgumentException('expiration must be a int');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $connectTimeout
|
||||
* @param int $readTimeout
|
||||
*/
|
||||
public static function timeout($connectTimeout, $readTimeout)
|
||||
{
|
||||
if (!is_int($connectTimeout)) {
|
||||
throw new InvalidArgumentException('connectTimeout must be a int');
|
||||
}
|
||||
|
||||
if (!is_int($readTimeout)) {
|
||||
throw new InvalidArgumentException('readTimeout must be a int');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $credentialsURI
|
||||
*/
|
||||
public static function credentialsURI($credentialsURI)
|
||||
{
|
||||
if (!is_string($credentialsURI)) {
|
||||
throw new InvalidArgumentException('credentialsURI must be a string');
|
||||
}
|
||||
|
||||
if ($credentialsURI === '') {
|
||||
throw new InvalidArgumentException('credentialsURI cannot be empty');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean|null $reuseLastProviderEnabled
|
||||
*/
|
||||
public static function reuseLastProviderEnabled($reuseLastProviderEnabled)
|
||||
{
|
||||
if (!is_bool($reuseLastProviderEnabled)) {
|
||||
throw new InvalidArgumentException('reuseLastProviderEnabled must be a boolean');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,9 +11,9 @@
|
||||
],
|
||||
"require": {
|
||||
"php": ">5.5",
|
||||
"alibabacloud/tea-utils": "^0.2.21",
|
||||
"alibabacloud/tea-utils": "^0.2.0",
|
||||
"alibabacloud/credentials": "^1.1",
|
||||
"alibabacloud/openapi-util": "^0.1.10|^0.2.1",
|
||||
"alibabacloud/openapi-util": "^0.1.10",
|
||||
"alibabacloud/gateway-spi": "^1",
|
||||
"alibabacloud/tea-xml": "^0.2"
|
||||
},
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit bootstrap="./tests/bootstrap.php" colors="true" processIsolation="false" stopOnFailure="false"
|
||||
convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true"
|
||||
testSuiteLoaderFile="phpunit/src/Runner/StandardTestSuiteLoader.php">
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="All">
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Unit">
|
||||
<directory suffix="Test.php">./tests/Unit</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<groups>
|
||||
<exclude>
|
||||
<group>integration</group>
|
||||
</exclude>
|
||||
</groups>
|
||||
|
||||
<logging>
|
||||
<log type="coverage-html" target="cache/coverage" lowUpperBound="35" highLowerBound="70"/>
|
||||
<log type="coverage-clover" target="cache/coverage.clover"/>
|
||||
</logging>
|
||||
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">./src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
@@ -1,15 +1,14 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
|
||||
namespace Darabonba\OpenApi\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
|
||||
use Darabonba\OpenApi\Models\GlobalParameters;
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
/**
|
||||
* Model for initing client
|
||||
* Model for initing client.
|
||||
*/
|
||||
class Config extends Model
|
||||
{
|
||||
@@ -17,7 +16,6 @@ class Config extends Model
|
||||
'accessKeyId' => '',
|
||||
'accessKeySecret' => '',
|
||||
'securityToken' => '',
|
||||
'bearerToken' => '',
|
||||
'protocol' => 'http',
|
||||
'method' => '',
|
||||
'regionId' => '',
|
||||
@@ -39,13 +37,12 @@ class Config extends Model
|
||||
'type' => '',
|
||||
'signatureVersion' => '',
|
||||
'signatureAlgorithm' => '',
|
||||
'key' => '',
|
||||
'cert' => '',
|
||||
'ca' => '',
|
||||
];
|
||||
|
||||
public function validate()
|
||||
{
|
||||
}
|
||||
|
||||
public function toMap()
|
||||
{
|
||||
$res = [];
|
||||
@@ -58,9 +55,6 @@ class Config extends Model
|
||||
if (null !== $this->securityToken) {
|
||||
$res['securityToken'] = $this->securityToken;
|
||||
}
|
||||
if (null !== $this->bearerToken) {
|
||||
$res['bearerToken'] = $this->bearerToken;
|
||||
}
|
||||
if (null !== $this->protocol) {
|
||||
$res['protocol'] = $this->protocol;
|
||||
}
|
||||
@@ -127,22 +121,13 @@ class Config extends Model
|
||||
if (null !== $this->globalParameters) {
|
||||
$res['globalParameters'] = null !== $this->globalParameters ? $this->globalParameters->toMap() : null;
|
||||
}
|
||||
if (null !== $this->key) {
|
||||
$res['key'] = $this->key;
|
||||
}
|
||||
if (null !== $this->cert) {
|
||||
$res['cert'] = $this->cert;
|
||||
}
|
||||
if (null !== $this->ca) {
|
||||
$res['ca'] = $this->ca;
|
||||
}
|
||||
if (null !== $this->disableHttp2) {
|
||||
$res['disableHttp2'] = $this->disableHttp2;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $map
|
||||
*
|
||||
* @return Config
|
||||
*/
|
||||
public static function fromMap($map = [])
|
||||
@@ -157,9 +142,6 @@ class Config extends Model
|
||||
if (isset($map['securityToken'])) {
|
||||
$model->securityToken = $map['securityToken'];
|
||||
}
|
||||
if (isset($map['bearerToken'])) {
|
||||
$model->bearerToken = $map['bearerToken'];
|
||||
}
|
||||
if (isset($map['protocol'])) {
|
||||
$model->protocol = $map['protocol'];
|
||||
}
|
||||
@@ -226,225 +208,226 @@ class Config extends Model
|
||||
if (isset($map['globalParameters'])) {
|
||||
$model->globalParameters = GlobalParameters::fromMap($map['globalParameters']);
|
||||
}
|
||||
if (isset($map['key'])) {
|
||||
$model->key = $map['key'];
|
||||
}
|
||||
if (isset($map['cert'])) {
|
||||
$model->cert = $map['cert'];
|
||||
}
|
||||
if (isset($map['ca'])) {
|
||||
$model->ca = $map['ca'];
|
||||
}
|
||||
if (isset($map['disableHttp2'])) {
|
||||
$model->disableHttp2 = $map['disableHttp2'];
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description accesskey id
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $accessKeyId;
|
||||
|
||||
/**
|
||||
* @description accesskey secret
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $accessKeySecret;
|
||||
|
||||
/**
|
||||
* @description security token
|
||||
*
|
||||
* @example a.txt
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $securityToken;
|
||||
|
||||
/**
|
||||
* @description bearer token
|
||||
* @example the-bearer-token
|
||||
* @var string
|
||||
*/
|
||||
public $bearerToken;
|
||||
|
||||
/**
|
||||
* @description http protocol
|
||||
*
|
||||
* @example http
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $protocol;
|
||||
|
||||
/**
|
||||
* @description http method
|
||||
*
|
||||
* @example GET
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $method;
|
||||
|
||||
/**
|
||||
* @description region id
|
||||
*
|
||||
* @example cn-hangzhou
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $regionId;
|
||||
|
||||
/**
|
||||
* @description read timeout
|
||||
*
|
||||
* @example 10
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $readTimeout;
|
||||
|
||||
/**
|
||||
* @description connect timeout
|
||||
*
|
||||
* @example 10
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $connectTimeout;
|
||||
|
||||
/**
|
||||
* @description http proxy
|
||||
*
|
||||
* @example http://localhost
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $httpProxy;
|
||||
|
||||
/**
|
||||
* @description https proxy
|
||||
*
|
||||
* @example https://localhost
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $httpsProxy;
|
||||
|
||||
/**
|
||||
* @description credential
|
||||
* @example
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* @var Credential
|
||||
*/
|
||||
public $credential;
|
||||
|
||||
/**
|
||||
* @description endpoint
|
||||
*
|
||||
* @example cs.aliyuncs.com
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $endpoint;
|
||||
|
||||
/**
|
||||
* @description proxy white list
|
||||
*
|
||||
* @example http://localhost
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $noProxy;
|
||||
|
||||
/**
|
||||
* @description max idle conns
|
||||
*
|
||||
* @example 3
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $maxIdleConns;
|
||||
|
||||
/**
|
||||
* @description network for endpoint
|
||||
*
|
||||
* @example public
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $network;
|
||||
|
||||
/**
|
||||
* @description user agent
|
||||
*
|
||||
* @example Alibabacloud/1
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $userAgent;
|
||||
|
||||
/**
|
||||
* @description suffix for endpoint
|
||||
*
|
||||
* @example aliyun
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $suffix;
|
||||
|
||||
/**
|
||||
* @description socks5 proxy
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $socks5Proxy;
|
||||
|
||||
/**
|
||||
* @description socks5 network
|
||||
*
|
||||
* @example TCP
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $socks5NetWork;
|
||||
|
||||
/**
|
||||
* @description endpoint type
|
||||
*
|
||||
* @example internal
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $endpointType;
|
||||
|
||||
/**
|
||||
* @description OpenPlatform endpoint
|
||||
*
|
||||
* @example openplatform.aliyuncs.com
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $openPlatformEndpoint;
|
||||
|
||||
/**
|
||||
* @description credential type
|
||||
*
|
||||
* @example access_key
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* @description Signature Version
|
||||
*
|
||||
* @example v1
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $signatureVersion;
|
||||
|
||||
/**
|
||||
* @description Signature Algorithm
|
||||
*
|
||||
* @example ACS3-HMAC-SHA256
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $signatureAlgorithm;
|
||||
|
||||
/**
|
||||
* @description Global Parameters
|
||||
*
|
||||
* @var GlobalParameters
|
||||
*/
|
||||
public $globalParameters;
|
||||
|
||||
/**
|
||||
* @description privite key for client certificate
|
||||
* @example MIIEvQ
|
||||
* @var string
|
||||
*/
|
||||
public $key;
|
||||
|
||||
/**
|
||||
* @description client certificate
|
||||
* @example -----BEGIN CERTIFICATE-----xxx-----END CERTIFICATE-----
|
||||
* @var string
|
||||
*/
|
||||
public $cert;
|
||||
|
||||
/**
|
||||
* @description server certificate
|
||||
* @example -----BEGIN CERTIFICATE-----xxx-----END CERTIFICATE-----
|
||||
* @var string
|
||||
*/
|
||||
public $ca;
|
||||
|
||||
/**
|
||||
* @description disable HTTP/2
|
||||
* @example false
|
||||
* @var bool
|
||||
*/
|
||||
public $disableHttp2;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
|
||||
namespace Darabonba\OpenApi\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
@@ -10,6 +11,7 @@ class GlobalParameters extends Model
|
||||
public function validate()
|
||||
{
|
||||
}
|
||||
|
||||
public function toMap()
|
||||
{
|
||||
$res = [];
|
||||
@@ -19,10 +21,13 @@ class GlobalParameters extends Model
|
||||
if (null !== $this->queries) {
|
||||
$res['queries'] = $this->queries;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $map
|
||||
*
|
||||
* @return GlobalParameters
|
||||
*/
|
||||
public static function fromMap($map = [])
|
||||
@@ -34,10 +39,11 @@ class GlobalParameters extends Model
|
||||
if (isset($map['queries'])) {
|
||||
$model->queries = $map['queries'];
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
public $headers;
|
||||
|
||||
public $queries;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
|
||||
namespace Darabonba\OpenApi\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
@@ -10,6 +11,7 @@ class OpenApiRequest extends Model
|
||||
public function validate()
|
||||
{
|
||||
}
|
||||
|
||||
public function toMap()
|
||||
{
|
||||
$res = [];
|
||||
@@ -31,10 +33,13 @@ class OpenApiRequest extends Model
|
||||
if (null !== $this->endpointOverride) {
|
||||
$res['endpointOverride'] = $this->endpointOverride;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $map
|
||||
*
|
||||
* @return OpenApiRequest
|
||||
*/
|
||||
public static function fromMap($map = [])
|
||||
@@ -58,8 +63,10 @@ class OpenApiRequest extends Model
|
||||
if (isset($map['endpointOverride'])) {
|
||||
$model->endpointOverride = $map['endpointOverride'];
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
public $headers;
|
||||
|
||||
public $query;
|
||||
@@ -71,5 +78,4 @@ class OpenApiRequest extends Model
|
||||
public $hostMap;
|
||||
|
||||
public $endpointOverride;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
|
||||
namespace Darabonba\OpenApi\Models;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
@@ -18,6 +19,7 @@ class Params extends Model
|
||||
Model::validateRequired('bodyType', $this->bodyType, true);
|
||||
Model::validateRequired('reqBodyType', $this->reqBodyType, true);
|
||||
}
|
||||
|
||||
public function toMap()
|
||||
{
|
||||
$res = [];
|
||||
@@ -48,10 +50,13 @@ class Params extends Model
|
||||
if (null !== $this->style) {
|
||||
$res['style'] = $this->style;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $map
|
||||
*
|
||||
* @return Params
|
||||
*/
|
||||
public static function fromMap($map = [])
|
||||
@@ -84,8 +89,10 @@ class Params extends Model
|
||||
if (isset($map['style'])) {
|
||||
$model->style = $map['style'];
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@@ -127,5 +134,4 @@ class Params extends Model
|
||||
public $reqBodyType;
|
||||
|
||||
public $style;
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,328 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Darabonba\OpenApi\Tests;
|
||||
|
||||
use Darabonba\OpenApi\OpenApiClient;
|
||||
use AlibabaCloud\Tea\Model;
|
||||
use AlibabaCloud\Tea\Request;
|
||||
use AlibabaCloud\Tea\Utils\Utils;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class OpenApiClientTest extends TestCase
|
||||
{
|
||||
public function testConfig(){
|
||||
$globalParameters = new GlobalParameters([
|
||||
"headers" => [
|
||||
"global-key" => "global-value"
|
||||
],
|
||||
"queries" => [
|
||||
"global-query" => "global-value"
|
||||
]
|
||||
]);
|
||||
$config = new Config([
|
||||
"endpoint" => "config.endpoint",
|
||||
"endpointType" => "regional",
|
||||
"network" => "config.network",
|
||||
"suffix" => "config.suffix",
|
||||
"protocol" => "config.protocol",
|
||||
"method" => "config.method",
|
||||
"regionId" => "config.regionId",
|
||||
"userAgent" => "config.userAgent",
|
||||
"readTimeout" => 3000,
|
||||
"connectTimeout" => 3000,
|
||||
"httpProxy" => "config.httpProxy",
|
||||
"httpsProxy" => "config.httpsProxy",
|
||||
"noProxy" => "config.noProxy",
|
||||
"socks5Proxy" => "config.socks5Proxy",
|
||||
"socks5NetWork" => "config.socks5NetWork",
|
||||
"maxIdleConns" => 128,
|
||||
"signatureVersion" => "config.signatureVersion",
|
||||
"signatureAlgorithm" => "config.signatureAlgorithm",
|
||||
"globalParameters" => $globalParameters
|
||||
]);
|
||||
$creConfig = new \AlibabaCloud\Credentials\Credential\Config([
|
||||
"accessKeyId" => "accessKeyId",
|
||||
"accessKeySecret" => "accessKeySecret",
|
||||
"securityToken" => "securityToken",
|
||||
"type" => "sts"
|
||||
]);
|
||||
$credential = new Credential($creConfig);
|
||||
$config->credential = $credential;
|
||||
$client = new OpenApiClient($config);
|
||||
$config->accessKeyId = "ak";
|
||||
$config->accessKeySecret = "secret";
|
||||
$config->securityToken = "token";
|
||||
$config->type = "sts";
|
||||
$client = new OpenApiClient($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Config
|
||||
*/
|
||||
public static function createConfig(){
|
||||
$globalParameters = new GlobalParameters([
|
||||
"headers" => [
|
||||
"global-key" => "global-value"
|
||||
],
|
||||
"queries" => [
|
||||
"global-query" => "global-value"
|
||||
]
|
||||
]);
|
||||
$config = new Config([
|
||||
"accessKeyId" => "ak",
|
||||
"accessKeySecret" => "secret",
|
||||
"securityToken" => "token",
|
||||
"type" => "sts",
|
||||
"userAgent" => "config.userAgent",
|
||||
"readTimeout" => 3000,
|
||||
"connectTimeout" => 3000,
|
||||
"maxIdleConns" => 128,
|
||||
"signatureVersion" => "config.signatureVersion",
|
||||
"signatureAlgorithm" => "ACS3-HMAC-SHA256",
|
||||
"globalParameters" => $globalParameters
|
||||
]);
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return RuntimeOptions
|
||||
*/
|
||||
public static function createRuntimeOptions(){
|
||||
$runtime = new RuntimeOptions([
|
||||
"readTimeout" => 4000,
|
||||
"connectTimeout" => 4000,
|
||||
"maxIdleConns" => 100,
|
||||
"autoretry" => true,
|
||||
"maxAttempts" => 1,
|
||||
"backoffPolicy" => "no",
|
||||
"backoffPeriod" => 1,
|
||||
"ignoreSSL" => true
|
||||
]);
|
||||
return $runtime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return OpenApiRequest
|
||||
*/
|
||||
public static function createOpenApiRequest(){
|
||||
$query = [];
|
||||
$query["key1"] = "value";
|
||||
$query["key2"] = 1;
|
||||
$query["key3"] = true;
|
||||
$body = [];
|
||||
$body["key1"] = "value";
|
||||
$body["key2"] = 1;
|
||||
$body["key3"] = true;
|
||||
$headers = [
|
||||
"for-test" => "sdk"
|
||||
];
|
||||
$req = new OpenApiRequest([
|
||||
"headers" => $headers,
|
||||
"query" => OpenApiUtilClient::query($query),
|
||||
"body" => OpenApiUtilClient::parseToMap($body)
|
||||
]);
|
||||
return $req;
|
||||
}
|
||||
|
||||
public function testCallApiForRPCWithV2Sign_AK_Form(){
|
||||
$config = self::createConfig();
|
||||
$runtime = self::createRuntimeOptions();
|
||||
$config->protocol = "HTTP";
|
||||
$config->signatureAlgorithm = "v2";
|
||||
$config->endpoint = "test.aliyuncs.com";
|
||||
$client = new OpenApiClient($config);
|
||||
$request = self::createOpenApiRequest();
|
||||
$params = new Params([
|
||||
"action" => "TestAPI",
|
||||
"version" => "2022-06-01",
|
||||
"protocol" => "HTTPS",
|
||||
"pathname" => "/",
|
||||
"method" => "POST",
|
||||
"authType" => "AK",
|
||||
"style" => "RPC",
|
||||
"reqBodyType" => "formData",
|
||||
"bodyType" => "json"
|
||||
]);
|
||||
$client->callApi($params, $request, $runtime);
|
||||
}
|
||||
|
||||
public function testCallApiForRPCWithV2Sign_Anonymous_JSON(){
|
||||
$config = self::createConfig();
|
||||
$runtime = self::createRuntimeOptions();
|
||||
$config->protocol = "HTTP";
|
||||
$config->signatureAlgorithm = "v2";
|
||||
$config->endpoint = "test.aliyuncs.com";
|
||||
$client = new OpenApiClient($config);
|
||||
$request = self::createOpenApiRequest();
|
||||
$params = new Params([
|
||||
"action" => "TestAPI",
|
||||
"version" => "2022-06-01",
|
||||
"protocol" => "HTTPS",
|
||||
"pathname" => "/",
|
||||
"method" => "POST",
|
||||
"authType" => "Anonymous",
|
||||
"style" => "RPC",
|
||||
"reqBodyType" => "json",
|
||||
"bodyType" => "json"
|
||||
]);
|
||||
$client->callApi($params, $request, $runtime);
|
||||
}
|
||||
|
||||
public function testCallApiForROAWithV2Sign_HTTPS_AK_Form(){
|
||||
$config = self::createConfig();
|
||||
$runtime = self::createRuntimeOptions();
|
||||
$config->signatureAlgorithm = "v2";
|
||||
$config->endpoint = "test.aliyuncs.com";
|
||||
$client = new OpenApiClient($config);
|
||||
$request = self::createOpenApiRequest();
|
||||
$params = new Params([
|
||||
"action" => "TestAPI",
|
||||
"version" => "2022-06-01",
|
||||
"protocol" => "HTTPS",
|
||||
"pathname" => "/test",
|
||||
"method" => "POST",
|
||||
"authType" => "AK",
|
||||
"style" => "ROA",
|
||||
"reqBodyType" => "formData",
|
||||
"bodyType" => "json"
|
||||
]);
|
||||
$client->callApi($params, $request, $runtime);
|
||||
}
|
||||
|
||||
public function testCallApiForROAWithV2Sign_Anonymous_JSON(){
|
||||
$config = self::createConfig();
|
||||
$runtime = self::createRuntimeOptions();
|
||||
$config->protocol = "HTTP";
|
||||
$config->signatureAlgorithm = "v2";
|
||||
$config->endpoint = "test.aliyuncs.com";
|
||||
$client = new OpenApiClient($config);
|
||||
$request = self::createOpenApiRequest();
|
||||
$params = new Params([
|
||||
"action" => "TestAPI",
|
||||
"version" => "2022-06-01",
|
||||
"protocol" => "HTTPS",
|
||||
"pathname" => "/test",
|
||||
"method" => "POST",
|
||||
"authType" => "Anonymous",
|
||||
"style" => "ROA",
|
||||
"reqBodyType" => "json",
|
||||
"bodyType" => "json"
|
||||
]);
|
||||
$client->callApi($params, $request, $runtime);
|
||||
}
|
||||
|
||||
public function testCallApiForRPCWithV3Sign_AK_Form(){
|
||||
$config = self::createConfig();
|
||||
$runtime = self::createRuntimeOptions();
|
||||
$config->protocol = "HTTP";
|
||||
$config->endpoint = "test.aliyuncs.com";
|
||||
$client = new OpenApiClient($config);
|
||||
$request = self::createOpenApiRequest();
|
||||
$params = new Params([
|
||||
"action" => "TestAPI",
|
||||
"version" => "2022-06-01",
|
||||
"protocol" => "HTTPS",
|
||||
"pathname" => "/",
|
||||
"method" => "POST",
|
||||
"authType" => "AK",
|
||||
"style" => "RPC",
|
||||
"reqBodyType" => "formData",
|
||||
"bodyType" => "json"
|
||||
]);
|
||||
$client->callApi($params, $request, $runtime);
|
||||
}
|
||||
|
||||
public function testCallApiForRPCWithV3Sign_Anonymous_JSON(){
|
||||
$config = self::createConfig();
|
||||
$runtime = self::createRuntimeOptions();
|
||||
$config->protocol = "HTTP";
|
||||
$config->endpoint = "test.aliyuncs.com";
|
||||
$client = new OpenApiClient($config);
|
||||
$request = self::createOpenApiRequest();
|
||||
$params = new Params([
|
||||
"action" => "TestAPI",
|
||||
"version" => "2022-06-01",
|
||||
"protocol" => "HTTPS",
|
||||
"pathname" => "/",
|
||||
"method" => "POST",
|
||||
"authType" => "Anonymous",
|
||||
"style" => "RPC",
|
||||
"reqBodyType" => "json",
|
||||
"bodyType" => "json"
|
||||
]);
|
||||
$client->callApi($params, $request, $runtime);
|
||||
}
|
||||
|
||||
public function testCallApiForROAWithV3Sign_AK_Form(){
|
||||
$config = self::createConfig();
|
||||
$runtime = self::createRuntimeOptions();
|
||||
$config->protocol = "HTTP";
|
||||
$config->endpoint = "test.aliyuncs.com";
|
||||
$client = new OpenApiClient($config);
|
||||
$request = self::createOpenApiRequest();
|
||||
$params = new Params([
|
||||
"action" => "TestAPI",
|
||||
"version" => "2022-06-01",
|
||||
"protocol" => "HTTPS",
|
||||
"pathname" => "/test",
|
||||
"method" => "POST",
|
||||
"authType" => "AK",
|
||||
"style" => "ROA",
|
||||
"reqBodyType" => "formData",
|
||||
"bodyType" => "json"
|
||||
]);
|
||||
$client->callApi($params, $request, $runtime);
|
||||
}
|
||||
|
||||
public function testCallApiForROAWithV3Sign_Anonymous_JSON(){
|
||||
$config = self::createConfig();
|
||||
$runtime = self::createRuntimeOptions();
|
||||
$config->protocol = "HTTP";
|
||||
$config->endpoint = "test.aliyuncs.com";
|
||||
$client = new OpenApiClient($config);
|
||||
$request = self::createOpenApiRequest();
|
||||
$params = new Params([
|
||||
"action" => "TestAPI",
|
||||
"version" => "2022-06-01",
|
||||
"protocol" => "HTTPS",
|
||||
"pathname" => "/test",
|
||||
"method" => "POST",
|
||||
"authType" => "Anonymous",
|
||||
"style" => "ROA",
|
||||
"reqBodyType" => "json",
|
||||
"bodyType" => "json"
|
||||
]);
|
||||
$client->callApi($params, $request, $runtime);
|
||||
}
|
||||
|
||||
public function testResponseBodyType(){
|
||||
$config = self::createConfig();
|
||||
$runtime = self::createRuntimeOptions();
|
||||
$config->protocol = "HTTP";
|
||||
$config->endpoint = "test.aliyuncs.com";
|
||||
$client = new OpenApiClient($config);
|
||||
$request = self::createOpenApiRequest();
|
||||
$params = new Params([
|
||||
"action" => "TestAPI",
|
||||
"version" => "2022-06-01",
|
||||
"protocol" => "HTTPS",
|
||||
"pathname" => "/test",
|
||||
"method" => "POST",
|
||||
"authType" => "AK",
|
||||
"style" => "ROA",
|
||||
"reqBodyType" => "formData",
|
||||
"bodyType" => "json"
|
||||
]);
|
||||
$client->callApi($params, $request, $runtime);
|
||||
$params->bodyType = "array";
|
||||
$client->callApi($params, $request, $runtime);
|
||||
$params->bodyType = "string";
|
||||
$client->callApi($params, $request, $runtime);
|
||||
$params->bodyType = "byte";
|
||||
$client->callApi($params, $request, $runtime);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
<?php
|
||||
|
||||
require dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||
@@ -16,7 +16,7 @@
|
||||
"lizhichao/one-sm": "^1.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "*"
|
||||
"phpunit/phpunit": "^4.8.35|^5.4.3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Unit">
|
||||
<directory suffix="Test.php">./tests</directory>
|
||||
<directory suffix="Test.php">./tests/Unit</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
|
||||
@@ -160,26 +160,26 @@ class OpenApiUtilClient
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse object into a string with specified style.
|
||||
* Parse array into a string with specified style.
|
||||
*
|
||||
* @style specified style e.g. repeatList
|
||||
*
|
||||
* @param mixed $object the object
|
||||
* @param mixed $array the array
|
||||
* @param string $prefix the prefix string
|
||||
* @param string $style
|
||||
*
|
||||
* @return string the string
|
||||
*/
|
||||
public static function arrayToStringWithSpecifiedStyle($object, $prefix, $style)
|
||||
public static function arrayToStringWithSpecifiedStyle($array, $prefix, $style)
|
||||
{
|
||||
if (null === $object) {
|
||||
if (null === $array) {
|
||||
return '';
|
||||
}
|
||||
if ('repeatList' === $style) {
|
||||
return self::toForm([$prefix => $object]);
|
||||
return self::toForm([$prefix => $array]);
|
||||
}
|
||||
if ('simple' == $style || 'spaceDelimited' == $style || 'pipeDelimited' == $style) {
|
||||
$strs = self::flatten($object);
|
||||
$strs = self::flatten($array);
|
||||
|
||||
switch ($style) {
|
||||
case 'spaceDelimited':
|
||||
@@ -192,8 +192,7 @@ class OpenApiUtilClient
|
||||
return implode(',', $strs);
|
||||
}
|
||||
} elseif ('json' === $style) {
|
||||
self::parse($object, $parsed);
|
||||
return json_encode($parsed);
|
||||
return json_encode($array);
|
||||
}
|
||||
|
||||
return '';
|
||||
@@ -424,7 +423,7 @@ class OpenApiUtilClient
|
||||
|
||||
foreach ($items as $key => $value) {
|
||||
$pos = \is_int($key) ? $key + 1 : $key;
|
||||
|
||||
|
||||
if ($value instanceof Model) {
|
||||
$value = $value->toMap();
|
||||
} elseif (\is_object($value)) {
|
||||
@@ -437,9 +436,6 @@ class OpenApiUtilClient
|
||||
self::flatten($value, $delimiter, $prepend . $pos . $delimiter)
|
||||
);
|
||||
} else {
|
||||
if (\is_bool($value)) {
|
||||
$value = true === $value ? 'true' : 'false';
|
||||
}
|
||||
$flatten[$prepend . $pos] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,14 +63,12 @@ class OpenApiUtilClientTest extends TestCase
|
||||
|
||||
public function testToForm()
|
||||
{
|
||||
$this->assertEquals('bool=true&client=test&strs.1=str1&strs.2=str2&strs.3=false&tag.key=value', OpenApiUtilClient::toForm([
|
||||
$this->assertEquals('client=test&strs.1=str1&strs.2=str2&tag.key=value', OpenApiUtilClient::toForm([
|
||||
'client' => 'test',
|
||||
'tag' => [
|
||||
'key' => 'value',
|
||||
],
|
||||
'strs' => ['str1', 'str2', false],
|
||||
'bool' => true,
|
||||
'null' => null,
|
||||
'strs' => ['str1', 'str2'],
|
||||
]));
|
||||
}
|
||||
|
||||
@@ -85,7 +83,6 @@ class OpenApiUtilClientTest extends TestCase
|
||||
$model = new MockModel();
|
||||
$model->a = 'foo';
|
||||
$model->c = 'boo';
|
||||
$model->r = true;
|
||||
|
||||
$array = [
|
||||
'a' => 'a',
|
||||
@@ -98,9 +95,7 @@ class OpenApiUtilClientTest extends TestCase
|
||||
'c' => ['x', 'y', 'z'],
|
||||
'd' => [
|
||||
$model
|
||||
],
|
||||
'e' => true,
|
||||
'f' => null,
|
||||
]
|
||||
];
|
||||
$this->assertEquals([
|
||||
'a' => 'a',
|
||||
@@ -112,10 +107,6 @@ class OpenApiUtilClientTest extends TestCase
|
||||
'd.1.A' => 'foo',
|
||||
'd.1.b' => '',
|
||||
'd.1.c' => 'boo',
|
||||
'd.1.c' => 'boo',
|
||||
'd.1.r' => 'true',
|
||||
'e' => 'true',
|
||||
'f' => null
|
||||
], OpenApiUtilClient::query($array));
|
||||
}
|
||||
|
||||
@@ -151,48 +142,6 @@ class OpenApiUtilClientTest extends TestCase
|
||||
)
|
||||
);
|
||||
|
||||
$test = new ParseModel([
|
||||
'str' => 'A',
|
||||
'model' => new ParseModel(['str' => 'sub model']),
|
||||
'array' => [1, 2, 3],
|
||||
]);
|
||||
$this->assertEquals(
|
||||
'{"str":"A","model":{"str":"sub model","model":null,"array":null},"array":[1,2,3]}',
|
||||
OpenApiUtilClient::arrayToStringWithSpecifiedStyle(
|
||||
$test,
|
||||
'instance',
|
||||
'json'
|
||||
)
|
||||
);
|
||||
// model item in array
|
||||
$test = [
|
||||
new ParseModel([
|
||||
'str' => 'A',
|
||||
]),
|
||||
];
|
||||
$this->assertEquals(
|
||||
'[{"str":"A","model":null,"array":null}]',
|
||||
OpenApiUtilClient::arrayToStringWithSpecifiedStyle(
|
||||
$test,
|
||||
'instance',
|
||||
'json'
|
||||
)
|
||||
);
|
||||
// model item in map
|
||||
$test = [
|
||||
'model' => new ParseModel([
|
||||
'str' => 'A',
|
||||
]),
|
||||
];
|
||||
$this->assertEquals(
|
||||
'{"model":{"str":"A","model":null,"array":null}}',
|
||||
OpenApiUtilClient::arrayToStringWithSpecifiedStyle(
|
||||
$test,
|
||||
'instance',
|
||||
'json'
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'ok,test,2,3',
|
||||
OpenApiUtilClient::arrayToStringWithSpecifiedStyle(
|
||||
@@ -346,8 +295,7 @@ class OpenApiUtilClientTest extends TestCase
|
||||
'b9ff646822f41ef647c1416fa2b8408923828abc0464af6706e18db3e8553da8',
|
||||
OpenApiUtilClient::hexEncode(OpenApiUtilClient::sign('secret', 'source', 'ACS3-HMAC-SM3'))
|
||||
);
|
||||
$this->assertEquals(
|
||||
'1d93c62698a1c26427265668e79fac099aa26c1df873669599a2fb2f272e64c9',
|
||||
$this->assertEquals('1d93c62698a1c26427265668e79fac099aa26c1df873669599a2fb2f272e64c9',
|
||||
OpenApiUtilClient::hexEncode(OpenApiUtilClient::sign('secret', 'source', 'ACS3-HMAC-SHA256'))
|
||||
);
|
||||
}
|
||||
@@ -363,14 +311,14 @@ class OpenApiUtilClientTest extends TestCase
|
||||
'array' => [1, 2, 3],
|
||||
]),
|
||||
[ // model item in array
|
||||
new ParseModel([
|
||||
'str' => 'A',
|
||||
]),
|
||||
new ParseModel([
|
||||
'str' => 'A',
|
||||
]),
|
||||
],
|
||||
[ // model item in map
|
||||
'model' => new ParseModel([
|
||||
'str' => 'A',
|
||||
]),
|
||||
'model' => new ParseModel([
|
||||
'str' => 'A',
|
||||
]),
|
||||
],
|
||||
],
|
||||
'expected' => [
|
||||
@@ -399,12 +347,6 @@ class OpenApiUtilClientTest extends TestCase
|
||||
],
|
||||
],
|
||||
],
|
||||
'expectedJsonStr' => [
|
||||
'["NotArray"]',
|
||||
'NotArray',
|
||||
'NotArray',
|
||||
'NotArray',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
29
Server/vendor/alibabacloud/tea-utils/phpunit.xml
vendored
29
Server/vendor/alibabacloud/tea-utils/phpunit.xml
vendored
@@ -1,18 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="tests/bootstrap.php" colors="true" executionOrder="depends,defects" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
|
||||
<coverage>
|
||||
<include>
|
||||
<directory suffix=".php">src</directory>
|
||||
</include>
|
||||
<report>
|
||||
<clover outputFile="cache/coverage.clover"/>
|
||||
<html outputDirectory="cache/coverage" lowUpperBound="35" highLowerBound="70"/>
|
||||
</report>
|
||||
</coverage>
|
||||
<logging/>
|
||||
<testsuites>
|
||||
<testsuite name="default">
|
||||
<directory suffix="Test.php">tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<phpunit backupGlobals="false" backupStaticAttributes="false" bootstrap="tests/bootstrap.php" colors="true"
|
||||
convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true"
|
||||
executionOrder="depends,defects" processIsolation="false" stopOnFailure="false">
|
||||
<logging>
|
||||
<log type="coverage-html" target="cache/coverage" lowUpperBound="35" highLowerBound="70"/>
|
||||
<log type="coverage-clover" target="cache/coverage.clover"/>
|
||||
</logging>
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="default">
|
||||
<directory suffix="Test.php">tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
||||
|
||||
@@ -19,9 +19,6 @@ class Utils
|
||||
*/
|
||||
public static function toBytes($string)
|
||||
{
|
||||
if (self::is_bytes($string)) {
|
||||
return $string;
|
||||
}
|
||||
$bytes = [];
|
||||
for ($i = 0; $i < \strlen($string); ++$i) {
|
||||
$bytes[] = \ord($string[$i]);
|
||||
@@ -39,9 +36,6 @@ class Utils
|
||||
*/
|
||||
public static function toString($bytes)
|
||||
{
|
||||
if (\is_string($bytes)) {
|
||||
return $bytes;
|
||||
}
|
||||
$str = '';
|
||||
foreach ($bytes as $ch) {
|
||||
$str .= \chr($ch);
|
||||
@@ -191,7 +185,7 @@ class Utils
|
||||
$object = $object->toMap();
|
||||
}
|
||||
|
||||
return json_encode($object, JSON_UNESCAPED_UNICODE + JSON_UNESCAPED_SLASHES);
|
||||
return json_encode($object);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -386,7 +380,7 @@ class Utils
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return int the number value
|
||||
* @return bool the number value
|
||||
*/
|
||||
public static function assertAsNumber($value)
|
||||
{
|
||||
@@ -397,19 +391,6 @@ class Utils
|
||||
throw new \InvalidArgumentException('It is not a number value.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert a value, if it is a integer, return it, otherwise throws
|
||||
* @param mixed $value
|
||||
* @return int the integer value
|
||||
*/
|
||||
public static function assertAsInteger($value){
|
||||
if (\is_int($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException('It is not a int value.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert a value, if it is a map, return it, otherwise throws.
|
||||
*
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
namespace AlibabaCloud\Tea\Utils\Utils;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
class ExtendsParameters extends Model {
|
||||
public function validate() {}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->headers) {
|
||||
$res['headers'] = $this->headers;
|
||||
}
|
||||
if (null !== $this->queries) {
|
||||
$res['queries'] = $this->queries;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return ExtendsParameters
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['headers'])){
|
||||
$model->headers = $map['headers'];
|
||||
}
|
||||
if(isset($map['queries'])){
|
||||
$model->queries = $map['queries'];
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
public $headers;
|
||||
|
||||
public $queries;
|
||||
|
||||
}
|
||||
@@ -1,273 +1,41 @@
|
||||
<?php
|
||||
|
||||
// This file is auto-generated, don't edit it. Thanks.
|
||||
|
||||
namespace AlibabaCloud\Tea\Utils\Utils;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
|
||||
/**
|
||||
* The common runtime options model
|
||||
*/
|
||||
class RuntimeOptions extends Model {
|
||||
protected $_name = [
|
||||
'autoretry' => 'autoretry',
|
||||
'ignoreSSL' => 'ignoreSSL',
|
||||
'key' => 'key',
|
||||
'cert' => 'cert',
|
||||
'ca' => 'ca',
|
||||
'maxAttempts' => 'max_attempts',
|
||||
'backoffPolicy' => 'backoff_policy',
|
||||
'backoffPeriod' => 'backoff_period',
|
||||
'readTimeout' => 'readTimeout',
|
||||
'connectTimeout' => 'connectTimeout',
|
||||
'httpProxy' => 'httpProxy',
|
||||
'httpsProxy' => 'httpsProxy',
|
||||
'noProxy' => 'noProxy',
|
||||
'maxIdleConns' => 'maxIdleConns',
|
||||
'localAddr' => 'localAddr',
|
||||
'socks5Proxy' => 'socks5Proxy',
|
||||
'socks5NetWork' => 'socks5NetWork',
|
||||
'keepAlive' => 'keepAlive',
|
||||
];
|
||||
public function validate() {}
|
||||
public function toMap() {
|
||||
$res = [];
|
||||
if (null !== $this->autoretry) {
|
||||
$res['autoretry'] = $this->autoretry;
|
||||
}
|
||||
if (null !== $this->ignoreSSL) {
|
||||
$res['ignoreSSL'] = $this->ignoreSSL;
|
||||
}
|
||||
if (null !== $this->key) {
|
||||
$res['key'] = $this->key;
|
||||
}
|
||||
if (null !== $this->cert) {
|
||||
$res['cert'] = $this->cert;
|
||||
}
|
||||
if (null !== $this->ca) {
|
||||
$res['ca'] = $this->ca;
|
||||
}
|
||||
if (null !== $this->maxAttempts) {
|
||||
$res['max_attempts'] = $this->maxAttempts;
|
||||
}
|
||||
if (null !== $this->backoffPolicy) {
|
||||
$res['backoff_policy'] = $this->backoffPolicy;
|
||||
}
|
||||
if (null !== $this->backoffPeriod) {
|
||||
$res['backoff_period'] = $this->backoffPeriod;
|
||||
}
|
||||
if (null !== $this->readTimeout) {
|
||||
$res['readTimeout'] = $this->readTimeout;
|
||||
}
|
||||
if (null !== $this->connectTimeout) {
|
||||
$res['connectTimeout'] = $this->connectTimeout;
|
||||
}
|
||||
if (null !== $this->httpProxy) {
|
||||
$res['httpProxy'] = $this->httpProxy;
|
||||
}
|
||||
if (null !== $this->httpsProxy) {
|
||||
$res['httpsProxy'] = $this->httpsProxy;
|
||||
}
|
||||
if (null !== $this->noProxy) {
|
||||
$res['noProxy'] = $this->noProxy;
|
||||
}
|
||||
if (null !== $this->maxIdleConns) {
|
||||
$res['maxIdleConns'] = $this->maxIdleConns;
|
||||
}
|
||||
if (null !== $this->localAddr) {
|
||||
$res['localAddr'] = $this->localAddr;
|
||||
}
|
||||
if (null !== $this->socks5Proxy) {
|
||||
$res['socks5Proxy'] = $this->socks5Proxy;
|
||||
}
|
||||
if (null !== $this->socks5NetWork) {
|
||||
$res['socks5NetWork'] = $this->socks5NetWork;
|
||||
}
|
||||
if (null !== $this->keepAlive) {
|
||||
$res['keepAlive'] = $this->keepAlive;
|
||||
}
|
||||
if (null !== $this->extendsParameters) {
|
||||
$res['extendsParameters'] = null !== $this->extendsParameters ? $this->extendsParameters->toMap() : null;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
/**
|
||||
* @param array $map
|
||||
* @return RuntimeOptions
|
||||
*/
|
||||
public static function fromMap($map = []) {
|
||||
$model = new self();
|
||||
if(isset($map['autoretry'])){
|
||||
$model->autoretry = $map['autoretry'];
|
||||
}
|
||||
if(isset($map['ignoreSSL'])){
|
||||
$model->ignoreSSL = $map['ignoreSSL'];
|
||||
}
|
||||
if(isset($map['key'])){
|
||||
$model->key = $map['key'];
|
||||
}
|
||||
if(isset($map['cert'])){
|
||||
$model->cert = $map['cert'];
|
||||
}
|
||||
if(isset($map['ca'])){
|
||||
$model->ca = $map['ca'];
|
||||
}
|
||||
if(isset($map['max_attempts'])){
|
||||
$model->maxAttempts = $map['max_attempts'];
|
||||
}
|
||||
if(isset($map['backoff_policy'])){
|
||||
$model->backoffPolicy = $map['backoff_policy'];
|
||||
}
|
||||
if(isset($map['backoff_period'])){
|
||||
$model->backoffPeriod = $map['backoff_period'];
|
||||
}
|
||||
if(isset($map['readTimeout'])){
|
||||
$model->readTimeout = $map['readTimeout'];
|
||||
}
|
||||
if(isset($map['connectTimeout'])){
|
||||
$model->connectTimeout = $map['connectTimeout'];
|
||||
}
|
||||
if(isset($map['httpProxy'])){
|
||||
$model->httpProxy = $map['httpProxy'];
|
||||
}
|
||||
if(isset($map['httpsProxy'])){
|
||||
$model->httpsProxy = $map['httpsProxy'];
|
||||
}
|
||||
if(isset($map['noProxy'])){
|
||||
$model->noProxy = $map['noProxy'];
|
||||
}
|
||||
if(isset($map['maxIdleConns'])){
|
||||
$model->maxIdleConns = $map['maxIdleConns'];
|
||||
}
|
||||
if(isset($map['localAddr'])){
|
||||
$model->localAddr = $map['localAddr'];
|
||||
}
|
||||
if(isset($map['socks5Proxy'])){
|
||||
$model->socks5Proxy = $map['socks5Proxy'];
|
||||
}
|
||||
if(isset($map['socks5NetWork'])){
|
||||
$model->socks5NetWork = $map['socks5NetWork'];
|
||||
}
|
||||
if(isset($map['keepAlive'])){
|
||||
$model->keepAlive = $map['keepAlive'];
|
||||
}
|
||||
if(isset($map['extendsParameters'])){
|
||||
$model->extendsParameters = ExtendsParameters::fromMap($map['extendsParameters']);
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
/**
|
||||
* @description whether to try again
|
||||
* @var bool
|
||||
*/
|
||||
class RuntimeOptions extends Model
|
||||
{
|
||||
public $autoretry;
|
||||
|
||||
/**
|
||||
* @description ignore SSL validation
|
||||
* @var bool
|
||||
*/
|
||||
public $ignoreSSL;
|
||||
|
||||
/**
|
||||
* @description privite key for client certificate
|
||||
* @var string
|
||||
*/
|
||||
public $key;
|
||||
|
||||
/**
|
||||
* @description client certificate
|
||||
* @var string
|
||||
*/
|
||||
public $cert;
|
||||
|
||||
/**
|
||||
* @description server certificate
|
||||
* @var string
|
||||
*/
|
||||
public $ca;
|
||||
|
||||
/**
|
||||
* @description maximum number of retries
|
||||
* @var int
|
||||
*/
|
||||
public $maxAttempts;
|
||||
|
||||
/**
|
||||
* @description backoff policy
|
||||
* @var string
|
||||
*/
|
||||
public $backoffPolicy;
|
||||
|
||||
/**
|
||||
* @description backoff period
|
||||
* @var int
|
||||
*/
|
||||
public $backoffPeriod;
|
||||
|
||||
/**
|
||||
* @description read timeout
|
||||
* @var int
|
||||
*/
|
||||
public $readTimeout;
|
||||
|
||||
/**
|
||||
* @description connect timeout
|
||||
* @var int
|
||||
*/
|
||||
public $connectTimeout;
|
||||
|
||||
/**
|
||||
* @description http proxy url
|
||||
* @var string
|
||||
*/
|
||||
public $httpProxy;
|
||||
|
||||
/**
|
||||
* @description https Proxy url
|
||||
* @var string
|
||||
*/
|
||||
public $httpsProxy;
|
||||
|
||||
/**
|
||||
* @description agent blacklist
|
||||
* @var string
|
||||
*/
|
||||
public $noProxy;
|
||||
|
||||
/**
|
||||
* @description maximum number of connections
|
||||
* @var int
|
||||
*/
|
||||
public $maxIdleConns;
|
||||
|
||||
/**
|
||||
* @description local addr
|
||||
* @var string
|
||||
*/
|
||||
public $localAddr;
|
||||
|
||||
/**
|
||||
* @description SOCKS5 proxy
|
||||
* @var string
|
||||
*/
|
||||
public $socks5Proxy;
|
||||
|
||||
/**
|
||||
* @description SOCKS5 netWork
|
||||
* @var string
|
||||
*/
|
||||
public $socks5NetWork;
|
||||
|
||||
/**
|
||||
* @description whether to enable keep-alive
|
||||
* @var bool
|
||||
*/
|
||||
public $keepAlive;
|
||||
|
||||
/**
|
||||
* @description Extends Parameters
|
||||
* @var ExtendsParameters
|
||||
*/
|
||||
public $extendsParameters;
|
||||
|
||||
protected $_name = [];
|
||||
}
|
||||
|
||||
@@ -4,8 +4,6 @@ namespace AlibabaCloud\Tea\Utils\Tests;
|
||||
|
||||
use AlibabaCloud\Tea\Model;
|
||||
use AlibabaCloud\Tea\Utils\Utils;
|
||||
use AlibabaCloud\Tea\Utils\Utils\ExtendsParameters;
|
||||
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
|
||||
use GuzzleHttp\Psr7\Stream;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
@@ -26,11 +24,6 @@ final class UtilsTest extends TestCase
|
||||
$this->assertEquals([
|
||||
115, 116, 114, 105, 110, 103,
|
||||
], Utils::toBytes('string'));
|
||||
$this->assertEquals([
|
||||
115, 116, 114, 105, 110, 103,
|
||||
], Utils::toBytes([
|
||||
115, 116, 114, 105, 110, 103,
|
||||
]));
|
||||
}
|
||||
|
||||
public function testToString()
|
||||
@@ -38,7 +31,6 @@ final class UtilsTest extends TestCase
|
||||
$this->assertEquals('string', Utils::toString([
|
||||
115, 116, 114, 105, 110, 103,
|
||||
]));
|
||||
$this->assertEquals('string', Utils::toString('string'));
|
||||
}
|
||||
|
||||
public function testParseJSON()
|
||||
@@ -116,17 +108,12 @@ final class UtilsTest extends TestCase
|
||||
$this->assertJson(Utils::toJSONString($object));
|
||||
$this->assertEquals('[]', Utils::toJSONString([]));
|
||||
$this->assertEquals('["foo"]', Utils::toJSONString(['foo']));
|
||||
$this->assertEquals(
|
||||
'{"str":"test","number":1,"bool":false,"null":null,"chinese":"中文","http":"https://aliyun.com:8080/zh/中文.html"}',
|
||||
Utils::toJSONString([
|
||||
'str' => 'test',
|
||||
'number' => 1,
|
||||
'bool' => FALSE,
|
||||
'null' => null,
|
||||
'chinese' => '中文',
|
||||
'http' => 'https://aliyun.com:8080/zh/中文.html',
|
||||
])
|
||||
);
|
||||
$this->assertEquals('{"str":"test","number":1,"bool":false,"null":null}', Utils::toJSONString([
|
||||
'str' => 'test',
|
||||
'number' => 1,
|
||||
'bool' => FALSE,
|
||||
'null' => null,
|
||||
]));
|
||||
$this->assertEquals('1', Utils::toJSONString(1));
|
||||
$this->assertEquals('true', Utils::toJSONString(TRUE));
|
||||
$this->assertEquals('null', Utils::toJSONString(null));
|
||||
@@ -263,21 +250,6 @@ final class UtilsTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function testAssertAsInteger()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('It is not a int value.');
|
||||
Utils::assertAsInteger('is not int');
|
||||
|
||||
try {
|
||||
$map = 123;
|
||||
$this->assertEquals($map, Utils::assertAsInteger($map));
|
||||
} catch (\Exception $e) {
|
||||
// should not be here
|
||||
$this->assertTrue(false);
|
||||
}
|
||||
}
|
||||
|
||||
public function testAssertAsMap()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
@@ -399,48 +371,6 @@ final class UtilsTest extends TestCase
|
||||
Utils::assertAsReadable(0);
|
||||
}
|
||||
|
||||
public function testRuntimeOptions()
|
||||
{
|
||||
$opts = new RuntimeOptions([
|
||||
"autoretry" => false,
|
||||
"ignoreSSL" => false,
|
||||
"key" => "key",
|
||||
"cert" => "cert",
|
||||
"ca" => "ca",
|
||||
"maxAttempts" => 3,
|
||||
"backoffPolicy" => "backoffPolicy",
|
||||
"backoffPeriod" => 10,
|
||||
"readTimeout" => 3000,
|
||||
"connectTimeout" => 3000,
|
||||
"httpProxy" => "httpProxy",
|
||||
"httpsProxy" => "httpsProxy",
|
||||
"noProxy" => "noProxy",
|
||||
"maxIdleConns" => 300,
|
||||
"keepAlive" => true,
|
||||
"extendsParameters" => new ExtendsParameters([
|
||||
"headers" => ['key' => 'value'],
|
||||
"queries" => ['key' => 'value'],
|
||||
]),
|
||||
]);
|
||||
$this->assertEquals(false, $opts->autoretry);
|
||||
$this->assertEquals(false, $opts->ignoreSSL);
|
||||
$this->assertEquals("key", $opts->key);
|
||||
$this->assertEquals("cert", $opts->cert);
|
||||
$this->assertEquals("ca", $opts->ca);
|
||||
$this->assertEquals(3, $opts->maxAttempts);
|
||||
$this->assertEquals("backoffPolicy", $opts->backoffPolicy);
|
||||
$this->assertEquals(10, $opts->backoffPeriod);
|
||||
$this->assertEquals(3000, $opts->readTimeout);
|
||||
$this->assertEquals(3000, $opts->connectTimeout);
|
||||
$this->assertEquals("httpProxy", $opts->httpProxy);
|
||||
$this->assertEquals("httpsProxy", $opts->httpsProxy);
|
||||
$this->assertEquals("noProxy", $opts->noProxy);
|
||||
$this->assertEquals(300, $opts->maxIdleConns);
|
||||
$this->assertEquals(true, $opts->keepAlive);
|
||||
$this->assertEquals('value', $opts->extendsParameters->headers['key']);
|
||||
$this->assertEquals('value', $opts->extendsParameters->queries['key']);
|
||||
}
|
||||
|
||||
private function convert($body, &$content)
|
||||
{
|
||||
$class = new \ReflectionClass($body);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"php": ">5.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "*",
|
||||
"phpunit/phpunit": "^4.8.35|^5.4.3",
|
||||
"symfony/var-dumper": "*"
|
||||
},
|
||||
"autoload": {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Unit">
|
||||
<directory suffix="Test.php">./tests</directory>
|
||||
<directory suffix="Test.php">./tests/Unit</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
|
||||
@@ -8,14 +8,14 @@ class XML
|
||||
{
|
||||
$res = self::parse($xmlStr);
|
||||
if ($response === null) {
|
||||
return $res;
|
||||
return $ref;
|
||||
} else {
|
||||
if (\is_string($response)) {
|
||||
$response = new $response();
|
||||
}
|
||||
$prop = get_object_vars($response);
|
||||
$target = [];
|
||||
|
||||
|
||||
foreach ($res as $k => $v) {
|
||||
if (isset($prop[$k])) {
|
||||
$target[$k] = $v;
|
||||
@@ -45,9 +45,7 @@ class XML
|
||||
|
||||
private static function parse($xml)
|
||||
{
|
||||
if (\PHP_VERSION_ID < 80000) {
|
||||
libxml_disable_entity_loader(true);
|
||||
}
|
||||
libxml_disable_entity_loader(true);
|
||||
|
||||
return json_decode(
|
||||
json_encode(
|
||||
|
||||
@@ -23,13 +23,13 @@ class RpcUtilsTest extends TestCase
|
||||
$name = $res['name'];
|
||||
$value = $res['value'];
|
||||
$this->assertEquals('test', $name);
|
||||
$this->assertEquals(1, $value);
|
||||
$this->assertEquals('1', $value);
|
||||
|
||||
$res = XML::parseXml($this->xmlStr, null);
|
||||
$name = $res['name'];
|
||||
$value = $res['value'];
|
||||
$this->assertEquals('test', $name);
|
||||
$this->assertEquals(1, $value);
|
||||
$this->assertEquals('1', $value);
|
||||
}
|
||||
|
||||
public function testArrayToXML()
|
||||
|
||||
2
Server/vendor/alibabacloud/tea/composer.json
vendored
2
Server/vendor/alibabacloud/tea/composer.json
vendored
@@ -31,7 +31,7 @@
|
||||
"ext-simplexml": "*",
|
||||
"ext-xmlwriter": "*",
|
||||
"guzzlehttp/guzzle": "^6.3|^7.0",
|
||||
"adbario/php-dot-notation": "^2.4"
|
||||
"adbario/php-dot-notation": "^2.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/dotenv": "^3.4",
|
||||
|
||||
@@ -13,9 +13,6 @@ class TeaError extends RuntimeException
|
||||
public $code = 0;
|
||||
public $data;
|
||||
public $name = '';
|
||||
public $statusCode;
|
||||
public $description;
|
||||
public $accessDeniedDetail;
|
||||
private $errorInfo;
|
||||
|
||||
/**
|
||||
@@ -31,13 +28,10 @@ class TeaError extends RuntimeException
|
||||
parent::__construct((string) $message, (int) $code, $previous);
|
||||
$this->errorInfo = $errorInfo;
|
||||
if (!empty($errorInfo)) {
|
||||
$properties = ['name', 'message', 'code', 'data', 'description', 'accessDeniedDetail'];
|
||||
$properties = ['name', 'message', 'code', 'data'];
|
||||
foreach ($properties as $property) {
|
||||
if (isset($errorInfo[$property])) {
|
||||
$this->{$property} = $errorInfo[$property];
|
||||
if ($property === 'data' && isset($errorInfo['data']['statusCode'])) {
|
||||
$this->statusCode = $errorInfo['data']['statusCode'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
44
Server/vendor/alibabacloud/tea/src/Helper.php
vendored
44
Server/vendor/alibabacloud/tea/src/Helper.php
vendored
@@ -37,50 +37,6 @@ class Helper
|
||||
return \JSON_ERROR_NONE == json_last_error();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isBytes($value)
|
||||
{
|
||||
if (!\is_array($value)) {
|
||||
return false;
|
||||
}
|
||||
$i = 0;
|
||||
foreach ($value as $k => $ord) {
|
||||
if ($k !== $i) {
|
||||
return false;
|
||||
}
|
||||
if (!\is_int($ord)) {
|
||||
return false;
|
||||
}
|
||||
if ($ord < 0 || $ord > 255) {
|
||||
return false;
|
||||
}
|
||||
++$i;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a bytes to string(utf8).
|
||||
*
|
||||
* @param array $bytes
|
||||
*
|
||||
* @return string the return string
|
||||
*/
|
||||
public static function toString($bytes)
|
||||
{
|
||||
$str = '';
|
||||
foreach ($bytes as $ch) {
|
||||
$str .= \chr($ch);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
|
||||
@@ -89,15 +89,11 @@ class Request extends PsrRequest
|
||||
if ($this->body instanceof StreamInterface) {
|
||||
$request = $request->withBody($this->body);
|
||||
} else {
|
||||
$body = $this->body;
|
||||
if (Helper::isBytes($this->body)) {
|
||||
$body = Helper::toString($this->body);
|
||||
}
|
||||
if (\function_exists('\GuzzleHttp\Psr7\stream_for')) {
|
||||
// @deprecated stream_for will be removed in guzzlehttp/psr7:2.0
|
||||
$request = $request->withBody(\GuzzleHttp\Psr7\stream_for($body));
|
||||
$request = $request->withBody(\GuzzleHttp\Psr7\stream_for($this->body));
|
||||
} else {
|
||||
$request = $request->withBody(\GuzzleHttp\Psr7\Utils::streamFor($body));
|
||||
$request = $request->withBody(\GuzzleHttp\Psr7\Utils::streamFor($this->body));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
3
Server/vendor/alibabacloud/tea/src/Tea.php
vendored
3
Server/vendor/alibabacloud/tea/src/Tea.php
vendored
@@ -273,9 +273,6 @@ class Tea
|
||||
if (isset($config['noProxy']) && !empty($config['noProxy'])) {
|
||||
$options->set('proxy.no', $config['noProxy']);
|
||||
}
|
||||
if (isset($config['ignoreSSL']) && !empty($config['ignoreSSL'])) {
|
||||
$options->set('verify',!((bool)$config['ignoreSSL']));
|
||||
}
|
||||
// readTimeout&connectTimeout unit is millisecond
|
||||
$read_timeout = isset($config['readTimeout']) && !empty($config['readTimeout']) ? (int) $config['readTimeout'] : 0;
|
||||
$con_timeout = isset($config['connectTimeout']) && !empty($config['connectTimeout']) ? (int) $config['connectTimeout'] : 0;
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
# ChangeLog - Aliyun OSS SDK for PHP
|
||||
|
||||
## v2.7.2 / 2024-10-28
|
||||
* Added: presign supports response-* parameters
|
||||
* Added: forcePathStyle option.
|
||||
|
||||
## v2.7.1 / 2024-02-28
|
||||
* Fixed: fix deprecated
|
||||
|
||||
|
||||
@@ -169,11 +169,6 @@ class OssClient
|
||||
throw new OssException("endpoint is empty");
|
||||
}
|
||||
$this->hostname = $this->checkEndpoint($endpoint, $isCName);
|
||||
if (isset($config['forcePathStyle'])) {
|
||||
if ($config['forcePathStyle'] === true) {
|
||||
$this->hostType = self::OSS_HOST_TYPE_PATH_STYLE;
|
||||
}
|
||||
}
|
||||
$this->requestProxy = $requestProxy;
|
||||
if (!$provider instanceof CredentialsProvider) {
|
||||
throw new OssException("provider must be an instance of CredentialsProvider");
|
||||
@@ -2377,7 +2372,7 @@ class OssClient
|
||||
$options[self::OSS_OBJECT] = $object;
|
||||
$options[self::OSS_SUB_RESOURCE] = 'x-oss-async-process';
|
||||
$options[self::OSS_CONTENT_TYPE] = 'application/octet-stream';
|
||||
$options[self::OSS_CONTENT] = 'x-oss-async-process=' . $asyncProcess;
|
||||
$options[self::OSS_CONTENT] = 'x-oss-async-process='.$asyncProcess;
|
||||
$response = $this->auth($options);
|
||||
$result = new BodyResult($response);
|
||||
return $result->getData();
|
||||
@@ -3004,7 +2999,7 @@ class OssClient
|
||||
return $this->getValue($options, self::OSS_CHECK_MD5, false, true, true);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Gets value of the specified key from the options
|
||||
*
|
||||
* @param array $options
|
||||
@@ -3274,7 +3269,7 @@ class OssClient
|
||||
|
||||
try {
|
||||
$tmp_object = $options[self::OSS_OBJECT];
|
||||
$encoding = array('UTF-8', 'GB2312', 'GBK');
|
||||
$encoding = array('UTF-8','GB2312', 'GBK');
|
||||
$encode = mb_detect_encoding($tmp_object, $encoding);
|
||||
if ($encode === 'UTF-8' || $encode === false) {
|
||||
return;
|
||||
@@ -3338,9 +3333,6 @@ class OssClient
|
||||
if ('' !== $bucket) {
|
||||
if ($this->hostType === self::OSS_HOST_TYPE_IP || $this->hostType === self::OSS_HOST_TYPE_PATH_STYLE) {
|
||||
$paths[] = $bucket;
|
||||
if ('' === $object) {
|
||||
$paths[] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
// + object
|
||||
@@ -3362,12 +3354,6 @@ class OssClient
|
||||
$query = array();
|
||||
$queryList = array(
|
||||
self::OSS_PART_NUM,
|
||||
'response-content-type',
|
||||
'response-content-language',
|
||||
'response-cache-control',
|
||||
'response-content-encoding',
|
||||
'response-expires',
|
||||
'response-content-disposition',
|
||||
self::OSS_UPLOAD_ID,
|
||||
self::OSS_COMP,
|
||||
self::OSS_LIVE_CHANNEL_STATUS,
|
||||
@@ -3395,7 +3381,6 @@ class OssClient
|
||||
if (isset($options[self::OSS_SUB_RESOURCE])) {
|
||||
$query[$options[self::OSS_SUB_RESOURCE]] = '';
|
||||
}
|
||||
|
||||
return OssUtil::toQueryString($query);
|
||||
}
|
||||
|
||||
@@ -3534,7 +3519,7 @@ class OssClient
|
||||
}
|
||||
|
||||
try {
|
||||
$encoding = array('UTF-8', 'GB2312', 'GBK');
|
||||
$encoding = array('UTF-8','GB2312', 'GBK');
|
||||
$encode = mb_detect_encoding($filepath, $encoding);
|
||||
if ($encode !== 'UTF-8') {
|
||||
return $filepath;
|
||||
@@ -3549,7 +3534,7 @@ class OssClient
|
||||
return $filepath;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Decodes the file path from GBK to UTF-8.
|
||||
*
|
||||
* @param $filepath
|
||||
@@ -3565,7 +3550,7 @@ class OssClient
|
||||
}
|
||||
|
||||
try {
|
||||
$encoding = array('UTF-8', 'GB2312', 'GBK');
|
||||
$encoding = array('UTF-8','GB2312', 'GBK');
|
||||
$encode = mb_detect_encoding($filepath, $encoding);
|
||||
if ($encode === 'UTF-8' || $encode === false) {
|
||||
return $filepath;
|
||||
@@ -3760,8 +3745,8 @@ class OssClient
|
||||
);
|
||||
// OssClient version information
|
||||
const OSS_NAME = "aliyun-sdk-php";
|
||||
const OSS_VERSION = "2.7.2";
|
||||
const OSS_BUILD = "20241028";
|
||||
const OSS_VERSION = "2.7.1";
|
||||
const OSS_BUILD = "20240228";
|
||||
const OSS_AUTHOR = "";
|
||||
const OSS_OPTIONS_ORIGIN = 'Origin';
|
||||
const OSS_OPTIONS_REQUEST_METHOD = 'Access-Control-Request-Method';
|
||||
|
||||
@@ -133,11 +133,6 @@ class Common
|
||||
return OssClient::OSS_SIGNATURE_VERSION_V1;
|
||||
}
|
||||
|
||||
public static function getPathStyleBucket()
|
||||
{
|
||||
return getenv('OSS_TEST_PATHSTYLE_BUCKET');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tool method, create a bucket
|
||||
*/
|
||||
|
||||
@@ -3,7 +3,10 @@
|
||||
namespace OSS\Tests;
|
||||
|
||||
use OSS\Core\OssException;
|
||||
use OSS\Http\RequestCore;
|
||||
use OSS\Credentials\StaticCredentialsProvider;
|
||||
use OSS\Model\LifecycleConfig;
|
||||
use OSS\Model\LifecycleRule;
|
||||
use OSS\Model\LifecycleAction;
|
||||
use OSS\OssClient;
|
||||
|
||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php';
|
||||
@@ -15,14 +18,12 @@ class OssClientForcePathStyleTest extends TestOssClientBase
|
||||
{
|
||||
$config = array(
|
||||
'signatureVersion' => OssClient::OSS_SIGNATURE_VERSION_V4,
|
||||
'forcePathStyle' => true,
|
||||
'hostType' => OssClient::OSS_HOST_TYPE_PATH_STYLE,
|
||||
);
|
||||
|
||||
$pathStyleClient = Common::getOssClient($config);
|
||||
$this->ossClient = Common::getOssClient($config);
|
||||
|
||||
try {
|
||||
$pathStyleClient->getBucketInfo($this->bucket);
|
||||
$this->assertTrue(false, "should not here");
|
||||
$this->ossClient->getBucketInfo($this->bucket);
|
||||
} catch (OssException $e) {
|
||||
$this->assertEquals($e->getErrorCode(), "SecondLevelDomainForbidden");
|
||||
$this->assertTrue(true);
|
||||
@@ -30,8 +31,7 @@ class OssClientForcePathStyleTest extends TestOssClientBase
|
||||
|
||||
try {
|
||||
$object = "oss-php-sdk-test/upload-test-object-name.txt";
|
||||
$pathStyleClient->putObject($this->bucket, $object, 'hi oss');
|
||||
$this->assertTrue(false, "should not here");
|
||||
$this->ossClient->putObject($this->bucket, $object, 'hi oss');
|
||||
} catch (OssException $e) {
|
||||
$this->assertEquals($e->getErrorCode(), "SecondLevelDomainForbidden");
|
||||
$this->assertTrue(true);
|
||||
@@ -40,85 +40,11 @@ class OssClientForcePathStyleTest extends TestOssClientBase
|
||||
try {
|
||||
$endpoint = Common::getEndpoint();
|
||||
$endpoint = str_replace(array('http://', 'https://'), '', $endpoint);
|
||||
$strUrl = $endpoint . "/" . $this->bucket . '/' . $object;
|
||||
$signUrl = $pathStyleClient->signUrl($this->bucket, $object, 3600);
|
||||
$strUrl = $this->bucket . '.' . $endpoint . "/" . $object;
|
||||
$signUrl = $this->ossClient->signUrl($this->bucket, $object, 3600);
|
||||
$this->assertTrue(strpos($signUrl, $strUrl) !== false);
|
||||
} catch (OssException $e) {
|
||||
$this->assertFalse(true);
|
||||
}
|
||||
}
|
||||
|
||||
public function testForcePathStyleOKV1()
|
||||
{
|
||||
$bucket = Common::getPathStyleBucket();
|
||||
|
||||
$this->assertFalse(empty($bucket), "path style bucket is not set.");
|
||||
|
||||
$config = array(
|
||||
'signatureVersion' => OssClient::OSS_SIGNATURE_VERSION_V1,
|
||||
'forcePathStyle' => true,
|
||||
);
|
||||
|
||||
$pathStyleClient = Common::getOssClient($config);
|
||||
|
||||
// bucket
|
||||
$info = $pathStyleClient->getBucketInfo($bucket);
|
||||
$this->assertEquals($bucket, $info->getName());
|
||||
|
||||
// object
|
||||
$object = "upload-test-object-name.txt";
|
||||
$pathStyleClient->putObject($bucket, $object, 'hi oss');
|
||||
$res = $pathStyleClient->getObject($bucket, $object);
|
||||
$this->assertEquals($res, 'hi oss');
|
||||
|
||||
//presign
|
||||
$signUrl = $pathStyleClient->signUrl($bucket, $object, 3600);
|
||||
|
||||
$httpCore = new RequestCore($signUrl);
|
||||
$httpCore->set_body("");
|
||||
$httpCore->set_method("GET");
|
||||
$httpCore->connect_timeout = 10;
|
||||
$httpCore->timeout = 10;
|
||||
$httpCore->add_header("Content-Type", "");
|
||||
$httpCore->send_request();
|
||||
$this->assertEquals(200, $httpCore->response_code);
|
||||
}
|
||||
|
||||
public function testForcePathStyleOKV4()
|
||||
{
|
||||
$bucket = Common::getPathStyleBucket();
|
||||
|
||||
$this->assertFalse(empty($bucket), "path style bucket is not set.");
|
||||
|
||||
$config = array(
|
||||
'signatureVersion' => OssClient::OSS_SIGNATURE_VERSION_V4,
|
||||
'forcePathStyle' => true,
|
||||
);
|
||||
|
||||
$pathStyleClient = Common::getOssClient($config);
|
||||
|
||||
// bucket
|
||||
$info = $pathStyleClient->getBucketInfo($bucket);
|
||||
$this->assertEquals($bucket, $info->getName());
|
||||
|
||||
// object
|
||||
$object = "upload-test-object-name.txt";
|
||||
$pathStyleClient->putObject($bucket, $object, 'hi oss');
|
||||
$res = $pathStyleClient->getObject($bucket, $object);
|
||||
$this->assertEquals($res, 'hi oss');
|
||||
|
||||
//presign
|
||||
$signUrl = $pathStyleClient->signUrl($bucket, $object, 3600);
|
||||
|
||||
#print("signUrl" . $signUrl . "\n");
|
||||
|
||||
$httpCore = new RequestCore($signUrl);
|
||||
$httpCore->set_body("");
|
||||
$httpCore->set_method("GET");
|
||||
$httpCore->connect_timeout = 10;
|
||||
$httpCore->timeout = 10;
|
||||
$httpCore->add_header("Content-Type", "");
|
||||
$httpCore->send_request();
|
||||
$this->assertEquals(200, $httpCore->response_code);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace OSS\Tests;
|
||||
|
||||
use OSS\Core\OssException;
|
||||
use OSS\Credentials\StaticCredentialsProvider;
|
||||
use OSS\Http\RequestCore;
|
||||
use OSS\Http\ResponseCore;
|
||||
use OSS\OssClient;
|
||||
|
||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php';
|
||||
|
||||
|
||||
class OssClientPresignTest extends TestOssClientBase
|
||||
{
|
||||
protected $stsOssClient;
|
||||
|
||||
public function testObjectWithSignV1()
|
||||
{
|
||||
$config = array(
|
||||
'signatureVersion' => OssClient::OSS_SIGNATURE_VERSION_V1
|
||||
);
|
||||
$this->bucket = Common::getBucketName() . '-' . time();
|
||||
$this->ossClient = Common::getOssClient($config);
|
||||
$this->ossClient->createBucket($this->bucket);
|
||||
Common::waitMetaSync();
|
||||
|
||||
$object = "a.file";
|
||||
$this->ossClient->putObject($this->bucket, $object, "hi oss");
|
||||
$timeout = 3600;
|
||||
$options = array(
|
||||
"response-content-disposition" => "inline"
|
||||
);
|
||||
try {
|
||||
$signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, OssClient::OSS_HTTP_GET, $options);
|
||||
} catch (OssException $e) {
|
||||
$this->assertFalse(true);
|
||||
}
|
||||
$this->assertStringContainsString("response-content-disposition=inline", $signedUrl);
|
||||
$options = array(
|
||||
"response-content-disposition" => "attachment",
|
||||
);
|
||||
|
||||
try {
|
||||
$signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, OssClient::OSS_HTTP_GET, $options);
|
||||
} catch (OssException $e) {
|
||||
$this->assertFalse(true);
|
||||
}
|
||||
$this->assertStringContainsString("response-content-disposition=attachment", $signedUrl);
|
||||
|
||||
$httpCore = new RequestCore($signedUrl);
|
||||
$httpCore->set_body("");
|
||||
$httpCore->set_method("GET");
|
||||
$httpCore->connect_timeout = 10;
|
||||
$httpCore->timeout = 10;
|
||||
$httpCore->add_header("Content-Type", "");
|
||||
$httpCore->send_request();
|
||||
$this->assertEquals(200, $httpCore->response_code);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->ossClient->deleteObject($this->bucket, "a.file");
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -305,49 +305,6 @@ class OssClientPresignV4Test extends TestOssClientBase
|
||||
}
|
||||
}
|
||||
|
||||
public function testObjectWithSignV4AndResponseQuery()
|
||||
{
|
||||
$config = array(
|
||||
'signatureVersion' => OssClient::OSS_SIGNATURE_VERSION_V4
|
||||
);
|
||||
$this->bucket = Common::getBucketName() . '-' . time();
|
||||
$this->ossClient = Common::getOssClient($config);
|
||||
$this->ossClient->createBucket($this->bucket);
|
||||
Common::waitMetaSync();
|
||||
|
||||
$object = "a.file";
|
||||
$this->ossClient->putObject($this->bucket, $object, "hi oss");
|
||||
$timeout = 3600;
|
||||
$options = array(
|
||||
"response-content-disposition" => "inline"
|
||||
);
|
||||
try {
|
||||
$signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, OssClient::OSS_HTTP_GET, $options);
|
||||
} catch (OssException $e) {
|
||||
$this->assertFalse(true);
|
||||
}
|
||||
$this->assertStringContainsString("response-content-disposition=inline", $signedUrl);
|
||||
$options = array(
|
||||
"response-content-disposition" => "attachment"
|
||||
);
|
||||
|
||||
try {
|
||||
$signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, OssClient::OSS_HTTP_GET, $options);
|
||||
} catch (OssException $e) {
|
||||
$this->assertFalse(true);
|
||||
}
|
||||
$this->assertStringContainsString("response-content-disposition=attachment", $signedUrl);
|
||||
|
||||
$httpCore = new RequestCore($signedUrl);
|
||||
$httpCore->set_body("");
|
||||
$httpCore->set_method("GET");
|
||||
$httpCore->connect_timeout = 10;
|
||||
$httpCore->timeout = 10;
|
||||
$httpCore->add_header("Content-Type", "");
|
||||
$httpCore->send_request();
|
||||
$this->assertEquals(200, $httpCore->response_code);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->ossClient->deleteObject($this->bucket, "a.file");
|
||||
|
||||
18
Server/vendor/autoload.php
vendored
18
Server/vendor/autoload.php
vendored
@@ -2,24 +2,6 @@
|
||||
|
||||
// autoload.php @generated by Composer
|
||||
|
||||
if (PHP_VERSION_ID < 50600) {
|
||||
if (!headers_sent()) {
|
||||
header('HTTP/1.1 500 Internal Server Error');
|
||||
}
|
||||
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
|
||||
if (!ini_get('display_errors')) {
|
||||
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
||||
fwrite(STDERR, $err);
|
||||
} elseif (!headers_sent()) {
|
||||
echo $err;
|
||||
}
|
||||
}
|
||||
trigger_error(
|
||||
$err,
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit075712db3cd06cc0fc14f5ab72673de0::getLoader();
|
||||
|
||||
139
Server/vendor/composer/ClassLoader.php
vendored
139
Server/vendor/composer/ClassLoader.php
vendored
@@ -42,37 +42,35 @@ namespace Composer\Autoload;
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
/** @var \Closure(string):void */
|
||||
private static $includeFile;
|
||||
|
||||
/** @var string|null */
|
||||
/** @var ?string */
|
||||
private $vendorDir;
|
||||
|
||||
// PSR-4
|
||||
/**
|
||||
* @var array<string, array<string, int>>
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<string, int>>
|
||||
*/
|
||||
private $prefixLengthsPsr4 = array();
|
||||
/**
|
||||
* @var array<string, list<string>>
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<int, string>>
|
||||
*/
|
||||
private $prefixDirsPsr4 = array();
|
||||
/**
|
||||
* @var list<string>
|
||||
* @var array[]
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private $fallbackDirsPsr4 = array();
|
||||
|
||||
// PSR-0
|
||||
/**
|
||||
* List of PSR-0 prefixes
|
||||
*
|
||||
* Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
|
||||
*
|
||||
* @var array<string, array<string, list<string>>>
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<string, string[]>>
|
||||
*/
|
||||
private $prefixesPsr0 = array();
|
||||
/**
|
||||
* @var list<string>
|
||||
* @var array[]
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private $fallbackDirsPsr0 = array();
|
||||
|
||||
@@ -80,7 +78,8 @@ class ClassLoader
|
||||
private $useIncludePath = false;
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
* @var string[]
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private $classMap = array();
|
||||
|
||||
@@ -88,29 +87,29 @@ class ClassLoader
|
||||
private $classMapAuthoritative = false;
|
||||
|
||||
/**
|
||||
* @var array<string, bool>
|
||||
* @var bool[]
|
||||
* @psalm-var array<string, bool>
|
||||
*/
|
||||
private $missingClasses = array();
|
||||
|
||||
/** @var string|null */
|
||||
/** @var ?string */
|
||||
private $apcuPrefix;
|
||||
|
||||
/**
|
||||
* @var array<string, self>
|
||||
* @var self[]
|
||||
*/
|
||||
private static $registeredLoaders = array();
|
||||
|
||||
/**
|
||||
* @param string|null $vendorDir
|
||||
* @param ?string $vendorDir
|
||||
*/
|
||||
public function __construct($vendorDir = null)
|
||||
{
|
||||
$this->vendorDir = $vendorDir;
|
||||
self::initializeIncludeClosure();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, list<string>>
|
||||
* @return string[]
|
||||
*/
|
||||
public function getPrefixes()
|
||||
{
|
||||
@@ -122,7 +121,8 @@ class ClassLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, list<string>>
|
||||
* @return array[]
|
||||
* @psalm-return array<string, array<int, string>>
|
||||
*/
|
||||
public function getPrefixesPsr4()
|
||||
{
|
||||
@@ -130,7 +130,8 @@ class ClassLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
* @return array[]
|
||||
* @psalm-return array<string, string>
|
||||
*/
|
||||
public function getFallbackDirs()
|
||||
{
|
||||
@@ -138,7 +139,8 @@ class ClassLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
* @return array[]
|
||||
* @psalm-return array<string, string>
|
||||
*/
|
||||
public function getFallbackDirsPsr4()
|
||||
{
|
||||
@@ -146,7 +148,8 @@ class ClassLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string> Array of classname => path
|
||||
* @return string[] Array of classname => path
|
||||
* @psalm-return array<string, string>
|
||||
*/
|
||||
public function getClassMap()
|
||||
{
|
||||
@@ -154,7 +157,8 @@ class ClassLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $classMap Class to filename map
|
||||
* @param string[] $classMap Class to filename map
|
||||
* @psalm-param array<string, string> $classMap
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -171,25 +175,24 @@ class ClassLoader
|
||||
* Registers a set of PSR-0 directories for a given prefix, either
|
||||
* appending or prepending to the ones previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param list<string>|string $paths The PSR-0 root directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
* @param string $prefix The prefix
|
||||
* @param string[]|string $paths The PSR-0 root directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add($prefix, $paths, $prepend = false)
|
||||
{
|
||||
$paths = (array) $paths;
|
||||
if (!$prefix) {
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
$paths,
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr0
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
$this->fallbackDirsPsr0,
|
||||
$paths
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
|
||||
@@ -198,19 +201,19 @@ class ClassLoader
|
||||
|
||||
$first = $prefix[0];
|
||||
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
||||
$this->prefixesPsr0[$first][$prefix] = $paths;
|
||||
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
||||
|
||||
return;
|
||||
}
|
||||
if ($prepend) {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
$paths,
|
||||
(array) $paths,
|
||||
$this->prefixesPsr0[$first][$prefix]
|
||||
);
|
||||
} else {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
$this->prefixesPsr0[$first][$prefix],
|
||||
$paths
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -219,9 +222,9 @@ class ClassLoader
|
||||
* Registers a set of PSR-4 directories for a given namespace, either
|
||||
* appending or prepending to the ones previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param list<string>|string $paths The PSR-4 base directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param string[]|string $paths The PSR-4 base directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
@@ -229,18 +232,17 @@ class ClassLoader
|
||||
*/
|
||||
public function addPsr4($prefix, $paths, $prepend = false)
|
||||
{
|
||||
$paths = (array) $paths;
|
||||
if (!$prefix) {
|
||||
// Register directories for the root namespace.
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
$paths,
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr4
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
$this->fallbackDirsPsr4,
|
||||
$paths
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||
@@ -250,18 +252,18 @@ class ClassLoader
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = $paths;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
} elseif ($prepend) {
|
||||
// Prepend directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
$paths,
|
||||
(array) $paths,
|
||||
$this->prefixDirsPsr4[$prefix]
|
||||
);
|
||||
} else {
|
||||
// Append directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
$this->prefixDirsPsr4[$prefix],
|
||||
$paths
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -270,8 +272,8 @@ class ClassLoader
|
||||
* Registers a set of PSR-0 directories for a given prefix,
|
||||
* replacing any others previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param list<string>|string $paths The PSR-0 base directories
|
||||
* @param string $prefix The prefix
|
||||
* @param string[]|string $paths The PSR-0 base directories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -288,8 +290,8 @@ class ClassLoader
|
||||
* Registers a set of PSR-4 directories for a given namespace,
|
||||
* replacing any others previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param list<string>|string $paths The PSR-4 base directories
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param string[]|string $paths The PSR-4 base directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
@@ -423,8 +425,7 @@ class ClassLoader
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
$includeFile = self::$includeFile;
|
||||
$includeFile($file);
|
||||
includeFile($file);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -475,9 +476,9 @@ class ClassLoader
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently registered loaders keyed by their corresponding vendor directories.
|
||||
* Returns the currently registered loaders indexed by their corresponding vendor directories.
|
||||
*
|
||||
* @return array<string, self>
|
||||
* @return self[]
|
||||
*/
|
||||
public static function getRegisteredLoaders()
|
||||
{
|
||||
@@ -554,26 +555,18 @@ class ClassLoader
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
private static function initializeIncludeClosure()
|
||||
{
|
||||
if (self::$includeFile !== null) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope isolated include.
|
||||
*
|
||||
* Prevents access to $this/self from included files.
|
||||
*
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
self::$includeFile = \Closure::bind(static function($file) {
|
||||
include $file;
|
||||
}, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope isolated include.
|
||||
*
|
||||
* Prevents access to $this/self from included files.
|
||||
*
|
||||
* @param string $file
|
||||
* @return void
|
||||
* @private
|
||||
*/
|
||||
function includeFile($file)
|
||||
{
|
||||
include $file;
|
||||
}
|
||||
|
||||
33
Server/vendor/composer/InstalledVersions.php
vendored
33
Server/vendor/composer/InstalledVersions.php
vendored
@@ -21,14 +21,12 @@ use Composer\Semver\VersionParser;
|
||||
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
|
||||
*
|
||||
* To require its presence, you can require `composer-runtime-api ^2.0`
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class InstalledVersions
|
||||
{
|
||||
/**
|
||||
* @var mixed[]|null
|
||||
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
|
||||
* @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}|array{}|null
|
||||
*/
|
||||
private static $installed;
|
||||
|
||||
@@ -39,7 +37,7 @@ class InstalledVersions
|
||||
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||
* @psalm-var array<string, array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
|
||||
*/
|
||||
private static $installedByVendor = array();
|
||||
|
||||
@@ -98,7 +96,7 @@ class InstalledVersions
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (isset($installed['versions'][$packageName])) {
|
||||
return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
|
||||
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +117,7 @@ class InstalledVersions
|
||||
*/
|
||||
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
||||
{
|
||||
$constraint = $parser->parseConstraints((string) $constraint);
|
||||
$constraint = $parser->parseConstraints($constraint);
|
||||
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
||||
|
||||
return $provided->matches($constraint);
|
||||
@@ -243,7 +241,7 @@ class InstalledVersions
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
|
||||
* @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}
|
||||
*/
|
||||
public static function getRootPackage()
|
||||
{
|
||||
@@ -257,7 +255,7 @@ class InstalledVersions
|
||||
*
|
||||
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
|
||||
* @return array[]
|
||||
* @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
|
||||
* @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}
|
||||
*/
|
||||
public static function getRawData()
|
||||
{
|
||||
@@ -280,7 +278,7 @@ class InstalledVersions
|
||||
* Returns the raw data of all installed.php which are currently loaded for custom implementations
|
||||
*
|
||||
* @return array[]
|
||||
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
|
||||
*/
|
||||
public static function getAllRawData()
|
||||
{
|
||||
@@ -303,7 +301,7 @@ class InstalledVersions
|
||||
* @param array[] $data A vendor/composer/installed.php data set
|
||||
* @return void
|
||||
*
|
||||
* @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
|
||||
* @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data
|
||||
*/
|
||||
public static function reload($data)
|
||||
{
|
||||
@@ -313,7 +311,7 @@ class InstalledVersions
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
|
||||
*/
|
||||
private static function getInstalled()
|
||||
{
|
||||
@@ -328,9 +326,7 @@ class InstalledVersions
|
||||
if (isset(self::$installedByVendor[$vendorDir])) {
|
||||
$installed[] = self::$installedByVendor[$vendorDir];
|
||||
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
||||
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
||||
$required = require $vendorDir.'/composer/installed.php';
|
||||
$installed[] = self::$installedByVendor[$vendorDir] = $required;
|
||||
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
|
||||
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
||||
self::$installed = $installed[count($installed) - 1];
|
||||
}
|
||||
@@ -342,17 +338,12 @@ class InstalledVersions
|
||||
// only require the installed.php file if this file is loaded from its dumped location,
|
||||
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
||||
$required = require __DIR__ . '/installed.php';
|
||||
self::$installed = $required;
|
||||
self::$installed = require __DIR__ . '/installed.php';
|
||||
} else {
|
||||
self::$installed = array();
|
||||
}
|
||||
}
|
||||
|
||||
if (self::$installed !== array()) {
|
||||
$installed[] = self::$installed;
|
||||
}
|
||||
$installed[] = self::$installed;
|
||||
|
||||
return $installed;
|
||||
}
|
||||
|
||||
4
Server/vendor/composer/autoload_classmap.php
vendored
4
Server/vendor/composer/autoload_classmap.php
vendored
@@ -2,13 +2,13 @@
|
||||
|
||||
// autoload_classmap.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
||||
'Normalizer' => $vendorDir . '/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php',
|
||||
'QrReader' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/QrReader.php',
|
||||
'Stringable' => $vendorDir . '/myclabs/php-enum/stubs/Stringable.php',
|
||||
'Zxing\\Binarizer' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/Binarizer.php',
|
||||
'Zxing\\BinaryBitmap' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/BinaryBitmap.php',
|
||||
'Zxing\\ChecksumException' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/ChecksumException.php',
|
||||
|
||||
10
Server/vendor/composer/autoload_files.php
vendored
10
Server/vendor/composer/autoload_files.php
vendored
@@ -2,17 +2,19 @@
|
||||
|
||||
// autoload_files.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
|
||||
'6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php',
|
||||
'e69f7f6ee287b969198c3c9d6777bd38' => $vendorDir . '/symfony/polyfill-intl-normalizer/bootstrap.php',
|
||||
'25072dd6e2470089de65ae7bf11d3109' => $vendorDir . '/symfony/polyfill-php72/bootstrap.php',
|
||||
'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
|
||||
'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
|
||||
'f598d06aa772fa33d905e87be6398fb1' => $vendorDir . '/symfony/polyfill-intl-idn/bootstrap.php',
|
||||
'd767e4fc2dc52fe66584ab8c6684783e' => $vendorDir . '/adbario/php-dot-notation/src/helpers.php',
|
||||
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
|
||||
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
|
||||
'626dcc41390ebdaa619faa02d99943b0' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/common/customFunctions.php',
|
||||
'9b552a3cc426e3287cc811caefa3cf53' => $vendorDir . '/topthink/think-helper/src/helper.php',
|
||||
'cc56288302d9df745d97c934d6a6e5f0' => $vendorDir . '/topthink/think-queue/src/common.php',
|
||||
'ffc1d7141d4fcbaeb47a6929f0811ed1' => $vendorDir . '/topthink/think-worker/src/command.php',
|
||||
);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_namespaces.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
|
||||
11
Server/vendor/composer/autoload_psr4.php
vendored
11
Server/vendor/composer/autoload_psr4.php
vendored
@@ -2,22 +2,21 @@
|
||||
|
||||
// autoload_psr4.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'think\\worker\\' => array($vendorDir . '/topthink/think-worker/src'),
|
||||
'think\\composer\\' => array($vendorDir . '/topthink/think-installer/src'),
|
||||
'think\\' => array($vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-queue/src'),
|
||||
'app\\' => array($baseDir . '/application'),
|
||||
'Workerman\\' => array($vendorDir . '/workerman/workerman'),
|
||||
'WebSocket\\' => array($vendorDir . '/textalk/websocket/lib'),
|
||||
'Symfony\\Polyfill\\Php72\\' => array($vendorDir . '/symfony/polyfill-php72'),
|
||||
'Symfony\\Polyfill\\Intl\\Normalizer\\' => array($vendorDir . '/symfony/polyfill-intl-normalizer'),
|
||||
'Symfony\\Polyfill\\Intl\\Idn\\' => array($vendorDir . '/symfony/polyfill-intl-idn'),
|
||||
'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
|
||||
'Symfony\\Component\\PropertyAccess\\' => array($vendorDir . '/symfony/property-access'),
|
||||
'Symfony\\Component\\OptionsResolver\\' => array($vendorDir . '/symfony/options-resolver'),
|
||||
'Psr\\Log\\' => array($vendorDir . '/psr/log/src'),
|
||||
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-factory/src', $vendorDir . '/psr/http-message/src'),
|
||||
'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'),
|
||||
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'),
|
||||
'OneSm\\' => array($vendorDir . '/lizhichao/one-sm/src'),
|
||||
'OSS\\' => array($vendorDir . '/aliyuncs/oss-sdk-php/src/OSS'),
|
||||
'MyCLabs\\Enum\\' => array($vendorDir . '/myclabs/php-enum/src'),
|
||||
|
||||
58
Server/vendor/composer/autoload_real.php
vendored
58
Server/vendor/composer/autoload_real.php
vendored
@@ -22,27 +22,59 @@ class ComposerAutoloaderInit075712db3cd06cc0fc14f5ab72673de0
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
require __DIR__ . '/platform_check.php';
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit075712db3cd06cc0fc14f5ab72673de0', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit075712db3cd06cc0fc14f5ab72673de0', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit075712db3cd06cc0fc14f5ab72673de0::getInitializer($loader));
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit075712db3cd06cc0fc14f5ab72673de0::getInitializer($loader));
|
||||
} else {
|
||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->set($namespace, $path);
|
||||
}
|
||||
|
||||
$map = require __DIR__ . '/autoload_psr4.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->setPsr4($namespace, $path);
|
||||
}
|
||||
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
$loader->addClassMap($classMap);
|
||||
}
|
||||
}
|
||||
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit075712db3cd06cc0fc14f5ab72673de0::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
||||
require $file;
|
||||
}
|
||||
}, null, null);
|
||||
foreach ($filesToLoad as $fileIdentifier => $file) {
|
||||
$requireFile($fileIdentifier, $file);
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit075712db3cd06cc0fc14f5ab72673de0::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire075712db3cd06cc0fc14f5ab72673de0($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fileIdentifier
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequire075712db3cd06cc0fc14f5ab72673de0($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
||||
require $file;
|
||||
}
|
||||
}
|
||||
|
||||
45
Server/vendor/composer/autoload_static.php
vendored
45
Server/vendor/composer/autoload_static.php
vendored
@@ -8,13 +8,15 @@ class ComposerStaticInit075712db3cd06cc0fc14f5ab72673de0
|
||||
{
|
||||
public static $files = array (
|
||||
'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
|
||||
'6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php',
|
||||
'e69f7f6ee287b969198c3c9d6777bd38' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/bootstrap.php',
|
||||
'25072dd6e2470089de65ae7bf11d3109' => __DIR__ . '/..' . '/symfony/polyfill-php72/bootstrap.php',
|
||||
'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
|
||||
'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
|
||||
'f598d06aa772fa33d905e87be6398fb1' => __DIR__ . '/..' . '/symfony/polyfill-intl-idn/bootstrap.php',
|
||||
'd767e4fc2dc52fe66584ab8c6684783e' => __DIR__ . '/..' . '/adbario/php-dot-notation/src/helpers.php',
|
||||
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
|
||||
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
|
||||
'626dcc41390ebdaa619faa02d99943b0' => __DIR__ . '/..' . '/khanamiryan/qrcode-detector-decoder/lib/common/customFunctions.php',
|
||||
'9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php',
|
||||
'cc56288302d9df745d97c934d6a6e5f0' => __DIR__ . '/..' . '/topthink/think-queue/src/common.php',
|
||||
'ffc1d7141d4fcbaeb47a6929f0811ed1' => __DIR__ . '/..' . '/topthink/think-worker/src/command.php',
|
||||
);
|
||||
|
||||
@@ -23,7 +25,6 @@ class ComposerStaticInit075712db3cd06cc0fc14f5ab72673de0
|
||||
array (
|
||||
'think\\worker\\' => 13,
|
||||
'think\\composer\\' => 15,
|
||||
'think\\' => 6,
|
||||
),
|
||||
'a' =>
|
||||
array (
|
||||
@@ -32,19 +33,19 @@ class ComposerStaticInit075712db3cd06cc0fc14f5ab72673de0
|
||||
'W' =>
|
||||
array (
|
||||
'Workerman\\' => 10,
|
||||
'WebSocket\\' => 10,
|
||||
),
|
||||
'S' =>
|
||||
array (
|
||||
'Symfony\\Polyfill\\Php72\\' => 23,
|
||||
'Symfony\\Polyfill\\Intl\\Normalizer\\' => 33,
|
||||
'Symfony\\Polyfill\\Intl\\Idn\\' => 26,
|
||||
'Symfony\\Polyfill\\Ctype\\' => 23,
|
||||
'Symfony\\Component\\PropertyAccess\\' => 33,
|
||||
'Symfony\\Component\\OptionsResolver\\' => 34,
|
||||
),
|
||||
'P' =>
|
||||
array (
|
||||
'Psr\\Log\\' => 8,
|
||||
'Psr\\Http\\Message\\' => 17,
|
||||
'Psr\\Http\\Client\\' => 16,
|
||||
),
|
||||
'O' =>
|
||||
array (
|
||||
@@ -97,11 +98,6 @@ class ComposerStaticInit075712db3cd06cc0fc14f5ab72673de0
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/topthink/think-installer/src',
|
||||
),
|
||||
'think\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/topthink/think-helper/src',
|
||||
1 => __DIR__ . '/..' . '/topthink/think-queue/src',
|
||||
),
|
||||
'app\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/../..' . '/application',
|
||||
@@ -110,9 +106,17 @@ class ComposerStaticInit075712db3cd06cc0fc14f5ab72673de0
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/workerman/workerman',
|
||||
),
|
||||
'WebSocket\\' =>
|
||||
'Symfony\\Polyfill\\Php72\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/textalk/websocket/lib',
|
||||
0 => __DIR__ . '/..' . '/symfony/polyfill-php72',
|
||||
),
|
||||
'Symfony\\Polyfill\\Intl\\Normalizer\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer',
|
||||
),
|
||||
'Symfony\\Polyfill\\Intl\\Idn\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/polyfill-intl-idn',
|
||||
),
|
||||
'Symfony\\Polyfill\\Ctype\\' =>
|
||||
array (
|
||||
@@ -126,18 +130,9 @@ class ComposerStaticInit075712db3cd06cc0fc14f5ab72673de0
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/options-resolver',
|
||||
),
|
||||
'Psr\\Log\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/psr/log/src',
|
||||
),
|
||||
'Psr\\Http\\Message\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/psr/http-factory/src',
|
||||
1 => __DIR__ . '/..' . '/psr/http-message/src',
|
||||
),
|
||||
'Psr\\Http\\Client\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/psr/http-client/src',
|
||||
0 => __DIR__ . '/..' . '/psr/http-message/src',
|
||||
),
|
||||
'OneSm\\' =>
|
||||
array (
|
||||
@@ -236,8 +231,8 @@ class ComposerStaticInit075712db3cd06cc0fc14f5ab72673de0
|
||||
|
||||
public static $classMap = array (
|
||||
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
||||
'Normalizer' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php',
|
||||
'QrReader' => __DIR__ . '/..' . '/khanamiryan/qrcode-detector-decoder/lib/QrReader.php',
|
||||
'Stringable' => __DIR__ . '/..' . '/myclabs/php-enum/stubs/Stringable.php',
|
||||
'Zxing\\Binarizer' => __DIR__ . '/..' . '/khanamiryan/qrcode-detector-decoder/lib/Binarizer.php',
|
||||
'Zxing\\BinaryBitmap' => __DIR__ . '/..' . '/khanamiryan/qrcode-detector-decoder/lib/BinaryBitmap.php',
|
||||
'Zxing\\ChecksumException' => __DIR__ . '/..' . '/khanamiryan/qrcode-detector-decoder/lib/ChecksumException.php',
|
||||
|
||||
1024
Server/vendor/composer/installed.json
vendored
1024
Server/vendor/composer/installed.json
vendored
File diff suppressed because it is too large
Load Diff
238
Server/vendor/composer/installed.php
vendored
238
Server/vendor/composer/installed.php
vendored
@@ -1,241 +1,211 @@
|
||||
<?php return array(
|
||||
'root' => array(
|
||||
'name' => 'topthink/think',
|
||||
'pretty_version' => 'dev-develop',
|
||||
'version' => 'dev-develop',
|
||||
'reference' => 'f0fa19f89f042e746b487a6d79e7019b657db2ce',
|
||||
'pretty_version' => 'dev-main',
|
||||
'version' => 'dev-main',
|
||||
'type' => 'project',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'reference' => '42fe117535dd5ae2252b9cff30494eb21369cdd3',
|
||||
'name' => 'topthink/think',
|
||||
'dev' => true,
|
||||
),
|
||||
'versions' => array(
|
||||
'adbario/php-dot-notation' => array(
|
||||
'pretty_version' => '2.5.0',
|
||||
'version' => '2.5.0.0',
|
||||
'reference' => '081e2cca50c84bfeeea2e3ef9b2c8d206d80ccae',
|
||||
'pretty_version' => '2.3.0',
|
||||
'version' => '2.3.0.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../adbario/php-dot-notation',
|
||||
'aliases' => array(),
|
||||
'reference' => '39ece8d385ce2f5e03718c693932d83ab0cb5972',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'alibabacloud/credentials' => array(
|
||||
'pretty_version' => '1.2.1',
|
||||
'version' => '1.2.1.0',
|
||||
'reference' => 'cd0f65127d010ce3be5ced13fa9b69218dcfc555',
|
||||
'pretty_version' => '1.1.4',
|
||||
'version' => '1.1.4.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../alibabacloud/credentials',
|
||||
'aliases' => array(),
|
||||
'reference' => 'e79d4151ad8924c0cf79d4fe0ec151b8d7663a25',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'alibabacloud/darabonba-openapi' => array(
|
||||
'pretty_version' => '0.2.13',
|
||||
'version' => '0.2.13.0',
|
||||
'reference' => '0213396384e2c064eefd614f3dd53636a63f987f',
|
||||
'pretty_version' => '0.2.6',
|
||||
'version' => '0.2.6.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../alibabacloud/darabonba-openapi',
|
||||
'aliases' => array(),
|
||||
'reference' => 'c64a2bafde3aaf8d11ba5aebfc08f59916b4c742',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'alibabacloud/dysmsapi-20170525' => array(
|
||||
'pretty_version' => '2.0.16',
|
||||
'version' => '2.0.16.0',
|
||||
'reference' => '43c4ba11cbc0fec26a373ce2c8f3572cfcad32b5',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../alibabacloud/dysmsapi-20170525',
|
||||
'aliases' => array(),
|
||||
'reference' => '43c4ba11cbc0fec26a373ce2c8f3572cfcad32b5',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'alibabacloud/endpoint-util' => array(
|
||||
'pretty_version' => '0.1.1',
|
||||
'version' => '0.1.1.0',
|
||||
'reference' => 'f3fe88a25d8df4faa3b0ae14ff202a9cc094e6c5',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../alibabacloud/endpoint-util',
|
||||
'aliases' => array(),
|
||||
'reference' => 'f3fe88a25d8df4faa3b0ae14ff202a9cc094e6c5',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'alibabacloud/gateway-spi' => array(
|
||||
'pretty_version' => '1.0.0',
|
||||
'version' => '1.0.0.0',
|
||||
'reference' => '7440f77750c329d8ab252db1d1d967314ccd1fcb',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../alibabacloud/gateway-spi',
|
||||
'aliases' => array(),
|
||||
'reference' => '7440f77750c329d8ab252db1d1d967314ccd1fcb',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'alibabacloud/openapi-util' => array(
|
||||
'pretty_version' => '0.1.13',
|
||||
'version' => '0.1.13.0',
|
||||
'reference' => '870e59984f05e104aa303c85b8214e339ba0a0ac',
|
||||
'pretty_version' => '0.1.11',
|
||||
'version' => '0.1.11.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../alibabacloud/openapi-util',
|
||||
'aliases' => array(),
|
||||
'reference' => '61ee137955a25c9f5f33170babb6071d4bccf12c',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'alibabacloud/tea' => array(
|
||||
'pretty_version' => '3.2.1',
|
||||
'version' => '3.2.1.0',
|
||||
'reference' => '1619cb96c158384f72b873e1f85de8b299c9c367',
|
||||
'pretty_version' => '3.1.24',
|
||||
'version' => '3.1.24.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../alibabacloud/tea',
|
||||
'aliases' => array(),
|
||||
'reference' => 'bb33395f47db3847d1940d6eb8ba1e56cd0623cb',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'alibabacloud/tea-utils' => array(
|
||||
'pretty_version' => '0.2.21',
|
||||
'version' => '0.2.21.0',
|
||||
'reference' => '5039e45714c6456186d267f5d81a4b260a652495',
|
||||
'pretty_version' => '0.2.16',
|
||||
'version' => '0.2.16.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../alibabacloud/tea-utils',
|
||||
'aliases' => array(),
|
||||
'reference' => 'ae10b306509a196e4af71803db710a0a05c54e60',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'alibabacloud/tea-xml' => array(
|
||||
'pretty_version' => '0.2.4',
|
||||
'version' => '0.2.4.0',
|
||||
'reference' => '3e0c000bf536224eebbac913c371bef174c0a16a',
|
||||
'pretty_version' => '0.2.3',
|
||||
'version' => '0.2.3.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../alibabacloud/tea-xml',
|
||||
'aliases' => array(),
|
||||
'reference' => '4bd2303d71c968cb7ae4e487c5fa3023aed3ff3b',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'aliyuncs/oss-sdk-php' => array(
|
||||
'pretty_version' => 'v2.7.2',
|
||||
'version' => '2.7.2.0',
|
||||
'reference' => '483dd0b8bff5d47f0e4ffc99f6077a295c5ccbb5',
|
||||
'pretty_version' => 'v2.7.1',
|
||||
'version' => '2.7.1.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../aliyuncs/oss-sdk-php',
|
||||
'aliases' => array(),
|
||||
'reference' => 'ce5d34dae9868237a32248788ea175c7e9da14b1',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'bacon/bacon-qr-code' => array(
|
||||
'pretty_version' => '1.0.3',
|
||||
'version' => '1.0.3.0',
|
||||
'reference' => '5a91b62b9d37cee635bbf8d553f4546057250bee',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../bacon/bacon-qr-code',
|
||||
'aliases' => array(),
|
||||
'reference' => '5a91b62b9d37cee635bbf8d553f4546057250bee',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'endroid/qr-code' => array(
|
||||
'pretty_version' => '2.5.1',
|
||||
'version' => '2.5.1.0',
|
||||
'reference' => '6062677d3404e0ded40647b8f62ec55ff9722eb7',
|
||||
'type' => 'symfony-bundle',
|
||||
'install_path' => __DIR__ . '/../endroid/qr-code',
|
||||
'aliases' => array(),
|
||||
'reference' => '6062677d3404e0ded40647b8f62ec55ff9722eb7',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'guzzlehttp/guzzle' => array(
|
||||
'pretty_version' => '7.9.2',
|
||||
'version' => '7.9.2.0',
|
||||
'reference' => 'd281ed313b989f213357e3be1a179f02196ac99b',
|
||||
'pretty_version' => '6.5.8',
|
||||
'version' => '6.5.8.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../guzzlehttp/guzzle',
|
||||
'aliases' => array(),
|
||||
'reference' => 'a52f0440530b54fa079ce76e8c5d196a42cad981',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'guzzlehttp/promises' => array(
|
||||
'pretty_version' => '2.0.3',
|
||||
'version' => '2.0.3.0',
|
||||
'reference' => '6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8',
|
||||
'pretty_version' => '1.5.1',
|
||||
'version' => '1.5.1.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../guzzlehttp/promises',
|
||||
'aliases' => array(),
|
||||
'reference' => 'fe752aedc9fd8fcca3fe7ad05d419d32998a06da',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'guzzlehttp/psr7' => array(
|
||||
'pretty_version' => '2.7.0',
|
||||
'version' => '2.7.0.0',
|
||||
'reference' => 'a70f5c95fb43bc83f07c9c948baa0dc1829bf201',
|
||||
'pretty_version' => '1.9.0',
|
||||
'version' => '1.9.0.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../guzzlehttp/psr7',
|
||||
'aliases' => array(),
|
||||
'reference' => 'e98e3e6d4f86621a9b75f623996e6bbdeb4b9318',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'hashids/hashids' => array(
|
||||
'pretty_version' => '3.0.0',
|
||||
'version' => '3.0.0.0',
|
||||
'reference' => 'b6c61142bfe36d43740a5419d11c351dddac0458',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../hashids/hashids',
|
||||
'aliases' => array(),
|
||||
'reference' => 'b6c61142bfe36d43740a5419d11c351dddac0458',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'khanamiryan/qrcode-detector-decoder' => array(
|
||||
'pretty_version' => '1',
|
||||
'version' => '1.0.0.0',
|
||||
'reference' => '96d5f80680b04803c4f1b69d6e01735e876b80c7',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../khanamiryan/qrcode-detector-decoder',
|
||||
'aliases' => array(),
|
||||
'reference' => '96d5f80680b04803c4f1b69d6e01735e876b80c7',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'lizhichao/one-sm' => array(
|
||||
'pretty_version' => '1.10',
|
||||
'version' => '1.10.0.0',
|
||||
'reference' => '687a012a44a5bfd4d9143a0234e1060543be455a',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../lizhichao/one-sm',
|
||||
'aliases' => array(),
|
||||
'reference' => '687a012a44a5bfd4d9143a0234e1060543be455a',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'myclabs/php-enum' => array(
|
||||
'pretty_version' => '1.8.4',
|
||||
'version' => '1.8.4.0',
|
||||
'reference' => 'a867478eae49c9f59ece437ae7f9506bfaa27483',
|
||||
'pretty_version' => '1.7.7',
|
||||
'version' => '1.7.7.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../myclabs/php-enum',
|
||||
'aliases' => array(),
|
||||
'reference' => 'd178027d1e679832db9f38248fcc7200647dc2b7',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'phpoffice/phpexcel' => array(
|
||||
'pretty_version' => '1.8.2',
|
||||
'version' => '1.8.2.0',
|
||||
'reference' => '1441011fb7ecdd8cc689878f54f8b58a6805f870',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../phpoffice/phpexcel',
|
||||
'aliases' => array(),
|
||||
'reference' => '1441011fb7ecdd8cc689878f54f8b58a6805f870',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'psr/http-client' => array(
|
||||
'pretty_version' => '1.0.3',
|
||||
'version' => '1.0.3.0',
|
||||
'reference' => 'bb5906edc1c324c9a05aa0873d40117941e5fa90',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../psr/http-client',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'psr/http-client-implementation' => array(
|
||||
'dev_requirement' => false,
|
||||
'provided' => array(
|
||||
0 => '1.0',
|
||||
),
|
||||
),
|
||||
'psr/http-factory' => array(
|
||||
'pretty_version' => '1.0.2',
|
||||
'version' => '1.0.2.0',
|
||||
'reference' => 'e616d01114759c4c489f93b099585439f795fe35',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../psr/http-factory',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'psr/http-factory-implementation' => array(
|
||||
'dev_requirement' => false,
|
||||
'provided' => array(
|
||||
0 => '1.0',
|
||||
),
|
||||
),
|
||||
'psr/http-message' => array(
|
||||
'pretty_version' => '2.0',
|
||||
'version' => '2.0.0.0',
|
||||
'reference' => '402d35bcb92c70c026d1a6a9883f06b2ead23d71',
|
||||
'pretty_version' => '1.0.1',
|
||||
'version' => '1.0.1.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../psr/http-message',
|
||||
'aliases' => array(),
|
||||
'reference' => 'f6561bf28d520154e4b0ec72be95418abe6d9363',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'psr/http-message-implementation' => array(
|
||||
@@ -244,139 +214,121 @@
|
||||
0 => '1.0',
|
||||
),
|
||||
),
|
||||
'psr/log' => array(
|
||||
'pretty_version' => '3.0.1',
|
||||
'version' => '3.0.1.0',
|
||||
'reference' => '79dff0b268932c640297f5208d6298f71855c03e',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../psr/log',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'ralouphie/getallheaders' => array(
|
||||
'pretty_version' => '3.0.3',
|
||||
'version' => '3.0.3.0',
|
||||
'reference' => '120b605dfeb996808c31b6477290a714d356e822',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../ralouphie/getallheaders',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'symfony/deprecation-contracts' => array(
|
||||
'pretty_version' => 'v3.5.1',
|
||||
'version' => '3.5.1.0',
|
||||
'reference' => '74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../symfony/deprecation-contracts',
|
||||
'aliases' => array(),
|
||||
'reference' => '120b605dfeb996808c31b6477290a714d356e822',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'symfony/options-resolver' => array(
|
||||
'pretty_version' => 'v2.8.52',
|
||||
'version' => '2.8.52.0',
|
||||
'reference' => '7aaab725bb58f0e18aa12c61bdadd4793ab4c32b',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../symfony/options-resolver',
|
||||
'aliases' => array(),
|
||||
'reference' => '7aaab725bb58f0e18aa12c61bdadd4793ab4c32b',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'symfony/polyfill-ctype' => array(
|
||||
'pretty_version' => 'v1.31.0',
|
||||
'version' => '1.31.0.0',
|
||||
'reference' => 'a3cc8b044a6ea513310cbd48ef7333b384945638',
|
||||
'pretty_version' => 'v1.26.0',
|
||||
'version' => '1.26.0.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../symfony/polyfill-ctype',
|
||||
'aliases' => array(),
|
||||
'reference' => '6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'symfony/polyfill-intl-idn' => array(
|
||||
'pretty_version' => 'v1.26.0',
|
||||
'version' => '1.26.0.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../symfony/polyfill-intl-idn',
|
||||
'aliases' => array(),
|
||||
'reference' => '59a8d271f00dd0e4c2e518104cc7963f655a1aa8',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'symfony/polyfill-intl-normalizer' => array(
|
||||
'pretty_version' => 'v1.26.0',
|
||||
'version' => '1.26.0.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../symfony/polyfill-intl-normalizer',
|
||||
'aliases' => array(),
|
||||
'reference' => '219aa369ceff116e673852dce47c3a41794c14bd',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'symfony/polyfill-php72' => array(
|
||||
'pretty_version' => 'v1.26.0',
|
||||
'version' => '1.26.0.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../symfony/polyfill-php72',
|
||||
'aliases' => array(),
|
||||
'reference' => 'bf44a9fd41feaac72b074de600314a93e2ae78e2',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'symfony/property-access' => array(
|
||||
'pretty_version' => 'v2.8.52',
|
||||
'version' => '2.8.52.0',
|
||||
'reference' => 'c8f10191183be9bb0d5a1b8364d3891f1bde07b6',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../symfony/property-access',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'textalk/websocket' => array(
|
||||
'pretty_version' => '1.5.8',
|
||||
'version' => '1.5.8.0',
|
||||
'reference' => 'd05dbaa97500176447ffb1f1800573f23085ab13',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../textalk/websocket',
|
||||
'aliases' => array(),
|
||||
'reference' => 'c8f10191183be9bb0d5a1b8364d3891f1bde07b6',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'topthink/framework' => array(
|
||||
'pretty_version' => 'v5.1.42',
|
||||
'version' => '5.1.42.0',
|
||||
'reference' => 'ecf1a90d397d821ce2df58f7d47e798c17eba3ad',
|
||||
'pretty_version' => 'v5.1.41',
|
||||
'version' => '5.1.41.0',
|
||||
'type' => 'think-framework',
|
||||
'install_path' => __DIR__ . '/../../thinkphp',
|
||||
'aliases' => array(),
|
||||
'reference' => '7137741a323a4a60cfca334507cd1812fac91bb2',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'topthink/think' => array(
|
||||
'pretty_version' => 'dev-develop',
|
||||
'version' => 'dev-develop',
|
||||
'reference' => 'f0fa19f89f042e746b487a6d79e7019b657db2ce',
|
||||
'pretty_version' => 'dev-main',
|
||||
'version' => 'dev-main',
|
||||
'type' => 'project',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'topthink/think-helper' => array(
|
||||
'pretty_version' => 'v3.1.10',
|
||||
'version' => '3.1.10.0',
|
||||
'reference' => 'ac66cc0859a12cd5d73258f50f338aadc95e9b46',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../topthink/think-helper',
|
||||
'aliases' => array(),
|
||||
'reference' => '42fe117535dd5ae2252b9cff30494eb21369cdd3',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'topthink/think-installer' => array(
|
||||
'pretty_version' => 'v2.0.5',
|
||||
'version' => '2.0.5.0',
|
||||
'reference' => '38ba647706e35d6704b5d370c06f8a160b635f88',
|
||||
'type' => 'composer-plugin',
|
||||
'install_path' => __DIR__ . '/../topthink/think-installer',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'topthink/think-queue' => array(
|
||||
'pretty_version' => 'v2.0.4',
|
||||
'version' => '2.0.4.0',
|
||||
'reference' => 'd9b8f38c7af8ad770257b0d7db711ce8b12a6969',
|
||||
'type' => 'think-extend',
|
||||
'install_path' => __DIR__ . '/../topthink/think-queue',
|
||||
'aliases' => array(),
|
||||
'reference' => '38ba647706e35d6704b5d370c06f8a160b635f88',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'topthink/think-worker' => array(
|
||||
'pretty_version' => 'v2.0.12',
|
||||
'version' => '2.0.12.0',
|
||||
'reference' => '922d8c95e2f095e0da66d18b9e3fbbfd8de70a3f',
|
||||
'type' => 'think-extend',
|
||||
'install_path' => __DIR__ . '/../topthink/think-worker',
|
||||
'aliases' => array(),
|
||||
'reference' => '922d8c95e2f095e0da66d18b9e3fbbfd8de70a3f',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'workerman/gateway-worker' => array(
|
||||
'pretty_version' => 'v3.0.22',
|
||||
'version' => '3.0.22.0',
|
||||
'reference' => 'a615036c482d11f68b693998575e804752ef9068',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../workerman/gateway-worker',
|
||||
'aliases' => array(),
|
||||
'reference' => 'a615036c482d11f68b693998575e804752ef9068',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'workerman/workerman' => array(
|
||||
'pretty_version' => 'v3.5.35',
|
||||
'version' => '3.5.35.0',
|
||||
'reference' => '3cc0adae51ba36db38b11e7996c64250d356dbe7',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../workerman/workerman',
|
||||
'aliases' => array(),
|
||||
'reference' => '3cc0adae51ba36db38b11e7996c64250d356dbe7',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
),
|
||||
|
||||
26
Server/vendor/composer/platform_check.php
vendored
Normal file
26
Server/vendor/composer/platform_check.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
// platform_check.php @generated by Composer
|
||||
|
||||
$issues = array();
|
||||
|
||||
if (!(PHP_VERSION_ID >= 70103)) {
|
||||
$issues[] = 'Your Composer dependencies require a PHP version ">= 7.1.3". You are running ' . PHP_VERSION . '.';
|
||||
}
|
||||
|
||||
if ($issues) {
|
||||
if (!headers_sent()) {
|
||||
header('HTTP/1.1 500 Internal Server Error');
|
||||
}
|
||||
if (!ini_get('display_errors')) {
|
||||
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
||||
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
|
||||
} elseif (!headers_sent()) {
|
||||
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
|
||||
}
|
||||
}
|
||||
trigger_error(
|
||||
'Composer detected issues in your platform: ' . implode(' ', $issues),
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
23
Server/vendor/guzzlehttp/guzzle/.php_cs
vendored
Normal file
23
Server/vendor/guzzlehttp/guzzle/.php_cs
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
$config = PhpCsFixer\Config::create()
|
||||
->setRiskyAllowed(true)
|
||||
->setRules([
|
||||
'@PSR2' => true,
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'declare_strict_types' => false,
|
||||
'concat_space' => ['spacing'=>'one'],
|
||||
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
|
||||
'ordered_imports' => true,
|
||||
// 'phpdoc_align' => ['align'=>'vertical'],
|
||||
// 'native_function_invocation' => true,
|
||||
])
|
||||
->setFinder(
|
||||
PhpCsFixer\Finder::create()
|
||||
->in(__DIR__.'/src')
|
||||
->in(__DIR__.'/tests')
|
||||
->name('*.php')
|
||||
)
|
||||
;
|
||||
|
||||
return $config;
|
||||
352
Server/vendor/guzzlehttp/guzzle/CHANGELOG.md
vendored
352
Server/vendor/guzzlehttp/guzzle/CHANGELOG.md
vendored
@@ -1,353 +1,58 @@
|
||||
# Change Log
|
||||
|
||||
Please refer to [UPGRADING](UPGRADING.md) guide for upgrading to a major version.
|
||||
|
||||
|
||||
## 7.9.2 - 2024-07-24
|
||||
|
||||
### Fixed
|
||||
|
||||
- Adjusted handler selection to use cURL if its version is 7.21.2 or higher, rather than 7.34.0
|
||||
|
||||
|
||||
## 7.9.1 - 2024-07-19
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix TLS 1.3 check for HTTP/2 requests
|
||||
|
||||
|
||||
## 7.9.0 - 2024-07-18
|
||||
|
||||
### Changed
|
||||
|
||||
- Improve protocol version checks to provide feedback around unsupported protocols
|
||||
- Only select the cURL handler by default if 7.34.0 or higher is linked
|
||||
- Improved `CurlMultiHandler` to avoid busy wait if possible
|
||||
- Dropped support for EOL `guzzlehttp/psr7` v1
|
||||
- Improved URI user info redaction in errors
|
||||
|
||||
## 7.8.2 - 2024-07-18
|
||||
|
||||
### Added
|
||||
|
||||
- Support for PHP 8.4
|
||||
|
||||
|
||||
## 7.8.1 - 2023-12-03
|
||||
|
||||
### Changed
|
||||
|
||||
- Updated links in docs to their canonical versions
|
||||
- Replaced `call_user_func*` with native calls
|
||||
|
||||
|
||||
## 7.8.0 - 2023-08-27
|
||||
|
||||
### Added
|
||||
|
||||
- Support for PHP 8.3
|
||||
- Added automatic closing of handles on `CurlFactory` object destruction
|
||||
|
||||
|
||||
## 7.7.1 - 2023-08-27
|
||||
|
||||
### Changed
|
||||
|
||||
- Remove the need for `AllowDynamicProperties` in `CurlMultiHandler`
|
||||
|
||||
|
||||
## 7.7.0 - 2023-05-21
|
||||
|
||||
### Added
|
||||
|
||||
- Support `guzzlehttp/promises` v2
|
||||
|
||||
|
||||
## 7.6.1 - 2023-05-15
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix `SetCookie::fromString` MaxAge deprecation warning and skip invalid MaxAge values
|
||||
|
||||
|
||||
## 7.6.0 - 2023-05-14
|
||||
|
||||
### Added
|
||||
|
||||
- Support for setting the minimum TLS version in a unified way
|
||||
- Apply on request the version set in options parameters
|
||||
|
||||
|
||||
## 7.5.2 - 2023-05-14
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed set cookie constructor validation
|
||||
- Fixed handling of files with `'0'` body
|
||||
|
||||
### Changed
|
||||
|
||||
- Corrected docs and default connect timeout value to 300 seconds
|
||||
|
||||
|
||||
## 7.5.1 - 2023-04-17
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `NO_PROXY` settings so that setting the `proxy` option to `no` overrides the env variable
|
||||
|
||||
### Changed
|
||||
|
||||
- Adjusted `guzzlehttp/psr7` version constraint to `^1.9.1 || ^2.4.5`
|
||||
|
||||
|
||||
## 7.5.0 - 2022-08-28
|
||||
|
||||
### Added
|
||||
|
||||
- Support PHP 8.2
|
||||
- Add request to delay closure params
|
||||
|
||||
|
||||
## 7.4.5 - 2022-06-20
|
||||
|
||||
### Fixed
|
||||
## 6.5.8 - 2022-06-20
|
||||
|
||||
* Fix change in port should be considered a change in origin
|
||||
* Fix `CURLOPT_HTTPAUTH` option not cleared on change of origin
|
||||
|
||||
|
||||
## 7.4.4 - 2022-06-09
|
||||
|
||||
### Fixed
|
||||
## 6.5.7 - 2022-06-09
|
||||
|
||||
* Fix failure to strip Authorization header on HTTP downgrade
|
||||
* Fix failure to strip the Cookie header on change in host or HTTP downgrade
|
||||
|
||||
|
||||
## 7.4.3 - 2022-05-25
|
||||
|
||||
### Fixed
|
||||
## 6.5.6 - 2022-05-25
|
||||
|
||||
* Fix cross-domain cookie leakage
|
||||
|
||||
## 6.5.5 - 2020-06-16
|
||||
|
||||
## 7.4.2 - 2022-03-20
|
||||
* Unpin version constraint for `symfony/polyfill-intl-idn` [#2678](https://github.com/guzzle/guzzle/pull/2678)
|
||||
|
||||
### Fixed
|
||||
## 6.5.4 - 2020-05-25
|
||||
|
||||
- Remove curl auth on cross-domain redirects to align with the Authorization HTTP header
|
||||
- Reject non-HTTP schemes in StreamHandler
|
||||
- Set a default ssl.peer_name context in StreamHandler to allow `force_ip_resolve`
|
||||
* Fix various intl icu issues [#2626](https://github.com/guzzle/guzzle/pull/2626)
|
||||
|
||||
## 6.5.3 - 2020-04-18
|
||||
|
||||
## 7.4.1 - 2021-12-06
|
||||
|
||||
### Changed
|
||||
|
||||
- Replaced implicit URI to string coercion [#2946](https://github.com/guzzle/guzzle/pull/2946)
|
||||
- Allow `symfony/deprecation-contracts` version 3 [#2961](https://github.com/guzzle/guzzle/pull/2961)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Only close curl handle if it's done [#2950](https://github.com/guzzle/guzzle/pull/2950)
|
||||
|
||||
|
||||
## 7.4.0 - 2021-10-18
|
||||
|
||||
### Added
|
||||
|
||||
- Support PHP 8.1 [#2929](https://github.com/guzzle/guzzle/pull/2929), [#2939](https://github.com/guzzle/guzzle/pull/2939)
|
||||
- Support `psr/log` version 2 and 3 [#2943](https://github.com/guzzle/guzzle/pull/2943)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Make sure we always call `restore_error_handler()` [#2915](https://github.com/guzzle/guzzle/pull/2915)
|
||||
- Fix progress parameter type compatibility between the cURL and stream handlers [#2936](https://github.com/guzzle/guzzle/pull/2936)
|
||||
- Throw `InvalidArgumentException` when an incorrect `headers` array is provided [#2916](https://github.com/guzzle/guzzle/pull/2916), [#2942](https://github.com/guzzle/guzzle/pull/2942)
|
||||
|
||||
### Changed
|
||||
|
||||
- Be more strict with types [#2914](https://github.com/guzzle/guzzle/pull/2914), [#2917](https://github.com/guzzle/guzzle/pull/2917), [#2919](https://github.com/guzzle/guzzle/pull/2919), [#2945](https://github.com/guzzle/guzzle/pull/2945)
|
||||
|
||||
|
||||
## 7.3.0 - 2021-03-23
|
||||
|
||||
### Added
|
||||
|
||||
- Support for DER and P12 certificates [#2413](https://github.com/guzzle/guzzle/pull/2413)
|
||||
- Support the cURL (http://) scheme for StreamHandler proxies [#2850](https://github.com/guzzle/guzzle/pull/2850)
|
||||
- Support for `guzzlehttp/psr7:^2.0` [#2878](https://github.com/guzzle/guzzle/pull/2878)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Handle exceptions on invalid header consistently between PHP versions and handlers [#2872](https://github.com/guzzle/guzzle/pull/2872)
|
||||
|
||||
|
||||
## 7.2.0 - 2020-10-10
|
||||
|
||||
### Added
|
||||
|
||||
- Support for PHP 8 [#2712](https://github.com/guzzle/guzzle/pull/2712), [#2715](https://github.com/guzzle/guzzle/pull/2715), [#2789](https://github.com/guzzle/guzzle/pull/2789)
|
||||
- Support passing a body summarizer to the http errors middleware [#2795](https://github.com/guzzle/guzzle/pull/2795)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Handle exceptions during response creation [#2591](https://github.com/guzzle/guzzle/pull/2591)
|
||||
- Fix CURLOPT_ENCODING not to be overwritten [#2595](https://github.com/guzzle/guzzle/pull/2595)
|
||||
- Make sure the Request always has a body object [#2804](https://github.com/guzzle/guzzle/pull/2804)
|
||||
|
||||
### Changed
|
||||
|
||||
- The `TooManyRedirectsException` has a response [#2660](https://github.com/guzzle/guzzle/pull/2660)
|
||||
- Avoid "functions" from dependencies [#2712](https://github.com/guzzle/guzzle/pull/2712)
|
||||
|
||||
### Deprecated
|
||||
|
||||
- Using environment variable GUZZLE_CURL_SELECT_TIMEOUT [#2786](https://github.com/guzzle/guzzle/pull/2786)
|
||||
|
||||
|
||||
## 7.1.1 - 2020-09-30
|
||||
|
||||
### Fixed
|
||||
|
||||
- Incorrect EOF detection for response body streams on Windows.
|
||||
|
||||
### Changed
|
||||
|
||||
- We dont connect curl `sink` on HEAD requests.
|
||||
- Removed some PHP 5 workarounds
|
||||
|
||||
|
||||
## 7.1.0 - 2020-09-22
|
||||
|
||||
### Added
|
||||
|
||||
- `GuzzleHttp\MessageFormatterInterface`
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed issue that caused cookies with no value not to be stored.
|
||||
- On redirects, we allow all safe methods like GET, HEAD and OPTIONS.
|
||||
- Fixed logging on empty responses.
|
||||
- Make sure MessageFormatter::format returns string
|
||||
|
||||
### Deprecated
|
||||
|
||||
- All functions in `GuzzleHttp` has been deprecated. Use static methods on `Utils` instead.
|
||||
- `ClientInterface::getConfig()`
|
||||
- `Client::getConfig()`
|
||||
- `Client::__call()`
|
||||
- `Utils::defaultCaBundle()`
|
||||
- `CurlFactory::LOW_CURL_VERSION_NUMBER`
|
||||
|
||||
|
||||
## 7.0.1 - 2020-06-27
|
||||
|
||||
* Fix multiply defined functions fatal error [#2699](https://github.com/guzzle/guzzle/pull/2699)
|
||||
|
||||
|
||||
## 7.0.0 - 2020-06-27
|
||||
|
||||
No changes since 7.0.0-rc1.
|
||||
|
||||
|
||||
## 7.0.0-rc1 - 2020-06-15
|
||||
|
||||
### Changed
|
||||
|
||||
* Use error level for logging errors in Middleware [#2629](https://github.com/guzzle/guzzle/pull/2629)
|
||||
* Disabled IDN support by default and require ext-intl to use it [#2675](https://github.com/guzzle/guzzle/pull/2675)
|
||||
|
||||
|
||||
## 7.0.0-beta2 - 2020-05-25
|
||||
|
||||
### Added
|
||||
|
||||
* Using `Utils` class instead of functions in the `GuzzleHttp` namespace. [#2546](https://github.com/guzzle/guzzle/pull/2546)
|
||||
* `ClientInterface::MAJOR_VERSION` [#2583](https://github.com/guzzle/guzzle/pull/2583)
|
||||
|
||||
### Changed
|
||||
|
||||
* Avoid the `getenv` function when unsafe [#2531](https://github.com/guzzle/guzzle/pull/2531)
|
||||
* Added real client methods [#2529](https://github.com/guzzle/guzzle/pull/2529)
|
||||
* Avoid functions due to global install conflicts [#2546](https://github.com/guzzle/guzzle/pull/2546)
|
||||
* Use Symfony intl-idn polyfill [#2550](https://github.com/guzzle/guzzle/pull/2550)
|
||||
* Adding methods for HTTP verbs like `Client::get()`, `Client::head()`, `Client::patch()` etc [#2529](https://github.com/guzzle/guzzle/pull/2529)
|
||||
* `ConnectException` extends `TransferException` [#2541](https://github.com/guzzle/guzzle/pull/2541)
|
||||
* Updated the default User Agent to "GuzzleHttp/7" [#2654](https://github.com/guzzle/guzzle/pull/2654)
|
||||
|
||||
### Fixed
|
||||
|
||||
* Various intl icu issues [#2626](https://github.com/guzzle/guzzle/pull/2626)
|
||||
|
||||
### Removed
|
||||
|
||||
* Pool option `pool_size` [#2528](https://github.com/guzzle/guzzle/pull/2528)
|
||||
|
||||
|
||||
## 7.0.0-beta1 - 2019-12-30
|
||||
|
||||
The diff might look very big but 95% of Guzzle users will be able to upgrade without modification.
|
||||
Please see [the upgrade document](UPGRADING.md) that describes all BC breaking changes.
|
||||
|
||||
### Added
|
||||
|
||||
* Implement PSR-18 and dropped PHP 5 support [#2421](https://github.com/guzzle/guzzle/pull/2421) [#2474](https://github.com/guzzle/guzzle/pull/2474)
|
||||
* PHP 7 types [#2442](https://github.com/guzzle/guzzle/pull/2442) [#2449](https://github.com/guzzle/guzzle/pull/2449) [#2466](https://github.com/guzzle/guzzle/pull/2466) [#2497](https://github.com/guzzle/guzzle/pull/2497) [#2499](https://github.com/guzzle/guzzle/pull/2499)
|
||||
* IDN support for redirects [2424](https://github.com/guzzle/guzzle/pull/2424)
|
||||
|
||||
### Changed
|
||||
|
||||
* Dont allow passing null as third argument to `BadResponseException::__construct()` [#2427](https://github.com/guzzle/guzzle/pull/2427)
|
||||
* Use SAPI constant instead of method call [#2450](https://github.com/guzzle/guzzle/pull/2450)
|
||||
* Use native function invocation [#2444](https://github.com/guzzle/guzzle/pull/2444)
|
||||
* Better defaults for PHP installations with old ICU lib [2454](https://github.com/guzzle/guzzle/pull/2454)
|
||||
* Added visibility to all constants [#2462](https://github.com/guzzle/guzzle/pull/2462)
|
||||
* Dont allow passing `null` as URI to `Client::request()` and `Client::requestAsync()` [#2461](https://github.com/guzzle/guzzle/pull/2461)
|
||||
* Widen the exception argument to throwable [#2495](https://github.com/guzzle/guzzle/pull/2495)
|
||||
|
||||
### Fixed
|
||||
|
||||
* Logging when Promise rejected with a string [#2311](https://github.com/guzzle/guzzle/pull/2311)
|
||||
|
||||
### Removed
|
||||
|
||||
* Class `SeekException` [#2162](https://github.com/guzzle/guzzle/pull/2162)
|
||||
* `RequestException::getResponseBodySummary()` [#2425](https://github.com/guzzle/guzzle/pull/2425)
|
||||
* `CookieJar::getCookieValue()` [#2433](https://github.com/guzzle/guzzle/pull/2433)
|
||||
* `uri_template()` and `UriTemplate` [#2440](https://github.com/guzzle/guzzle/pull/2440)
|
||||
* Request options `save_to` and `exceptions` [#2464](https://github.com/guzzle/guzzle/pull/2464)
|
||||
|
||||
* Remove use of internal functions [#2548](https://github.com/guzzle/guzzle/pull/2548)
|
||||
|
||||
## 6.5.2 - 2019-12-23
|
||||
|
||||
* idn_to_ascii() fix for old PHP versions [#2489](https://github.com/guzzle/guzzle/pull/2489)
|
||||
|
||||
|
||||
## 6.5.1 - 2019-12-21
|
||||
|
||||
* Better defaults for PHP installations with old ICU lib [#2454](https://github.com/guzzle/guzzle/pull/2454)
|
||||
* IDN support for redirects [#2424](https://github.com/guzzle/guzzle/pull/2424)
|
||||
|
||||
|
||||
## 6.5.0 - 2019-12-07
|
||||
|
||||
* Improvement: Added support for reset internal queue in MockHandler. [#2143](https://github.com/guzzle/guzzle/pull/2143)
|
||||
* Improvement: Added support to pass arbitrary options to `curl_multi_init`. [#2287](https://github.com/guzzle/guzzle/pull/2287)
|
||||
* Fix: Gracefully handle passing `null` to the `header` option. [#2132](https://github.com/guzzle/guzzle/pull/2132)
|
||||
* Fix: `RetryMiddleware` did not do exponential delay between retires due unit mismatch. [#2132](https://github.com/guzzle/guzzle/pull/2132)
|
||||
* Fix: `RetryMiddleware` did not do exponential delay between retries due unit mismatch. [#2132](https://github.com/guzzle/guzzle/pull/2132)
|
||||
Previously, `RetryMiddleware` would sleep for 1 millisecond, then 2 milliseconds, then 4 milliseconds.
|
||||
**After this change, `RetryMiddleware` will sleep for 1 second, then 2 seconds, then 4 seconds.**
|
||||
`Middleware::retry()` accepts a second callback parameter to override the default timeouts if needed.
|
||||
* Fix: Prevent undefined offset when using array for ssl_key options. [#2348](https://github.com/guzzle/guzzle/pull/2348)
|
||||
* Deprecated `ClientInterface::VERSION`
|
||||
|
||||
|
||||
## 6.4.1 - 2019-10-23
|
||||
|
||||
* No `guzzle.phar` was created in 6.4.0 due expired API token. This release will fix that
|
||||
* No `guzzle.phar` was created in 6.4.0 due expired API token. This release will fix that
|
||||
* Added `parent::__construct()` to `FileCookieJar` and `SessionCookieJar`
|
||||
|
||||
|
||||
## 6.4.0 - 2019-10-23
|
||||
|
||||
* Improvement: Improved error messages when using curl < 7.21.2 [#2108](https://github.com/guzzle/guzzle/pull/2108)
|
||||
@@ -360,7 +65,6 @@ Please see [the upgrade document](UPGRADING.md) that describes all BC breaking c
|
||||
* Fix: Prevent concurrent writes to file when saving `CookieJar` [#2335](https://github.com/guzzle/guzzle/pull/2335)
|
||||
* Improvement: Update `MockHandler` so we can test transfer time [#2362](https://github.com/guzzle/guzzle/pull/2362)
|
||||
|
||||
|
||||
## 6.3.3 - 2018-04-22
|
||||
|
||||
* Fix: Default headers when decode_content is specified
|
||||
@@ -402,14 +106,13 @@ Please see [the upgrade document](UPGRADING.md) that describes all BC breaking c
|
||||
* Bug fix: Fill `CURLOPT_CAPATH` and `CURLOPT_CAINFO` properly [#1684](https://github.com/guzzle/guzzle/pull/1684)
|
||||
* Improvement: Use `\GuzzleHttp\Promise\rejection_for` function instead of object init [#1827](https://github.com/guzzle/guzzle/pull/1827)
|
||||
|
||||
+ Minor code cleanups, documentation fixes and clarifications.
|
||||
|
||||
+ Minor code cleanups, documentation fixes and clarifications.
|
||||
|
||||
## 6.2.3 - 2017-02-28
|
||||
|
||||
* Fix deprecations with guzzle/psr7 version 1.4
|
||||
|
||||
|
||||
## 6.2.2 - 2016-10-08
|
||||
|
||||
* Allow to pass nullable Response to delay callable
|
||||
@@ -417,7 +120,6 @@ Please see [the upgrade document](UPGRADING.md) that describes all BC breaking c
|
||||
* Fix drain case where content-length is the literal string zero
|
||||
* Obfuscate in-URL credentials in exceptions
|
||||
|
||||
|
||||
## 6.2.1 - 2016-07-18
|
||||
|
||||
* Address HTTP_PROXY security vulnerability, CVE-2016-5385:
|
||||
@@ -428,7 +130,6 @@ Please see [the upgrade document](UPGRADING.md) that describes all BC breaking c
|
||||
a server does not honor `Connection: close`.
|
||||
* Ignore URI fragment when sending requests.
|
||||
|
||||
|
||||
## 6.2.0 - 2016-03-21
|
||||
|
||||
* Feature: added `GuzzleHttp\json_encode` and `GuzzleHttp\json_decode`.
|
||||
@@ -448,7 +149,6 @@ Please see [the upgrade document](UPGRADING.md) that describes all BC breaking c
|
||||
* Bug fix: provide an empty string to `http_build_query` for HHVM workaround.
|
||||
https://github.com/guzzle/guzzle/pull/1367
|
||||
|
||||
|
||||
## 6.1.1 - 2015-11-22
|
||||
|
||||
* Bug fix: Proxy::wrapSync() now correctly proxies to the appropriate handler
|
||||
@@ -464,7 +164,6 @@ Please see [the upgrade document](UPGRADING.md) that describes all BC breaking c
|
||||
* Bug fix: fixed regression where MockHandler was not using `sink`.
|
||||
https://github.com/guzzle/guzzle/pull/1292
|
||||
|
||||
|
||||
## 6.1.0 - 2015-09-08
|
||||
|
||||
* Feature: Added the `on_stats` request option to provide access to transfer
|
||||
@@ -499,7 +198,6 @@ Please see [the upgrade document](UPGRADING.md) that describes all BC breaking c
|
||||
* Bug fix: Adding a Content-Length to PHP stream wrapper requests if not set.
|
||||
https://github.com/guzzle/guzzle/pull/1189
|
||||
|
||||
|
||||
## 6.0.2 - 2015-07-04
|
||||
|
||||
* Fixed a memory leak in the curl handlers in which references to callbacks
|
||||
@@ -517,7 +215,6 @@ Please see [the upgrade document](UPGRADING.md) that describes all BC breaking c
|
||||
* Functions are now conditionally required using an additional level of
|
||||
indirection to help with global Composer installations.
|
||||
|
||||
|
||||
## 6.0.1 - 2015-05-27
|
||||
|
||||
* Fixed a bug with serializing the `query` request option where the `&`
|
||||
@@ -526,7 +223,6 @@ Please see [the upgrade document](UPGRADING.md) that describes all BC breaking c
|
||||
use `form_params` or `multipart` instead.
|
||||
* Various doc fixes.
|
||||
|
||||
|
||||
## 6.0.0 - 2015-05-26
|
||||
|
||||
* See the UPGRADING.md document for more information.
|
||||
@@ -551,7 +247,6 @@ Please see [the upgrade document](UPGRADING.md) that describes all BC breaking c
|
||||
* `$maxHandles` has been removed from CurlMultiHandler.
|
||||
* `MultipartPostBody` is now part of the `guzzlehttp/psr7` package.
|
||||
|
||||
|
||||
## 5.3.0 - 2015-05-19
|
||||
|
||||
* Mock now supports `save_to`
|
||||
@@ -562,7 +257,6 @@ Please see [the upgrade document](UPGRADING.md) that describes all BC breaking c
|
||||
* Marked `GuzzleHttp\Client::getDefaultUserAgent` as deprecated.
|
||||
* URL scheme is now always lowercased.
|
||||
|
||||
|
||||
## 6.0.0-beta.1
|
||||
|
||||
* Requires PHP >= 5.5
|
||||
@@ -615,7 +309,6 @@ Please see [the upgrade document](UPGRADING.md) that describes all BC breaking c
|
||||
* `GuzzleHttp\QueryParser` has been replaced with the
|
||||
`GuzzleHttp\Psr7\parse_query`.
|
||||
|
||||
|
||||
## 5.2.0 - 2015-01-27
|
||||
|
||||
* Added `AppliesHeadersInterface` to make applying headers to a request based
|
||||
@@ -626,7 +319,6 @@ Please see [the upgrade document](UPGRADING.md) that describes all BC breaking c
|
||||
RingBridge.
|
||||
* Added a guard in the Pool class to not use recursion for request retries.
|
||||
|
||||
|
||||
## 5.1.0 - 2014-12-19
|
||||
|
||||
* Pool class no longer uses recursion when a request is intercepted.
|
||||
@@ -647,7 +339,6 @@ Please see [the upgrade document](UPGRADING.md) that describes all BC breaking c
|
||||
* Exceptions thrown in the `end` event are now correctly wrapped with Guzzle
|
||||
specific exceptions if necessary.
|
||||
|
||||
|
||||
## 5.0.3 - 2014-11-03
|
||||
|
||||
This change updates query strings so that they are treated as un-encoded values
|
||||
@@ -662,7 +353,6 @@ string that should not be parsed or encoded (unless a call to getQuery() is
|
||||
subsequently made, forcing the query-string to be converted into a Query
|
||||
object).
|
||||
|
||||
|
||||
## 5.0.2 - 2014-10-30
|
||||
|
||||
* Added a trailing `\r\n` to multipart/form-data payloads. See
|
||||
@@ -682,9 +372,7 @@ object).
|
||||
* Note: This has been changed in 5.0.3 to now encode query string values by
|
||||
default unless the `rawString` argument is provided when setting the query
|
||||
string on a URL: Now allowing many more characters to be present in the
|
||||
query string without being percent encoded. See
|
||||
https://datatracker.ietf.org/doc/html/rfc3986#appendix-A
|
||||
|
||||
query string without being percent encoded. See http://tools.ietf.org/html/rfc3986#appendix-A
|
||||
|
||||
## 5.0.1 - 2014-10-16
|
||||
|
||||
@@ -697,7 +385,6 @@ Bugfix release.
|
||||
* Fixed an issue where transfer statistics were not being populated in the
|
||||
RingBridge. https://github.com/guzzle/guzzle/issues/866
|
||||
|
||||
|
||||
## 5.0.0 - 2014-10-12
|
||||
|
||||
Adding support for non-blocking responses and some minor API cleanup.
|
||||
@@ -727,7 +414,7 @@ interfaces.
|
||||
responses, `GuzzleHttp\Collection`, `GuzzleHttp\Url`,
|
||||
`GuzzleHttp\Query`, `GuzzleHttp\Post\PostBody`, and
|
||||
`GuzzleHttp\Cookie\SetCookie`. This blog post provides a good outline of
|
||||
why I did this: https://ocramius.github.io/blog/fluent-interfaces-are-evil/.
|
||||
why I did this: http://ocramius.github.io/blog/fluent-interfaces-are-evil/.
|
||||
This also makes the Guzzle message interfaces compatible with the current
|
||||
PSR-7 message proposal.
|
||||
* Removed "functions.php", so that Guzzle is truly PSR-4 compliant. Except
|
||||
@@ -779,7 +466,6 @@ interfaces.
|
||||
argument. They now accept an associative array of options, including the
|
||||
"size" key and "metadata" key which can be used to provide custom metadata.
|
||||
|
||||
|
||||
## 4.2.2 - 2014-09-08
|
||||
|
||||
* Fixed a memory leak in the CurlAdapter when reusing cURL handles.
|
||||
@@ -914,6 +600,8 @@ interfaces.
|
||||
|
||||
## 4.0.0 - 2014-03-29
|
||||
|
||||
* For more information on the 4.0 transition, see:
|
||||
http://mtdowling.com/blog/2014/03/15/guzzle-4-rc/
|
||||
* For information on changes and upgrading, see:
|
||||
https://github.com/guzzle/guzzle/blob/master/UPGRADING.md#3x-to-40
|
||||
* Added `GuzzleHttp\batch()` as a convenience function for sending requests in
|
||||
@@ -1222,7 +910,7 @@ interfaces.
|
||||
|
||||
## 3.4.0 - 2013-04-11
|
||||
|
||||
* Bug fix: URLs are now resolved correctly based on https://datatracker.ietf.org/doc/html/rfc3986#section-5.2. #289
|
||||
* Bug fix: URLs are now resolved correctly based on http://tools.ietf.org/html/rfc3986#section-5.2. #289
|
||||
* Bug fix: Absolute URLs with a path in a service description will now properly override the base URL. #289
|
||||
* Bug fix: Parsing a query string with a single PHP array value will now result in an array. #263
|
||||
* Bug fix: Better normalization of the User-Agent header to prevent duplicate headers. #264.
|
||||
|
||||
18
Server/vendor/guzzlehttp/guzzle/Dockerfile
vendored
Normal file
18
Server/vendor/guzzlehttp/guzzle/Dockerfile
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
FROM composer:latest as setup
|
||||
|
||||
RUN mkdir /guzzle
|
||||
|
||||
WORKDIR /guzzle
|
||||
|
||||
RUN set -xe \
|
||||
&& composer init --name=guzzlehttp/test --description="Simple project for testing Guzzle scripts" --author="Márk Sági-Kazár <mark.sagikazar@gmail.com>" --no-interaction \
|
||||
&& composer require guzzlehttp/guzzle
|
||||
|
||||
|
||||
FROM php:7.3
|
||||
|
||||
RUN mkdir /guzzle
|
||||
|
||||
WORKDIR /guzzle
|
||||
|
||||
COPY --from=setup /guzzle /guzzle
|
||||
59
Server/vendor/guzzlehttp/guzzle/README.md
vendored
59
Server/vendor/guzzlehttp/guzzle/README.md
vendored
@@ -3,7 +3,7 @@
|
||||
# Guzzle, PHP HTTP client
|
||||
|
||||
[](https://github.com/guzzle/guzzle/releases)
|
||||
[](https://github.com/guzzle/guzzle/actions?query=workflow%3ACI)
|
||||
[](https://github.com/guzzle/guzzle/actions?query=workflow%3ACI)
|
||||
[](https://packagist.org/packages/guzzlehttp/guzzle)
|
||||
|
||||
Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and
|
||||
@@ -15,7 +15,6 @@ trivial to integrate with web services.
|
||||
- Can send both synchronous and asynchronous requests using the same interface.
|
||||
- Uses PSR-7 interfaces for requests, responses, and streams. This allows you
|
||||
to utilize other PSR-7 compatible libraries with Guzzle.
|
||||
- Supports PSR-18 allowing interoperability between other PSR-18 HTTP Clients.
|
||||
- Abstracts away the underlying HTTP transport, allowing you to write
|
||||
environment and transport agnostic code; i.e., no hard dependency on cURL,
|
||||
PHP streams, sockets, or non-blocking event loops.
|
||||
@@ -25,11 +24,11 @@ trivial to integrate with web services.
|
||||
$client = new \GuzzleHttp\Client();
|
||||
$response = $client->request('GET', 'https://api.github.com/repos/guzzle/guzzle');
|
||||
|
||||
echo $response->getStatusCode(); // 200
|
||||
echo $response->getHeaderLine('content-type'); // 'application/json; charset=utf8'
|
||||
echo $response->getBody(); // '{"id": 1420053, "name": "guzzle", ...}'
|
||||
echo $response->getStatusCode(); # 200
|
||||
echo $response->getHeaderLine('content-type'); # 'application/json; charset=utf8'
|
||||
echo $response->getBody(); # '{"id": 1420053, "name": "guzzle", ...}'
|
||||
|
||||
// Send an asynchronous request.
|
||||
# Send an asynchronous request.
|
||||
$request = new \GuzzleHttp\Psr7\Request('GET', 'http://httpbin.org');
|
||||
$promise = $client->sendAsync($request)->then(function ($response) {
|
||||
echo 'I completed! ' . $response->getBody();
|
||||
@@ -53,20 +52,39 @@ We use GitHub issues only to discuss bugs and new features. For support please r
|
||||
The recommended way to install Guzzle is through
|
||||
[Composer](https://getcomposer.org/).
|
||||
|
||||
```bash
|
||||
# Install Composer
|
||||
curl -sS https://getcomposer.org/installer | php
|
||||
```
|
||||
|
||||
Next, run the Composer command to install the latest stable version of Guzzle:
|
||||
|
||||
```bash
|
||||
composer require guzzlehttp/guzzle
|
||||
```
|
||||
|
||||
After installing, you need to require Composer's autoloader:
|
||||
|
||||
```php
|
||||
require 'vendor/autoload.php';
|
||||
```
|
||||
|
||||
You can then later update Guzzle using composer:
|
||||
|
||||
```bash
|
||||
composer update
|
||||
```
|
||||
|
||||
|
||||
## Version Guidance
|
||||
|
||||
| Version | Status | Packagist | Namespace | Repo | Docs | PSR-7 | PHP Version |
|
||||
|---------|---------------------|---------------------|--------------|---------------------|---------------------|-------|--------------|
|
||||
| 3.x | EOL (2016-10-31) | `guzzle/guzzle` | `Guzzle` | [v3][guzzle-3-repo] | [v3][guzzle-3-docs] | No | >=5.3.3,<7.0 |
|
||||
| 4.x | EOL (2016-10-31) | `guzzlehttp/guzzle` | `GuzzleHttp` | [v4][guzzle-4-repo] | N/A | No | >=5.4,<7.0 |
|
||||
| 5.x | EOL (2019-10-31) | `guzzlehttp/guzzle` | `GuzzleHttp` | [v5][guzzle-5-repo] | [v5][guzzle-5-docs] | No | >=5.4,<7.4 |
|
||||
| 6.x | EOL (2023-10-31) | `guzzlehttp/guzzle` | `GuzzleHttp` | [v6][guzzle-6-repo] | [v6][guzzle-6-docs] | Yes | >=5.5,<8.0 |
|
||||
| 7.x | Latest | `guzzlehttp/guzzle` | `GuzzleHttp` | [v7][guzzle-7-repo] | [v7][guzzle-7-docs] | Yes | >=7.2.5,<8.5 |
|
||||
| Version | Status | Packagist | Namespace | Repo | Docs | PSR-7 | PHP Version |
|
||||
|---------|----------------|---------------------|--------------|---------------------|---------------------|-------|--------------|
|
||||
| 3.x | EOL | `guzzle/guzzle` | `Guzzle` | [v3][guzzle-3-repo] | [v3][guzzle-3-docs] | No | >=5.3.3,<7.0 |
|
||||
| 4.x | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | [v4][guzzle-4-repo] | N/A | No | >=5.4,<7.0 |
|
||||
| 5.x | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | [v5][guzzle-5-repo] | [v5][guzzle-5-docs] | No | >=5.4,<7.4 |
|
||||
| 6.x | Security fixes | `guzzlehttp/guzzle` | `GuzzleHttp` | [v6][guzzle-6-repo] | [v6][guzzle-6-docs] | Yes | >=5.5,<8.0 |
|
||||
| 7.x | Latest | `guzzlehttp/guzzle` | `GuzzleHttp` | [v7][guzzle-7-repo] | [v7][guzzle-7-docs] | Yes | >=7.2.5,<8.2 |
|
||||
|
||||
[guzzle-3-repo]: https://github.com/guzzle/guzzle3
|
||||
[guzzle-4-repo]: https://github.com/guzzle/guzzle/tree/4.x
|
||||
@@ -77,18 +95,3 @@ composer require guzzlehttp/guzzle
|
||||
[guzzle-5-docs]: https://docs.guzzlephp.org/en/5.3/
|
||||
[guzzle-6-docs]: https://docs.guzzlephp.org/en/6.5/
|
||||
[guzzle-7-docs]: https://docs.guzzlephp.org/en/latest/
|
||||
|
||||
|
||||
## Security
|
||||
|
||||
If you discover a security vulnerability within this package, please send an email to security@tidelift.com. All security vulnerabilities will be promptly addressed. Please do not disclose security-related issues publicly until a fix has been announced. Please see [Security Policy](https://github.com/guzzle/guzzle/security/policy) for more information.
|
||||
|
||||
## License
|
||||
|
||||
Guzzle is made available under the MIT License (MIT). Please see [License File](LICENSE) for more information.
|
||||
|
||||
## For Enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription
|
||||
|
||||
The maintainers of Guzzle and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-guzzlehttp-guzzle?utm_source=packagist-guzzlehttp-guzzle&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
||||
|
||||
68
Server/vendor/guzzlehttp/guzzle/UPGRADING.md
vendored
68
Server/vendor/guzzlehttp/guzzle/UPGRADING.md
vendored
@@ -1,60 +1,10 @@
|
||||
Guzzle Upgrade Guide
|
||||
====================
|
||||
|
||||
6.0 to 7.0
|
||||
----------
|
||||
|
||||
In order to take advantage of the new features of PHP, Guzzle dropped the support
|
||||
of PHP 5. The minimum supported PHP version is now PHP 7.2. Type hints and return
|
||||
types for functions and methods have been added wherever possible.
|
||||
|
||||
Please make sure:
|
||||
- You are calling a function or a method with the correct type.
|
||||
- If you extend a class of Guzzle; update all signatures on methods you override.
|
||||
|
||||
#### Other backwards compatibility breaking changes
|
||||
|
||||
- Class `GuzzleHttp\UriTemplate` is removed.
|
||||
- Class `GuzzleHttp\Exception\SeekException` is removed.
|
||||
- Classes `GuzzleHttp\Exception\BadResponseException`, `GuzzleHttp\Exception\ClientException`,
|
||||
`GuzzleHttp\Exception\ServerException` can no longer be initialized with an empty
|
||||
Response as argument.
|
||||
- Class `GuzzleHttp\Exception\ConnectException` now extends `GuzzleHttp\Exception\TransferException`
|
||||
instead of `GuzzleHttp\Exception\RequestException`.
|
||||
- Function `GuzzleHttp\Exception\ConnectException::getResponse()` is removed.
|
||||
- Function `GuzzleHttp\Exception\ConnectException::hasResponse()` is removed.
|
||||
- Constant `GuzzleHttp\ClientInterface::VERSION` is removed. Added `GuzzleHttp\ClientInterface::MAJOR_VERSION` instead.
|
||||
- Function `GuzzleHttp\Exception\RequestException::getResponseBodySummary` is removed.
|
||||
Use `\GuzzleHttp\Psr7\get_message_body_summary` as an alternative.
|
||||
- Function `GuzzleHttp\Cookie\CookieJar::getCookieValue` is removed.
|
||||
- Request option `exceptions` is removed. Please use `http_errors`.
|
||||
- Request option `save_to` is removed. Please use `sink`.
|
||||
- Pool option `pool_size` is removed. Please use `concurrency`.
|
||||
- We now look for environment variables in the `$_SERVER` super global, due to thread safety issues with `getenv`. We continue to fallback to `getenv` in CLI environments, for maximum compatibility.
|
||||
- The `get`, `head`, `put`, `post`, `patch`, `delete`, `getAsync`, `headAsync`, `putAsync`, `postAsync`, `patchAsync`, and `deleteAsync` methods are now implemented as genuine methods on `GuzzleHttp\Client`, with strong typing. The original `__call` implementation remains unchanged for now, for maximum backwards compatibility, but won't be invoked under normal operation.
|
||||
- The `log` middleware will log the errors with level `error` instead of `notice`
|
||||
- Support for international domain names (IDN) is now disabled by default, and enabling it requires installing ext-intl, linked against a modern version of the C library (ICU 4.6 or higher).
|
||||
|
||||
#### Native functions calls
|
||||
|
||||
All internal native functions calls of Guzzle are now prefixed with a slash. This
|
||||
change makes it impossible for method overloading by other libraries or applications.
|
||||
Example:
|
||||
|
||||
```php
|
||||
// Before:
|
||||
curl_version();
|
||||
|
||||
// After:
|
||||
\curl_version();
|
||||
```
|
||||
|
||||
For the full diff you can check [here](https://github.com/guzzle/guzzle/compare/6.5.4..master).
|
||||
|
||||
5.0 to 6.0
|
||||
----------
|
||||
|
||||
Guzzle now uses [PSR-7](https://www.php-fig.org/psr/psr-7/) for HTTP messages.
|
||||
Guzzle now uses [PSR-7](http://www.php-fig.org/psr/psr-7/) for HTTP messages.
|
||||
Due to the fact that these messages are immutable, this prompted a refactoring
|
||||
of Guzzle to use a middleware based system rather than an event system. Any
|
||||
HTTP message interaction (e.g., `GuzzleHttp\Message\Request`) need to be
|
||||
@@ -189,11 +139,11 @@ $client = new GuzzleHttp\Client(['handler' => $handler]);
|
||||
|
||||
## POST Requests
|
||||
|
||||
This version added the [`form_params`](https://docs.guzzlephp.org/en/latest/request-options.html#form_params)
|
||||
This version added the [`form_params`](http://guzzle.readthedocs.org/en/latest/request-options.html#form_params)
|
||||
and `multipart` request options. `form_params` is an associative array of
|
||||
strings or array of strings and is used to serialize an
|
||||
`application/x-www-form-urlencoded` POST request. The
|
||||
[`multipart`](https://docs.guzzlephp.org/en/latest/request-options.html#multipart)
|
||||
[`multipart`](http://guzzle.readthedocs.org/en/latest/request-options.html#multipart)
|
||||
option is now used to send a multipart/form-data POST request.
|
||||
|
||||
`GuzzleHttp\Post\PostFile` has been removed. Use the `multipart` option to add
|
||||
@@ -209,7 +159,7 @@ The `base_url` option has been renamed to `base_uri`.
|
||||
|
||||
## Rewritten Adapter Layer
|
||||
|
||||
Guzzle now uses [RingPHP](https://ringphp.readthedocs.org/en/latest) to send
|
||||
Guzzle now uses [RingPHP](http://ringphp.readthedocs.org/en/latest) to send
|
||||
HTTP requests. The `adapter` option in a `GuzzleHttp\Client` constructor
|
||||
is still supported, but it has now been renamed to `handler`. Instead of
|
||||
passing a `GuzzleHttp\Adapter\AdapterInterface`, you must now pass a PHP
|
||||
@@ -217,7 +167,7 @@ passing a `GuzzleHttp\Adapter\AdapterInterface`, you must now pass a PHP
|
||||
|
||||
## Removed Fluent Interfaces
|
||||
|
||||
[Fluent interfaces were removed](https://ocramius.github.io/blog/fluent-interfaces-are-evil/)
|
||||
[Fluent interfaces were removed](http://ocramius.github.io/blog/fluent-interfaces-are-evil)
|
||||
from the following classes:
|
||||
|
||||
- `GuzzleHttp\Collection`
|
||||
@@ -575,7 +525,7 @@ You can intercept a request and inject a response using the `intercept()` event
|
||||
of a `GuzzleHttp\Event\BeforeEvent`, `GuzzleHttp\Event\CompleteEvent`, and
|
||||
`GuzzleHttp\Event\ErrorEvent` event.
|
||||
|
||||
See: https://docs.guzzlephp.org/en/latest/events.html
|
||||
See: http://docs.guzzlephp.org/en/latest/events.html
|
||||
|
||||
## Inflection
|
||||
|
||||
@@ -668,9 +618,9 @@ in separate repositories:
|
||||
|
||||
The service description layer of Guzzle has moved into two separate packages:
|
||||
|
||||
- https://github.com/guzzle/command Provides a high level abstraction over web
|
||||
- http://github.com/guzzle/command Provides a high level abstraction over web
|
||||
services by representing web service operations using commands.
|
||||
- https://github.com/guzzle/guzzle-services Provides an implementation of
|
||||
- http://github.com/guzzle/guzzle-services Provides an implementation of
|
||||
guzzle/command that provides request serialization and response parsing using
|
||||
Guzzle service descriptions.
|
||||
|
||||
@@ -870,7 +820,7 @@ HeaderInterface (e.g. toArray(), getAll(), etc.).
|
||||
3.3 to 3.4
|
||||
----------
|
||||
|
||||
Base URLs of a client now follow the rules of https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.2 when merging URLs.
|
||||
Base URLs of a client now follow the rules of http://tools.ietf.org/html/rfc3986#section-5.2.2 when merging URLs.
|
||||
|
||||
3.2 to 3.3
|
||||
----------
|
||||
|
||||
65
Server/vendor/guzzlehttp/guzzle/composer.json
vendored
65
Server/vendor/guzzlehttp/guzzle/composer.json
vendored
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "guzzlehttp/guzzle",
|
||||
"type": "library",
|
||||
"description": "Guzzle is a PHP HTTP client library",
|
||||
"keywords": [
|
||||
"framework",
|
||||
@@ -8,10 +9,9 @@
|
||||
"web service",
|
||||
"curl",
|
||||
"client",
|
||||
"HTTP client",
|
||||
"PSR-7",
|
||||
"PSR-18"
|
||||
"HTTP client"
|
||||
],
|
||||
"homepage": "http://guzzlephp.org/",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
@@ -50,69 +50,30 @@
|
||||
"homepage": "https://github.com/Tobion"
|
||||
}
|
||||
],
|
||||
"repositories": [
|
||||
{
|
||||
"type": "package",
|
||||
"package": {
|
||||
"name": "guzzle/client-integration-tests",
|
||||
"version": "v3.0.2",
|
||||
"dist": {
|
||||
"url": "https://codeload.github.com/guzzle/client-integration-tests/zip/2c025848417c1135031fdf9c728ee53d0a7ceaee",
|
||||
"type": "zip"
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2.5 || ^8.0",
|
||||
"phpunit/phpunit": "^7.5.20 || ^8.5.8 || ^9.3.11",
|
||||
"php-http/message": "^1.0 || ^2.0",
|
||||
"guzzlehttp/psr7": "^1.7 || ^2.0",
|
||||
"th3n3rd/cartesian-product": "^0.3"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Http\\Client\\Tests\\": "src/"
|
||||
}
|
||||
},
|
||||
"bin": [
|
||||
"bin/http_test_server"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.2.5 || ^8.0",
|
||||
"php": ">=5.5",
|
||||
"ext-json": "*",
|
||||
"guzzlehttp/promises": "^1.5.3 || ^2.0.3",
|
||||
"guzzlehttp/psr7": "^2.7.0",
|
||||
"psr/http-client": "^1.0",
|
||||
"symfony/deprecation-contracts": "^2.2 || ^3.0"
|
||||
},
|
||||
"provide": {
|
||||
"psr/http-client-implementation": "1.0"
|
||||
"symfony/polyfill-intl-idn": "^1.17",
|
||||
"guzzlehttp/promises": "^1.0",
|
||||
"guzzlehttp/psr7": "^1.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-curl": "*",
|
||||
"bamarni/composer-bin-plugin": "^1.8.2",
|
||||
"guzzle/client-integration-tests": "3.0.2",
|
||||
"php-http/message-factory": "^1.1",
|
||||
"phpunit/phpunit": "^8.5.39 || ^9.6.20",
|
||||
"psr/log": "^1.1 || ^2.0 || ^3.0"
|
||||
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0",
|
||||
"psr/log": "^1.1"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-curl": "Required for CURL handler support",
|
||||
"ext-intl": "Required for Internationalized Domain Name (IDN) support",
|
||||
"psr/log": "Required for using the Log middleware"
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"bamarni/composer-bin-plugin": true
|
||||
},
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"bamarni-bin": {
|
||||
"bin-links": true,
|
||||
"forward-command": false
|
||||
"branch-alias": {
|
||||
"dev-master": "6.5-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp;
|
||||
|
||||
use Psr\Http\Message\MessageInterface;
|
||||
|
||||
final class BodySummarizer implements BodySummarizerInterface
|
||||
{
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $truncateAt;
|
||||
|
||||
public function __construct(?int $truncateAt = null)
|
||||
{
|
||||
$this->truncateAt = $truncateAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a summarized message body.
|
||||
*/
|
||||
public function summarize(MessageInterface $message): ?string
|
||||
{
|
||||
return $this->truncateAt === null
|
||||
? Psr7\Message::bodySummary($message)
|
||||
: Psr7\Message::bodySummary($message, $this->truncateAt);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp;
|
||||
|
||||
use Psr\Http\Message\MessageInterface;
|
||||
|
||||
interface BodySummarizerInterface
|
||||
{
|
||||
/**
|
||||
* Returns a summarized message body.
|
||||
*/
|
||||
public function summarize(MessageInterface $message): ?string;
|
||||
}
|
||||
268
Server/vendor/guzzlehttp/guzzle/src/Client.php
vendored
268
Server/vendor/guzzlehttp/guzzle/src/Client.php
vendored
@@ -1,26 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp;
|
||||
|
||||
use GuzzleHttp\Cookie\CookieJar;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use GuzzleHttp\Exception\InvalidArgumentException;
|
||||
use GuzzleHttp\Promise as P;
|
||||
use GuzzleHttp\Promise\PromiseInterface;
|
||||
use GuzzleHttp\Promise;
|
||||
use GuzzleHttp\Psr7;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
|
||||
/**
|
||||
* @final
|
||||
* @method ResponseInterface get(string|UriInterface $uri, array $options = [])
|
||||
* @method ResponseInterface head(string|UriInterface $uri, array $options = [])
|
||||
* @method ResponseInterface put(string|UriInterface $uri, array $options = [])
|
||||
* @method ResponseInterface post(string|UriInterface $uri, array $options = [])
|
||||
* @method ResponseInterface patch(string|UriInterface $uri, array $options = [])
|
||||
* @method ResponseInterface delete(string|UriInterface $uri, array $options = [])
|
||||
* @method Promise\PromiseInterface getAsync(string|UriInterface $uri, array $options = [])
|
||||
* @method Promise\PromiseInterface headAsync(string|UriInterface $uri, array $options = [])
|
||||
* @method Promise\PromiseInterface putAsync(string|UriInterface $uri, array $options = [])
|
||||
* @method Promise\PromiseInterface postAsync(string|UriInterface $uri, array $options = [])
|
||||
* @method Promise\PromiseInterface patchAsync(string|UriInterface $uri, array $options = [])
|
||||
* @method Promise\PromiseInterface deleteAsync(string|UriInterface $uri, array $options = [])
|
||||
*/
|
||||
class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||
class Client implements ClientInterface
|
||||
{
|
||||
use ClientTrait;
|
||||
|
||||
/**
|
||||
* @var array Default request options
|
||||
*/
|
||||
/** @var array Default request options */
|
||||
private $config;
|
||||
|
||||
/**
|
||||
@@ -52,19 +57,19 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||
*
|
||||
* @param array $config Client configuration settings.
|
||||
*
|
||||
* @see RequestOptions for a list of available request options.
|
||||
* @see \GuzzleHttp\RequestOptions for a list of available request options.
|
||||
*/
|
||||
public function __construct(array $config = [])
|
||||
{
|
||||
if (!isset($config['handler'])) {
|
||||
$config['handler'] = HandlerStack::create();
|
||||
} elseif (!\is_callable($config['handler'])) {
|
||||
throw new InvalidArgumentException('handler must be a callable');
|
||||
} elseif (!is_callable($config['handler'])) {
|
||||
throw new \InvalidArgumentException('handler must be a callable');
|
||||
}
|
||||
|
||||
// Convert the base_uri to a UriInterface
|
||||
if (isset($config['base_uri'])) {
|
||||
$config['base_uri'] = Psr7\Utils::uriFor($config['base_uri']);
|
||||
$config['base_uri'] = Psr7\uri_for($config['base_uri']);
|
||||
}
|
||||
|
||||
$this->configureDefaults($config);
|
||||
@@ -74,21 +79,19 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||
* @param string $method
|
||||
* @param array $args
|
||||
*
|
||||
* @return PromiseInterface|ResponseInterface
|
||||
*
|
||||
* @deprecated Client::__call will be removed in guzzlehttp/guzzle:8.0.
|
||||
* @return Promise\PromiseInterface
|
||||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
if (\count($args) < 1) {
|
||||
throw new InvalidArgumentException('Magic request methods require a URI and optional options array');
|
||||
if (count($args) < 1) {
|
||||
throw new \InvalidArgumentException('Magic request methods require a URI and optional options array');
|
||||
}
|
||||
|
||||
$uri = $args[0];
|
||||
$opts = $args[1] ?? [];
|
||||
$opts = isset($args[1]) ? $args[1] : [];
|
||||
|
||||
return \substr($method, -5) === 'Async'
|
||||
? $this->requestAsync(\substr($method, 0, -5), $uri, $opts)
|
||||
return substr($method, -5) === 'Async'
|
||||
? $this->requestAsync(substr($method, 0, -5), $uri, $opts)
|
||||
: $this->request($method, $uri, $opts);
|
||||
}
|
||||
|
||||
@@ -97,8 +100,10 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||
*
|
||||
* @param array $options Request options to apply to the given
|
||||
* request and to the transfer. See \GuzzleHttp\RequestOptions.
|
||||
*
|
||||
* @return Promise\PromiseInterface
|
||||
*/
|
||||
public function sendAsync(RequestInterface $request, array $options = []): PromiseInterface
|
||||
public function sendAsync(RequestInterface $request, array $options = [])
|
||||
{
|
||||
// Merge the base URI into the request URI if needed.
|
||||
$options = $this->prepareDefaults($options);
|
||||
@@ -115,26 +120,12 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||
* @param array $options Request options to apply to the given
|
||||
* request and to the transfer. See \GuzzleHttp\RequestOptions.
|
||||
*
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function send(RequestInterface $request, array $options = []): ResponseInterface
|
||||
public function send(RequestInterface $request, array $options = [])
|
||||
{
|
||||
$options[RequestOptions::SYNCHRONOUS] = true;
|
||||
|
||||
return $this->sendAsync($request, $options)->wait();
|
||||
}
|
||||
|
||||
/**
|
||||
* The HttpClient PSR (PSR-18) specify this method.
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function sendRequest(RequestInterface $request): ResponseInterface
|
||||
{
|
||||
$options[RequestOptions::SYNCHRONOUS] = true;
|
||||
$options[RequestOptions::ALLOW_REDIRECTS] = false;
|
||||
$options[RequestOptions::HTTP_ERRORS] = false;
|
||||
|
||||
return $this->sendAsync($request, $options)->wait();
|
||||
}
|
||||
|
||||
@@ -149,18 +140,20 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||
* @param string $method HTTP method
|
||||
* @param string|UriInterface $uri URI object or string.
|
||||
* @param array $options Request options to apply. See \GuzzleHttp\RequestOptions.
|
||||
*
|
||||
* @return Promise\PromiseInterface
|
||||
*/
|
||||
public function requestAsync(string $method, $uri = '', array $options = []): PromiseInterface
|
||||
public function requestAsync($method, $uri = '', array $options = [])
|
||||
{
|
||||
$options = $this->prepareDefaults($options);
|
||||
// Remove request modifying parameter because it can be done up-front.
|
||||
$headers = $options['headers'] ?? [];
|
||||
$body = $options['body'] ?? null;
|
||||
$version = $options['version'] ?? '1.1';
|
||||
$headers = isset($options['headers']) ? $options['headers'] : [];
|
||||
$body = isset($options['body']) ? $options['body'] : null;
|
||||
$version = isset($options['version']) ? $options['version'] : '1.1';
|
||||
// Merge the URI into the base URI.
|
||||
$uri = $this->buildUri(Psr7\Utils::uriFor($uri), $options);
|
||||
if (\is_array($body)) {
|
||||
throw $this->invalidBody();
|
||||
$uri = $this->buildUri($uri, $options);
|
||||
if (is_array($body)) {
|
||||
$this->invalidBody();
|
||||
}
|
||||
$request = new Psr7\Request($method, $uri, $headers, $body, $version);
|
||||
// Remove the option so that they are not doubly-applied.
|
||||
@@ -180,12 +173,12 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||
* @param string|UriInterface $uri URI object or string.
|
||||
* @param array $options Request options to apply. See \GuzzleHttp\RequestOptions.
|
||||
*
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function request(string $method, $uri = '', array $options = []): ResponseInterface
|
||||
public function request($method, $uri = '', array $options = [])
|
||||
{
|
||||
$options[RequestOptions::SYNCHRONOUS] = true;
|
||||
|
||||
return $this->requestAsync($method, $uri, $options)->wait();
|
||||
}
|
||||
|
||||
@@ -199,24 +192,30 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||
* @param string|null $option The config option to retrieve.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @deprecated Client::getConfig will be removed in guzzlehttp/guzzle:8.0.
|
||||
*/
|
||||
public function getConfig(?string $option = null)
|
||||
public function getConfig($option = null)
|
||||
{
|
||||
return $option === null
|
||||
? $this->config
|
||||
: ($this->config[$option] ?? null);
|
||||
: (isset($this->config[$option]) ? $this->config[$option] : null);
|
||||
}
|
||||
|
||||
private function buildUri(UriInterface $uri, array $config): UriInterface
|
||||
/**
|
||||
* @param string|null $uri
|
||||
*
|
||||
* @return UriInterface
|
||||
*/
|
||||
private function buildUri($uri, array $config)
|
||||
{
|
||||
// for BC we accept null which would otherwise fail in uri_for
|
||||
$uri = Psr7\uri_for($uri === null ? '' : $uri);
|
||||
|
||||
if (isset($config['base_uri'])) {
|
||||
$uri = Psr7\UriResolver::resolve(Psr7\Utils::uriFor($config['base_uri']), $uri);
|
||||
$uri = Psr7\UriResolver::resolve(Psr7\uri_for($config['base_uri']), $uri);
|
||||
}
|
||||
|
||||
if (isset($config['idn_conversion']) && ($config['idn_conversion'] !== false)) {
|
||||
$idnOptions = ($config['idn_conversion'] === true) ? \IDNA_DEFAULT : $config['idn_conversion'];
|
||||
$idnOptions = ($config['idn_conversion'] === true) ? IDNA_DEFAULT : $config['idn_conversion'];
|
||||
$uri = Utils::idnUriConvert($uri, $idnOptions);
|
||||
}
|
||||
|
||||
@@ -225,16 +224,19 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||
|
||||
/**
|
||||
* Configures the default options for a client.
|
||||
*
|
||||
* @param array $config
|
||||
* @return void
|
||||
*/
|
||||
private function configureDefaults(array $config): void
|
||||
private function configureDefaults(array $config)
|
||||
{
|
||||
$defaults = [
|
||||
'allow_redirects' => RedirectMiddleware::$defaultSettings,
|
||||
'http_errors' => true,
|
||||
'decode_content' => true,
|
||||
'verify' => true,
|
||||
'cookies' => false,
|
||||
'idn_conversion' => false,
|
||||
'http_errors' => true,
|
||||
'decode_content' => true,
|
||||
'verify' => true,
|
||||
'cookies' => false,
|
||||
'idn_conversion' => true,
|
||||
];
|
||||
|
||||
// Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set.
|
||||
@@ -242,17 +244,17 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||
// We can only trust the HTTP_PROXY environment variable in a CLI
|
||||
// process due to the fact that PHP has no reliable mechanism to
|
||||
// get environment variables that start with "HTTP_".
|
||||
if (\PHP_SAPI === 'cli' && ($proxy = Utils::getenv('HTTP_PROXY'))) {
|
||||
$defaults['proxy']['http'] = $proxy;
|
||||
if (php_sapi_name() === 'cli' && getenv('HTTP_PROXY')) {
|
||||
$defaults['proxy']['http'] = getenv('HTTP_PROXY');
|
||||
}
|
||||
|
||||
if ($proxy = Utils::getenv('HTTPS_PROXY')) {
|
||||
if ($proxy = getenv('HTTPS_PROXY')) {
|
||||
$defaults['proxy']['https'] = $proxy;
|
||||
}
|
||||
|
||||
if ($noProxy = Utils::getenv('NO_PROXY')) {
|
||||
$cleanedNoProxy = \str_replace(' ', '', $noProxy);
|
||||
$defaults['proxy']['no'] = \explode(',', $cleanedNoProxy);
|
||||
if ($noProxy = getenv('NO_PROXY')) {
|
||||
$cleanedNoProxy = str_replace(' ', '', $noProxy);
|
||||
$defaults['proxy']['no'] = explode(',', $cleanedNoProxy);
|
||||
}
|
||||
|
||||
$this->config = $config + $defaults;
|
||||
@@ -263,15 +265,15 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||
|
||||
// Add the default user-agent header.
|
||||
if (!isset($this->config['headers'])) {
|
||||
$this->config['headers'] = ['User-Agent' => Utils::defaultUserAgent()];
|
||||
$this->config['headers'] = ['User-Agent' => default_user_agent()];
|
||||
} else {
|
||||
// Add the User-Agent header if one was not already set.
|
||||
foreach (\array_keys($this->config['headers']) as $name) {
|
||||
if (\strtolower($name) === 'user-agent') {
|
||||
foreach (array_keys($this->config['headers']) as $name) {
|
||||
if (strtolower($name) === 'user-agent') {
|
||||
return;
|
||||
}
|
||||
}
|
||||
$this->config['headers']['User-Agent'] = Utils::defaultUserAgent();
|
||||
$this->config['headers']['User-Agent'] = default_user_agent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,8 +281,10 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||
* Merges default options into the array.
|
||||
*
|
||||
* @param array $options Options to modify by reference
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function prepareDefaults(array $options): array
|
||||
private function prepareDefaults(array $options)
|
||||
{
|
||||
$defaults = $this->config;
|
||||
|
||||
@@ -292,13 +296,13 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||
|
||||
// Special handling for headers is required as they are added as
|
||||
// conditional headers and as headers passed to a request ctor.
|
||||
if (\array_key_exists('headers', $options)) {
|
||||
if (array_key_exists('headers', $options)) {
|
||||
// Allows default headers to be unset.
|
||||
if ($options['headers'] === null) {
|
||||
$defaults['_conditional'] = [];
|
||||
unset($options['headers']);
|
||||
} elseif (!\is_array($options['headers'])) {
|
||||
throw new InvalidArgumentException('headers must be an array');
|
||||
} elseif (!is_array($options['headers'])) {
|
||||
throw new \InvalidArgumentException('headers must be an array');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,49 +326,65 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||
* as-is without merging in default options.
|
||||
*
|
||||
* @param array $options See \GuzzleHttp\RequestOptions.
|
||||
*
|
||||
* @return Promise\PromiseInterface
|
||||
*/
|
||||
private function transfer(RequestInterface $request, array $options): PromiseInterface
|
||||
private function transfer(RequestInterface $request, array $options)
|
||||
{
|
||||
// save_to -> sink
|
||||
if (isset($options['save_to'])) {
|
||||
$options['sink'] = $options['save_to'];
|
||||
unset($options['save_to']);
|
||||
}
|
||||
|
||||
// exceptions -> http_errors
|
||||
if (isset($options['exceptions'])) {
|
||||
$options['http_errors'] = $options['exceptions'];
|
||||
unset($options['exceptions']);
|
||||
}
|
||||
|
||||
$request = $this->applyOptions($request, $options);
|
||||
/** @var HandlerStack $handler */
|
||||
$handler = $options['handler'];
|
||||
|
||||
try {
|
||||
return P\Create::promiseFor($handler($request, $options));
|
||||
return Promise\promise_for($handler($request, $options));
|
||||
} catch (\Exception $e) {
|
||||
return P\Create::rejectionFor($e);
|
||||
return Promise\rejection_for($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the array of request options to a request.
|
||||
*
|
||||
* @param RequestInterface $request
|
||||
* @param array $options
|
||||
*
|
||||
* @return RequestInterface
|
||||
*/
|
||||
private function applyOptions(RequestInterface $request, array &$options): RequestInterface
|
||||
private function applyOptions(RequestInterface $request, array &$options)
|
||||
{
|
||||
$modify = [
|
||||
'set_headers' => [],
|
||||
];
|
||||
|
||||
if (isset($options['headers'])) {
|
||||
if (array_keys($options['headers']) === range(0, count($options['headers']) - 1)) {
|
||||
throw new InvalidArgumentException('The headers array must have header name as keys.');
|
||||
}
|
||||
$modify['set_headers'] = $options['headers'];
|
||||
unset($options['headers']);
|
||||
}
|
||||
|
||||
if (isset($options['form_params'])) {
|
||||
if (isset($options['multipart'])) {
|
||||
throw new InvalidArgumentException('You cannot use '
|
||||
.'form_params and multipart at the same time. Use the '
|
||||
.'form_params option if you want to send application/'
|
||||
.'x-www-form-urlencoded requests, and the multipart '
|
||||
.'option to send multipart/form-data requests.');
|
||||
throw new \InvalidArgumentException('You cannot use '
|
||||
. 'form_params and multipart at the same time. Use the '
|
||||
. 'form_params option if you want to send application/'
|
||||
. 'x-www-form-urlencoded requests, and the multipart '
|
||||
. 'option to send multipart/form-data requests.');
|
||||
}
|
||||
$options['body'] = \http_build_query($options['form_params'], '', '&');
|
||||
$options['body'] = http_build_query($options['form_params'], '', '&');
|
||||
unset($options['form_params']);
|
||||
// Ensure that we don't have the header in different case and set the new value.
|
||||
$options['_conditional'] = Psr7\Utils::caselessRemove(['Content-Type'], $options['_conditional']);
|
||||
$options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']);
|
||||
$options['_conditional']['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||
}
|
||||
|
||||
@@ -374,10 +394,10 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||
}
|
||||
|
||||
if (isset($options['json'])) {
|
||||
$options['body'] = Utils::jsonEncode($options['json']);
|
||||
$options['body'] = \GuzzleHttp\json_encode($options['json']);
|
||||
unset($options['json']);
|
||||
// Ensure that we don't have the header in different case and set the new value.
|
||||
$options['_conditional'] = Psr7\Utils::caselessRemove(['Content-Type'], $options['_conditional']);
|
||||
$options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']);
|
||||
$options['_conditional']['Content-Type'] = 'application/json';
|
||||
}
|
||||
|
||||
@@ -385,47 +405,47 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||
&& $options['decode_content'] !== true
|
||||
) {
|
||||
// Ensure that we don't have the header in different case and set the new value.
|
||||
$options['_conditional'] = Psr7\Utils::caselessRemove(['Accept-Encoding'], $options['_conditional']);
|
||||
$options['_conditional'] = Psr7\_caseless_remove(['Accept-Encoding'], $options['_conditional']);
|
||||
$modify['set_headers']['Accept-Encoding'] = $options['decode_content'];
|
||||
}
|
||||
|
||||
if (isset($options['body'])) {
|
||||
if (\is_array($options['body'])) {
|
||||
throw $this->invalidBody();
|
||||
if (is_array($options['body'])) {
|
||||
$this->invalidBody();
|
||||
}
|
||||
$modify['body'] = Psr7\Utils::streamFor($options['body']);
|
||||
$modify['body'] = Psr7\stream_for($options['body']);
|
||||
unset($options['body']);
|
||||
}
|
||||
|
||||
if (!empty($options['auth']) && \is_array($options['auth'])) {
|
||||
if (!empty($options['auth']) && is_array($options['auth'])) {
|
||||
$value = $options['auth'];
|
||||
$type = isset($value[2]) ? \strtolower($value[2]) : 'basic';
|
||||
$type = isset($value[2]) ? strtolower($value[2]) : 'basic';
|
||||
switch ($type) {
|
||||
case 'basic':
|
||||
// Ensure that we don't have the header in different case and set the new value.
|
||||
$modify['set_headers'] = Psr7\Utils::caselessRemove(['Authorization'], $modify['set_headers']);
|
||||
$modify['set_headers'] = Psr7\_caseless_remove(['Authorization'], $modify['set_headers']);
|
||||
$modify['set_headers']['Authorization'] = 'Basic '
|
||||
.\base64_encode("$value[0]:$value[1]");
|
||||
. base64_encode("$value[0]:$value[1]");
|
||||
break;
|
||||
case 'digest':
|
||||
// @todo: Do not rely on curl
|
||||
$options['curl'][\CURLOPT_HTTPAUTH] = \CURLAUTH_DIGEST;
|
||||
$options['curl'][\CURLOPT_USERPWD] = "$value[0]:$value[1]";
|
||||
$options['curl'][CURLOPT_HTTPAUTH] = CURLAUTH_DIGEST;
|
||||
$options['curl'][CURLOPT_USERPWD] = "$value[0]:$value[1]";
|
||||
break;
|
||||
case 'ntlm':
|
||||
$options['curl'][\CURLOPT_HTTPAUTH] = \CURLAUTH_NTLM;
|
||||
$options['curl'][\CURLOPT_USERPWD] = "$value[0]:$value[1]";
|
||||
$options['curl'][CURLOPT_HTTPAUTH] = CURLAUTH_NTLM;
|
||||
$options['curl'][CURLOPT_USERPWD] = "$value[0]:$value[1]";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($options['query'])) {
|
||||
$value = $options['query'];
|
||||
if (\is_array($value)) {
|
||||
$value = \http_build_query($value, '', '&', \PHP_QUERY_RFC3986);
|
||||
if (is_array($value)) {
|
||||
$value = http_build_query($value, null, '&', PHP_QUERY_RFC3986);
|
||||
}
|
||||
if (!\is_string($value)) {
|
||||
throw new InvalidArgumentException('query must be a string or array');
|
||||
if (!is_string($value)) {
|
||||
throw new \InvalidArgumentException('query must be a string or array');
|
||||
}
|
||||
$modify['query'] = $value;
|
||||
unset($options['query']);
|
||||
@@ -434,22 +454,18 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||
// Ensure that sink is not an invalid value.
|
||||
if (isset($options['sink'])) {
|
||||
// TODO: Add more sink validation?
|
||||
if (\is_bool($options['sink'])) {
|
||||
throw new InvalidArgumentException('sink must not be a boolean');
|
||||
if (is_bool($options['sink'])) {
|
||||
throw new \InvalidArgumentException('sink must not be a boolean');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($options['version'])) {
|
||||
$modify['version'] = $options['version'];
|
||||
}
|
||||
|
||||
$request = Psr7\Utils::modifyRequest($request, $modify);
|
||||
$request = Psr7\modify_request($request, $modify);
|
||||
if ($request->getBody() instanceof Psr7\MultipartStream) {
|
||||
// Use a multipart/form-data POST if a Content-Type is not set.
|
||||
// Ensure that we don't have the header in different case and set the new value.
|
||||
$options['_conditional'] = Psr7\Utils::caselessRemove(['Content-Type'], $options['_conditional']);
|
||||
$options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']);
|
||||
$options['_conditional']['Content-Type'] = 'multipart/form-data; boundary='
|
||||
.$request->getBody()->getBoundary();
|
||||
. $request->getBody()->getBoundary();
|
||||
}
|
||||
|
||||
// Merge in conditional headers if they are not present.
|
||||
@@ -461,7 +477,7 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||
$modify['set_headers'][$k] = $v;
|
||||
}
|
||||
}
|
||||
$request = Psr7\Utils::modifyRequest($request, $modify);
|
||||
$request = Psr7\modify_request($request, $modify);
|
||||
// Don't pass this internal value along to middleware/handlers.
|
||||
unset($options['_conditional']);
|
||||
}
|
||||
@@ -470,14 +486,16 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an InvalidArgumentException with pre-set message.
|
||||
* Throw Exception with pre-set message.
|
||||
* @return void
|
||||
* @throws \InvalidArgumentException Invalid body.
|
||||
*/
|
||||
private function invalidBody(): InvalidArgumentException
|
||||
private function invalidBody()
|
||||
{
|
||||
return new InvalidArgumentException('Passing in the "body" request '
|
||||
.'option as an array to send a request is not supported. '
|
||||
.'Please use the "form_params" request option to send a '
|
||||
.'application/x-www-form-urlencoded request, or the "multipart" '
|
||||
.'request option to send a multipart/form-data request.');
|
||||
throw new \InvalidArgumentException('Passing in the "body" request '
|
||||
. 'option as an array to send a POST request has been deprecated. '
|
||||
. 'Please use the "form_params" request option to send a '
|
||||
. 'application/x-www-form-urlencoded request, or the "multipart" '
|
||||
. 'request option to send a multipart/form-data request.');
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user