提交服务端基础框架
This commit is contained in:
14
Server/vendor/alibabacloud/credentials/CHANGELOG.md
vendored
Executable file
14
Server/vendor/alibabacloud/credentials/CHANGELOG.md
vendored
Executable file
@@ -0,0 +1,14 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 1.1.3 - 2020-12-24
|
||||
|
||||
- Require guzzle ^6.3|^7.0
|
||||
|
||||
## 1.0.2 - 2020-02-14
|
||||
- Update Tea.
|
||||
|
||||
## 1.0.1 - 2019-12-30
|
||||
- Supported get `Role Name` automatically.
|
||||
|
||||
## 1.0.0 - 2019-09-01
|
||||
- Initial release of the Alibaba Cloud Credentials for PHP Version 1.0.0 on Packagist See <https://github.com/aliyun/credentials-php> for more information.
|
||||
30
Server/vendor/alibabacloud/credentials/CONTRIBUTING.md
vendored
Executable file
30
Server/vendor/alibabacloud/credentials/CONTRIBUTING.md
vendored
Executable file
@@ -0,0 +1,30 @@
|
||||
# CONTRIBUTING
|
||||
|
||||
We work hard to provide a high-quality and useful SDK for Alibaba Cloud, and
|
||||
we greatly value feedback and contributions from our community. Please submit
|
||||
your [issues][issues] or [pull requests][pull-requests] through GitHub.
|
||||
|
||||
## Tips
|
||||
|
||||
- The SDK is released under the [Apache license][license]. Any code you submit
|
||||
will be released under that license. For substantial contributions, we may
|
||||
ask you to sign a [Alibaba Documentation Corporate Contributor License
|
||||
Agreement (CLA)][cla].
|
||||
- We follow all of the relevant PSR recommendations from the [PHP Framework
|
||||
Interop Group][php-fig]. Please submit code that follows these standards.
|
||||
The [PHP CS Fixer][cs-fixer] tool can be helpful for formatting your code.
|
||||
Your can use `composer fixer` to fix code.
|
||||
- We maintain a high percentage of code coverage in our unit tests. If you make
|
||||
changes to the code, please add, update, and/or remove tests as appropriate.
|
||||
- If your code does not conform to the PSR standards, does not include adequate
|
||||
tests, or does not contain a changelog document, we may ask you to update
|
||||
your pull requests before we accept them. We also reserve the right to deny
|
||||
any pull requests that do not align with our standards or goals.
|
||||
|
||||
[issues]: https://github.com/aliyun/credentials-php/issues
|
||||
[pull-requests]: https://github.com/aliyun/credentials-php/pulls
|
||||
[license]: http://www.apache.org/licenses/LICENSE-2.0
|
||||
[cla]: https://alibaba-cla-2018.oss-cn-beijing.aliyuncs.com/Alibaba_Documentation_Open_Source_Corporate_CLA.pdf
|
||||
[php-fig]: http://php-fig.org
|
||||
[cs-fixer]: http://cs.sensiolabs.org/
|
||||
[docs-readme]: https://github.com/aliyun/credentials-php/blob/master/README.md
|
||||
13
Server/vendor/alibabacloud/credentials/LICENSE.md
vendored
Executable file
13
Server/vendor/alibabacloud/credentials/LICENSE.md
vendored
Executable file
@@ -0,0 +1,13 @@
|
||||
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
88
Server/vendor/alibabacloud/credentials/NOTICE.md
vendored
Executable file
88
Server/vendor/alibabacloud/credentials/NOTICE.md
vendored
Executable file
@@ -0,0 +1,88 @@
|
||||
# NOTICE
|
||||
|
||||
<https://www.alibabacloud.com/>
|
||||
|
||||
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License").
|
||||
You may not use this file except in compliance with the License.
|
||||
A copy of the License is located at
|
||||
|
||||
<http://www.apache.org/licenses/LICENSE-2.0>
|
||||
|
||||
or in the "license" file accompanying this file. This file is distributed
|
||||
on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
||||
express or implied. See the License for the specific language governing
|
||||
permissions and limitations under the License.
|
||||
|
||||
# Guzzle
|
||||
|
||||
<https://github.com/guzzle/guzzle>
|
||||
|
||||
Copyright (c) 2011-2018 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
# jmespath.php
|
||||
|
||||
<https://github.com/mtdowling/jmespath.php>
|
||||
|
||||
Copyright (c) 2014 Michael Dowling, https://github.com/mtdowling
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
# Dot
|
||||
|
||||
<https://github.com/adbario/php-dot-notation>
|
||||
|
||||
Copyright (c) 2016-2019 Riku Särkinen
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
250
Server/vendor/alibabacloud/credentials/README-zh-CN.md
vendored
Executable file
250
Server/vendor/alibabacloud/credentials/README-zh-CN.md
vendored
Executable file
@@ -0,0 +1,250 @@
|
||||
[English](/README.md) | 简体中文
|
||||
|
||||
|
||||
# Alibaba Cloud Credentials for 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 作为依赖项:
|
||||
```
|
||||
composer require alibabacloud/credentials
|
||||
```
|
||||
> 一些用户可能由于网络问题无法安装,可以使用[阿里云 Composer 全量镜像](https://developer.aliyun.com/composer)。
|
||||
|
||||
请看[安装](/docs/zh-CN/1-Installation.md)有关通过 Composer 和其他方式安装的详细信息。
|
||||
|
||||
|
||||
## 快速使用
|
||||
在您开始之前,您需要注册阿里云帐户并获取您的[凭证](https://usercenter.console.aliyun.com/#/manage/ak)。
|
||||
|
||||
### 凭证类型
|
||||
|
||||
#### AccessKey
|
||||
|
||||
通过[用户信息管理][ak]设置 access_key,它们具有该账户完全的权限,请妥善保管。有时出于安全考虑,您不能把具有完全访问权限的主账户 AccessKey 交于一个项目的开发者使用,您可以[创建RAM子账户][ram]并为子账户[授权][permissions],使用RAM子用户的 AccessKey 来进行API调用。
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
|
||||
// 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
|
||||
|
||||
通过安全令牌服务(Security Token Service,简称 STS),申请临时安全凭证(Temporary Security Credentials,简称 TSC),创建临时安全凭证。
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
|
||||
$sts = new Credential([
|
||||
'type' => 'sts',
|
||||
'access_key_id' => '<access_key_id>',
|
||||
'accessKey_secret' => '<accessKey_secret>',
|
||||
'security_token' => '<security_token>',
|
||||
]);
|
||||
$sts->getAccessKeyId();
|
||||
$sts->getAccessKeySecret();
|
||||
$sts->getSecurityToken();
|
||||
```
|
||||
|
||||
#### RamRoleArn
|
||||
|
||||
通过指定[RAM角色][RAM Role],让凭证自动申请维护 STS Token。你可以通过为 `Policy` 赋值来限制获取到的 STS Token 的权限。
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
|
||||
$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' => '',
|
||||
]);
|
||||
$ramRoleArn->getAccessKeyId();
|
||||
$ramRoleArn->getAccessKeySecret();
|
||||
$ramRoleArn->getRoleArn();
|
||||
$ramRoleArn->getRoleSessionName();
|
||||
$ramRoleArn->getPolicy();
|
||||
```
|
||||
|
||||
#### EcsRamRole
|
||||
|
||||
通过指定角色名称,让凭证自动申请维护 STS Token
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
|
||||
$ecsRamRole = new Credential([
|
||||
'type' => 'ecs_ram_role',
|
||||
'role_name' => '<role_name>',
|
||||
]);
|
||||
$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.
|
||||
```
|
||||
|
||||
#### RsaKeyPair
|
||||
|
||||
通过指定公钥Id和私钥文件,让凭证自动申请维护 AccessKey。仅支持日本站。
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
|
||||
$rsaKeyPair = new Credential([
|
||||
'type' => 'rsa_key_pair',
|
||||
'public_key_id' => '<public_key_id>',
|
||||
'private_key_file' => '<private_key_file>',
|
||||
]);
|
||||
$rsaKeyPair->getPublicKeyId();
|
||||
$rsaKeyPair->getPrivateKey();
|
||||
```
|
||||
|
||||
#### Bearer Token
|
||||
|
||||
如呼叫中心(CCC)需用此凭证,请自行申请维护 Bearer Token。
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
|
||||
$bearerToken = new Credential([
|
||||
'type' => 'bearer_token',
|
||||
'bearer_token' => '<bearer_token>',
|
||||
]);
|
||||
$bearerToken->getBearerToken();
|
||||
$bearerToken->getSignature();
|
||||
```
|
||||
|
||||
## 默认凭证提供程序链
|
||||
默认凭证提供程序链查找可用的凭证,寻找顺序如下:
|
||||
|
||||
### 1. 环境凭证
|
||||
程序首先会在环境变量里寻找环境凭证,如果定义了 `ALIBABA_CLOUD_ACCESS_KEY_ID` 和 `ALIBABA_CLOUD_ACCESS_KEY_SECRET` 环境变量且不为空,程序将使用他们创建默认凭证。
|
||||
|
||||
### 2. 配置文件
|
||||
> 如果用户主目录存在默认文件 `~/.alibabacloud/credentials` (Windows 为 `C:\Users\USER_NAME\.alibabacloud\credentials`),程序会自动创建指定类型和名称的凭证。默认文件可以不存在,但解析错误会抛出异常。 凭证名称不分大小写,若凭证同名,后者会覆盖前者。不同的项目、工具之间可以共用这个配置文件,因为超出项目之外,也不会被意外提交到版本控制。Windows 上可以使用环境变量引用到主目录 %UserProfile%。类 Unix 的系统可以使用环境变量 $HOME 或 ~ (tilde)。 可以通过定义 `ALIBABA_CLOUD_CREDENTIALS_FILE` 环境变量修改默认文件的路径。
|
||||
|
||||
```ini
|
||||
[default]
|
||||
type = access_key # 认证方式为 access_key
|
||||
access_key_id = foo # Key
|
||||
access_key_secret = bar # Secret
|
||||
|
||||
[project1]
|
||||
type = ecs_ram_role # 认证方式为 ecs_ram_role
|
||||
role_name = EcsRamRoleTest # Role Name,非必填,不填则自动获取,建议设置,可以减少网络请求。
|
||||
|
||||
[project2]
|
||||
type = ram_role_arn # 认证方式为 ram_role_arn
|
||||
access_key_id = foo
|
||||
access_key_secret = bar
|
||||
role_arn = role_arn
|
||||
role_session_name = session_name
|
||||
|
||||
[project3]
|
||||
type = rsa_key_pair # 认证方式为 rsa_key_pair
|
||||
public_key_id = publicKeyId # Public Key ID
|
||||
private_key_file = /your/pk.pem # Private Key 文件
|
||||
```
|
||||
|
||||
### 3. 实例 RAM 角色
|
||||
如果定义了环境变量 `ALIBABA_CLOUD_ECS_METADATA` 且不为空,程序会将该环境变量的值作为角色名称,请求 `http://100.100.100.200/latest/meta-data/ram/security-credentials/` 获取临时安全凭证作为默认凭证。
|
||||
|
||||
### 自定义凭证提供程序链
|
||||
可通过自定义程序链代替默认程序链的寻找顺序,也可以自行编写闭包传入提供者。
|
||||
```php
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Providers\ChainProvider;
|
||||
|
||||
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://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
|
||||
251
Server/vendor/alibabacloud/credentials/README.md
vendored
Executable file
251
Server/vendor/alibabacloud/credentials/README.md
vendored
Executable file
@@ -0,0 +1,251 @@
|
||||
English | [简体中文](/README-zh-CN.md)
|
||||
|
||||
|
||||
# Alibaba Cloud Credentials for 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
|
||||
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:
|
||||
```
|
||||
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
|
||||
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
|
||||
|
||||
#### 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.
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
|
||||
// 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
|
||||
|
||||
Create a temporary security credential by applying Temporary Security Credentials (TSC) through the Security Token Service (STS).
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
|
||||
$sts = new Credential([
|
||||
'type' => 'sts',
|
||||
'access_key_id' => '<access_key_id>',
|
||||
'accessKey_secret' => '<accessKey_secret>',
|
||||
'security_token' => '<security_token>',
|
||||
]);
|
||||
$sts->getAccessKeyId();
|
||||
$sts->getAccessKeySecret();
|
||||
$sts->getSecurityToken();
|
||||
```
|
||||
|
||||
#### RamRoleArn
|
||||
|
||||
By specifying [RAM Role][RAM Role], the credential will be able to automatically request maintenance of STS Token. If you want to limit the permissions([How to make a policy][policy]) of STS Token, you can assign value for `Policy`.
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
|
||||
$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' => '',
|
||||
]);
|
||||
$ramRoleArn->getAccessKeyId();
|
||||
$ramRoleArn->getAccessKeySecret();
|
||||
$ramRoleArn->getRoleArn();
|
||||
$ramRoleArn->getRoleSessionName();
|
||||
$ramRoleArn->getPolicy();
|
||||
```
|
||||
|
||||
#### EcsRamRole
|
||||
|
||||
By specifying the role name, the credential will be able to automatically request maintenance of STS Token.
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
|
||||
$ecsRamRole = new Credential([
|
||||
'type' => 'ecs_ram_role',
|
||||
'role_name' => '<role_name>',
|
||||
]);
|
||||
$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.
|
||||
```
|
||||
|
||||
#### 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.
|
||||
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
|
||||
$rsaKeyPair = new Credential([
|
||||
'type' => 'rsa_key_pair',
|
||||
'public_key_id' => '<public_key_id>',
|
||||
'private_key_file' => '<private_key_file>',
|
||||
]);
|
||||
$rsaKeyPair->getPublicKeyId();
|
||||
$rsaKeyPair->getPrivateKey();
|
||||
```
|
||||
|
||||
#### Bearer Token
|
||||
|
||||
If credential is required by the Cloud Call Centre (CCC), please apply for Bearer Token maintenance by yourself.
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use AlibabaCloud\Credentials\Credential;
|
||||
|
||||
$bearerToken = new Credential([
|
||||
'type' => 'bearer_token',
|
||||
'bearer_token' => '<bearer_token>',
|
||||
]);
|
||||
$bearerToken->getBearerToken();
|
||||
$bearerToken->getSignature();
|
||||
```
|
||||
|
||||
## Default credential provider chain
|
||||
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.
|
||||
|
||||
### 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.
|
||||
|
||||
```ini
|
||||
[default]
|
||||
type = access_key # Authentication method is access_key
|
||||
access_key_id = foo # Key
|
||||
access_key_secret = bar # Secret
|
||||
|
||||
[project1]
|
||||
type = ecs_ram_role # Authentication method is ecs_ram_role
|
||||
role_name = EcsRamRoleTest # Role name, optional. It will be retrieved automatically if not set. It is highly recommended to set it up to reduce requests.
|
||||
|
||||
[project2]
|
||||
type = ram_role_arn # Authentication method is ram_role_arn
|
||||
access_key_id = foo
|
||||
access_key_secret = bar
|
||||
role_arn = role_arn
|
||||
role_session_name = session_name
|
||||
|
||||
[project3]
|
||||
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
|
||||
```
|
||||
|
||||
### 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.
|
||||
|
||||
### 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
|
||||
|
||||
use AlibabaCloud\Credentials\Providers\ChainProvider;
|
||||
|
||||
ChainProvider::set(
|
||||
ChainProvider::ini(),
|
||||
ChainProvider::env(),
|
||||
ChainProvider::instance()
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
## Documentation
|
||||
* [Prerequisites](/docs/zh-CN/0-Prerequisites.md)
|
||||
* [Installation](/docs/zh-CN/1-Installation.md)
|
||||
|
||||
|
||||
## Issue
|
||||
[Submit Issue](https://github.com/aliyun/credentials-php/issues/new/choose), Problems that do not meet the guidelines may close immediately.
|
||||
|
||||
|
||||
## Release notes
|
||||
Detailed changes for each version are recorded in the [Release Notes](/CHANGELOG.md).
|
||||
|
||||
|
||||
## Contribution
|
||||
Please read the [Contribution Guide](/CONTRIBUTING.md) before submitting a Pull Request.
|
||||
|
||||
|
||||
## Related
|
||||
* [OpenAPI Developer Portal][open-api]
|
||||
* [Packagist][packagist]
|
||||
* [Composer][composer]
|
||||
* [Guzzle Doc][guzzle-docs]
|
||||
* [Latest Release][latest-release]
|
||||
|
||||
|
||||
## License
|
||||
[Apache-2.0](/LICENSE.md)
|
||||
|
||||
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
|
||||
|
||||
|
||||
[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
|
||||
21
Server/vendor/alibabacloud/credentials/SECURITY.md
vendored
Executable file
21
Server/vendor/alibabacloud/credentials/SECURITY.md
vendored
Executable file
@@ -0,0 +1,21 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
Use this section to tell people about which versions of your project are
|
||||
currently being supported with security updates.
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 5.1.x | :white_check_mark: |
|
||||
| 5.0.x | :x: |
|
||||
| 4.0.x | :white_check_mark: |
|
||||
| < 4.0 | :x: |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
Use this section to tell people how to report a vulnerability.
|
||||
|
||||
Tell them where to go, how often they can expect to get an update on a
|
||||
reported vulnerability, what to expect if the vulnerability is accepted or
|
||||
declined, etc.
|
||||
6
Server/vendor/alibabacloud/credentials/UPGRADING.md
vendored
Executable file
6
Server/vendor/alibabacloud/credentials/UPGRADING.md
vendored
Executable file
@@ -0,0 +1,6 @@
|
||||
Upgrading Guide
|
||||
===============
|
||||
|
||||
1.x
|
||||
-----------------------
|
||||
- This is the first version. See <https://github.com/aliyun/credentials-php> for more information.
|
||||
104
Server/vendor/alibabacloud/credentials/composer.json
vendored
Executable file
104
Server/vendor/alibabacloud/credentials/composer.json
vendored
Executable file
@@ -0,0 +1,104 @@
|
||||
{
|
||||
"name": "alibabacloud/credentials",
|
||||
"homepage": "https://www.alibabacloud.com/",
|
||||
"description": "Alibaba Cloud Credentials for PHP",
|
||||
"keywords": [
|
||||
"sdk",
|
||||
"tool",
|
||||
"cloud",
|
||||
"client",
|
||||
"aliyun",
|
||||
"library",
|
||||
"alibaba",
|
||||
"Credentials",
|
||||
"alibabacloud"
|
||||
],
|
||||
"type": "library",
|
||||
"license": "Apache-2.0",
|
||||
"support": {
|
||||
"source": "https://github.com/aliyun/credentials-php",
|
||||
"issues": "https://github.com/aliyun/credentials-php/issues"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Alibaba Cloud SDK",
|
||||
"email": "sdk-team@alibabacloud.com",
|
||||
"homepage": "http://www.alibabacloud.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.6",
|
||||
"ext-curl": "*",
|
||||
"ext-json": "*",
|
||||
"ext-libxml": "*",
|
||||
"ext-openssl": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-simplexml": "*",
|
||||
"ext-xmlwriter": "*",
|
||||
"guzzlehttp/guzzle": "^6.3|^7.0",
|
||||
"adbario/php-dot-notation": "^2.2",
|
||||
"alibabacloud/tea": "^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-spl": "*",
|
||||
"ext-dom": "*",
|
||||
"ext-pcre": "*",
|
||||
"psr/cache": "^1.0",
|
||||
"ext-sockets": "*",
|
||||
"drupal/coder": "^8.3",
|
||||
"symfony/dotenv": "^3.4",
|
||||
"phpunit/phpunit": "^4.8.35|^5.4.3",
|
||||
"monolog/monolog": "^1.24",
|
||||
"composer/composer": "^1.8",
|
||||
"mikey179/vfsstream": "^1.6",
|
||||
"symfony/var-dumper": "^3.4"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-sockets": "To use client-side monitoring"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"AlibabaCloud\\Credentials\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"AlibabaCloud\\Credentials\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"preferred-install": "dist",
|
||||
"optimize-autoloader": true
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"scripts-descriptions": {
|
||||
"cs": "Tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard.",
|
||||
"cbf": "Automatically correct coding standard violations.",
|
||||
"fixer": "Fixes code to follow standards.",
|
||||
"test": "Run all tests.",
|
||||
"unit": "Run Unit tests.",
|
||||
"feature": "Run Feature tests.",
|
||||
"clearCache": "Clear cache like coverage.",
|
||||
"coverage": "Show Coverage html.",
|
||||
"endpoints": "Update endpoints from OSS."
|
||||
},
|
||||
"scripts": {
|
||||
"cs": "phpcs --standard=PSR2 -n ./",
|
||||
"cbf": "phpcbf --standard=PSR2 -n ./",
|
||||
"fixer": "php-cs-fixer fix ./",
|
||||
"test": [
|
||||
"phpunit --colors=always"
|
||||
],
|
||||
"unit": [
|
||||
"@clearCache",
|
||||
"phpunit --testsuite=Unit --colors=always"
|
||||
],
|
||||
"feature": [
|
||||
"@clearCache",
|
||||
"phpunit --testsuite=Feature --colors=always"
|
||||
],
|
||||
"coverage": "open cache/coverage/index.html",
|
||||
"clearCache": "rm -rf cache/*"
|
||||
}
|
||||
}
|
||||
72
Server/vendor/alibabacloud/credentials/src/AccessKeyCredential.php
vendored
Executable file
72
Server/vendor/alibabacloud/credentials/src/AccessKeyCredential.php
vendored
Executable file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use AlibabaCloud\Credentials\Signature\ShaHmac1Signature;
|
||||
|
||||
/**
|
||||
* Use the AccessKey to complete the authentication.
|
||||
*/
|
||||
class AccessKeyCredential implements CredentialsInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $accessKeyId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $accessKeySecret;
|
||||
|
||||
/**
|
||||
* AccessKeyCredential constructor.
|
||||
*
|
||||
* @param string $access_key_id Access key ID
|
||||
* @param string $access_key_secret Access Key Secret
|
||||
*/
|
||||
public function __construct($access_key_id, $access_key_secret)
|
||||
{
|
||||
Filter::accessKey($access_key_id, $access_key_secret);
|
||||
|
||||
$this->accessKeyId = $access_key_id;
|
||||
$this->accessKeySecret = $access_key_secret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAccessKeyId()
|
||||
{
|
||||
return $this->accessKeyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAccessKeySecret()
|
||||
{
|
||||
return $this->accessKeySecret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "$this->accessKeyId#$this->accessKeySecret";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ShaHmac1Signature
|
||||
*/
|
||||
public function getSignature()
|
||||
{
|
||||
return new ShaHmac1Signature();
|
||||
}
|
||||
|
||||
public function getSecurityToken()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
53
Server/vendor/alibabacloud/credentials/src/BearerTokenCredential.php
vendored
Executable file
53
Server/vendor/alibabacloud/credentials/src/BearerTokenCredential.php
vendored
Executable file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use AlibabaCloud\Credentials\Signature\BearerTokenSignature;
|
||||
|
||||
/**
|
||||
* Class BearerTokenCredential
|
||||
*/
|
||||
class BearerTokenCredential implements CredentialsInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $bearerToken;
|
||||
|
||||
/**
|
||||
* BearerTokenCredential constructor.
|
||||
*
|
||||
* @param $bearerToken
|
||||
*/
|
||||
public function __construct($bearerToken)
|
||||
{
|
||||
Filter::bearerToken($bearerToken);
|
||||
|
||||
$this->bearerToken = $bearerToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBearerToken()
|
||||
{
|
||||
return $this->bearerToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "bearerToken#$this->bearerToken";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BearerTokenSignature
|
||||
*/
|
||||
public function getSignature()
|
||||
{
|
||||
return new BearerTokenSignature();
|
||||
}
|
||||
}
|
||||
182
Server/vendor/alibabacloud/credentials/src/Credential.php
vendored
Executable file
182
Server/vendor/alibabacloud/credentials/src/Credential.php
vendored
Executable file
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use AlibabaCloud\Credentials\Credential\Config;
|
||||
use InvalidArgumentException;
|
||||
use ReflectionClass;
|
||||
use ReflectionException;
|
||||
use ReflectionParameter;
|
||||
|
||||
/**
|
||||
* Class Credential
|
||||
*
|
||||
* @package AlibabaCloud\Credentials
|
||||
*
|
||||
* @mixin AccessKeyCredential
|
||||
* @mixin BearerTokenCredential
|
||||
* @mixin EcsRamRoleCredential
|
||||
* @mixin RamRoleArnCredential
|
||||
* @mixin RsaKeyPairCredential
|
||||
*/
|
||||
class Credential
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $config = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
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 AccessKeyCredential|BearerTokenCredential|EcsRamRoleCredential|RamRoleArnCredential|RsaKeyPairCredential
|
||||
*/
|
||||
protected $credential;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* Credential constructor.
|
||||
*
|
||||
* @param array|Config $config
|
||||
*
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function __construct($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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Config $config
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function parse($config)
|
||||
{
|
||||
$config = get_object_vars($config);
|
||||
$res = [];
|
||||
foreach ($config as $key => $value) {
|
||||
$res[$this->toUnderScore($key)] = $value;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
private function toUnderScore($str)
|
||||
{
|
||||
$dstr = preg_replace_callback('/([A-Z]+)/', function ($matchs) {
|
||||
return '_' . strtolower($matchs[0]);
|
||||
}, $str);
|
||||
return trim(preg_replace('/_{2,}/', '_', $dstr), '_');
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param array $arguments
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($name, $arguments)
|
||||
{
|
||||
return $this->credential->$name($arguments);
|
||||
}
|
||||
}
|
||||
50
Server/vendor/alibabacloud/credentials/src/Credential/Config.php
vendored
Executable file
50
Server/vendor/alibabacloud/credentials/src/Credential/Config.php
vendored
Executable file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Credential;
|
||||
|
||||
class Config
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'default';
|
||||
|
||||
public $accessKeyId = "";
|
||||
|
||||
public $accessKeySecret = "";
|
||||
|
||||
public $securityToken = "";
|
||||
|
||||
public $bearerToken = "";
|
||||
|
||||
public $roleName = "";
|
||||
|
||||
public $roleArn = "";
|
||||
|
||||
public $roleSessionName = "";
|
||||
|
||||
public $host = "";
|
||||
|
||||
public $publicKeyId = "";
|
||||
|
||||
public $privateKeyFile = "";
|
||||
|
||||
public $readTimeout = 0;
|
||||
|
||||
public $connectTimeout = 0;
|
||||
|
||||
public $certFile = "";
|
||||
|
||||
public $certPassword = "";
|
||||
|
||||
public $proxy = "";
|
||||
|
||||
public $expiration = 0;
|
||||
|
||||
public function __construct($config)
|
||||
{
|
||||
foreach ($config as $k => $v) {
|
||||
$this->{$k} = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
102
Server/vendor/alibabacloud/credentials/src/Credentials.php
vendored
Executable file
102
Server/vendor/alibabacloud/credentials/src/Credentials.php
vendored
Executable file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use AlibabaCloud\Credentials\Providers\ChainProvider;
|
||||
use ReflectionException;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Class Credentials
|
||||
*
|
||||
* @package AlibabaCloud\Credentials
|
||||
*/
|
||||
class Credentials
|
||||
{
|
||||
use MockTrait;
|
||||
|
||||
/**
|
||||
* @var array|CredentialsInterface[] containers of credentials
|
||||
*/
|
||||
protected static $credentials = [];
|
||||
|
||||
/**
|
||||
* Get the credential instance by name.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return Credential
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public static function get($name = null)
|
||||
{
|
||||
if ($name !== null) {
|
||||
Filter::credentialName($name);
|
||||
} else {
|
||||
$name = ChainProvider::getDefaultName();
|
||||
}
|
||||
|
||||
self::load();
|
||||
|
||||
if (self::has($name)) {
|
||||
return new Credential(self::$credentials[\strtolower($name)]);
|
||||
}
|
||||
|
||||
throw new RuntimeException("Credential '$name' not found");
|
||||
}
|
||||
|
||||
private static function load()
|
||||
{
|
||||
if (self::$credentials) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ChainProvider::hasCustomChain()) {
|
||||
ChainProvider::customProvider(ChainProvider::getDefaultName());
|
||||
} else {
|
||||
ChainProvider::defaultProvider(ChainProvider::getDefaultName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether there is a credential.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function has($name)
|
||||
{
|
||||
Filter::credentialName($name);
|
||||
|
||||
return isset(self::$credentials[\strtolower($name)]);
|
||||
}
|
||||
|
||||
public static function flush()
|
||||
{
|
||||
self::$credentials = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all credentials.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function all()
|
||||
{
|
||||
self::load();
|
||||
|
||||
return self::$credentials;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param array $credential
|
||||
*/
|
||||
public static function set($name, array $credential)
|
||||
{
|
||||
Filter::credentialName($name);
|
||||
|
||||
self::$credentials[\strtolower($name)] = \array_change_key_case($credential);
|
||||
}
|
||||
}
|
||||
23
Server/vendor/alibabacloud/credentials/src/CredentialsInterface.php
vendored
Executable file
23
Server/vendor/alibabacloud/credentials/src/CredentialsInterface.php
vendored
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use AlibabaCloud\Credentials\Signature\SignatureInterface;
|
||||
|
||||
/**
|
||||
* Interface CredentialsInterface
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
interface CredentialsInterface
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString();
|
||||
|
||||
/**
|
||||
* @return SignatureInterface
|
||||
*/
|
||||
public function getSignature();
|
||||
}
|
||||
151
Server/vendor/alibabacloud/credentials/src/EcsRamRoleCredential.php
vendored
Executable file
151
Server/vendor/alibabacloud/credentials/src/EcsRamRoleCredential.php
vendored
Executable file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use AlibabaCloud\Credentials\Providers\EcsRamRoleProvider;
|
||||
use AlibabaCloud\Credentials\Request\Request;
|
||||
use AlibabaCloud\Credentials\Signature\ShaHmac1Signature;
|
||||
use Exception;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Use the RAM role of an ECS instance to complete the authentication.
|
||||
*/
|
||||
class EcsRamRoleCredential implements CredentialsInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $roleName;
|
||||
|
||||
/**
|
||||
* EcsRamRoleCredential constructor.
|
||||
*
|
||||
* @param $role_name
|
||||
*/
|
||||
public function __construct($role_name = null)
|
||||
{
|
||||
Filter::roleName($role_name);
|
||||
|
||||
$this->roleName = $role_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getRoleName()
|
||||
{
|
||||
if ($this->roleName !== null) {
|
||||
return $this->roleName;
|
||||
}
|
||||
|
||||
$this->roleName = $this->getRoleNameFromMeta();
|
||||
|
||||
return $this->roleName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getRoleNameFromMeta()
|
||||
{
|
||||
$options = [
|
||||
'http_errors' => false,
|
||||
'timeout' => 1,
|
||||
'connect_timeout' => 1,
|
||||
];
|
||||
|
||||
$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');
|
||||
}
|
||||
|
||||
if ($result->getStatusCode() !== 200) {
|
||||
throw new RuntimeException('Error retrieving credentials from result: ' . $result->getBody());
|
||||
}
|
||||
|
||||
$role_name = (string)$result;
|
||||
if (!$role_name) {
|
||||
throw new RuntimeException('Error retrieving credentials from result is empty');
|
||||
}
|
||||
|
||||
return $role_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "roleName#$this->roleName";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ShaHmac1Signature
|
||||
*/
|
||||
public function getSignature()
|
||||
{
|
||||
return new ShaHmac1Signature();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getAccessKeyId()
|
||||
{
|
||||
return $this->getSessionCredential()->getAccessKeyId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return StsCredential
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
protected function getSessionCredential()
|
||||
{
|
||||
return (new EcsRamRoleProvider($this))->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getAccessKeySecret()
|
||||
{
|
||||
return $this->getSessionCredential()->getAccessKeySecret();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getSecurityToken()
|
||||
{
|
||||
return $this->getSessionCredential()->getSecurityToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getExpiration()
|
||||
{
|
||||
return $this->getSessionCredential()->getExpiration();
|
||||
}
|
||||
}
|
||||
134
Server/vendor/alibabacloud/credentials/src/Filter.php
vendored
Executable file
134
Server/vendor/alibabacloud/credentials/src/Filter.php
vendored
Executable 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');
|
||||
}
|
||||
}
|
||||
}
|
||||
202
Server/vendor/alibabacloud/credentials/src/Helper.php
vendored
Executable file
202
Server/vendor/alibabacloud/credentials/src/Helper.php
vendored
Executable file
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use Closure;
|
||||
|
||||
/**
|
||||
* Class Helper
|
||||
*
|
||||
* @package AlibabaCloud\Credentials
|
||||
*/
|
||||
class Helper
|
||||
{
|
||||
/**
|
||||
* @param array $arrays
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function merge(array $arrays)
|
||||
{
|
||||
$result = [];
|
||||
foreach ($arrays as $array) {
|
||||
foreach ($array as $key => $value) {
|
||||
if (is_int($key)) {
|
||||
$result[] = $value;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($result[$key]) && is_array($result[$key])) {
|
||||
$result[$key] = self::merge(
|
||||
[$result[$key], $value]
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
$result[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $filename
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function inOpenBasedir($filename)
|
||||
{
|
||||
$open_basedir = ini_get('open_basedir');
|
||||
if (!$open_basedir) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$dirs = explode(PATH_SEPARATOR, $open_basedir);
|
||||
|
||||
return empty($dirs) || self::inDir($filename, $dirs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filename
|
||||
* @param array $dirs
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function inDir($filename, array $dirs)
|
||||
{
|
||||
foreach ($dirs as $dir) {
|
||||
if ($dir[strlen($dir) - 1] !== DIRECTORY_SEPARATOR) {
|
||||
$dir .= DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
if (0 === strpos($filename, $dir)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public static function isWindows()
|
||||
{
|
||||
return PATH_SEPARATOR === ';';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
*
|
||||
* @return bool|mixed
|
||||
*/
|
||||
public static function envNotEmpty($key)
|
||||
{
|
||||
$value = self::env($key, false);
|
||||
if ($value) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of an environment variable.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $default
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function env($key, $default = null)
|
||||
{
|
||||
$value = getenv($key);
|
||||
|
||||
if ($value === false) {
|
||||
return self::value($default);
|
||||
}
|
||||
|
||||
if (self::envSubstr($value)) {
|
||||
return substr($value, 1, -1);
|
||||
}
|
||||
|
||||
return self::envConversion($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default value of the given value.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function value($value)
|
||||
{
|
||||
return $value instanceof Closure ? $value() : $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function envSubstr($value)
|
||||
{
|
||||
return ($valueLength = strlen($value)) > 1
|
||||
&& strpos($value, '"') === 0
|
||||
&& $value[$valueLength - 1] === '"';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*
|
||||
* @return bool|string|null
|
||||
*/
|
||||
public static function envConversion($value)
|
||||
{
|
||||
$key = strtolower($value);
|
||||
|
||||
if ($key === 'null' || $key === '(null)') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$list = [
|
||||
'true' => true,
|
||||
'(true)' => true,
|
||||
'false' => false,
|
||||
'(false)' => false,
|
||||
'empty' => '',
|
||||
'(empty)' => '',
|
||||
];
|
||||
|
||||
return isset($list[$key]) ? $list[$key] : $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the environment's HOME directory.
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public static function getHomeDirectory()
|
||||
{
|
||||
if (getenv('HOME')) {
|
||||
return getenv('HOME');
|
||||
}
|
||||
|
||||
return (getenv('HOMEDRIVE') && getenv('HOMEPATH'))
|
||||
? getenv('HOMEDRIVE') . getenv('HOMEPATH')
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed ...$parameters
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public static function dd(...$parameters)
|
||||
{
|
||||
dump(...$parameters);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
98
Server/vendor/alibabacloud/credentials/src/MockTrait.php
vendored
Executable file
98
Server/vendor/alibabacloud/credentials/src/MockTrait.php
vendored
Executable file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use Exception;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use GuzzleHttp\Handler\MockHandler;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
/**
|
||||
* Trait MockTrait
|
||||
*
|
||||
* @package AlibabaCloud\Credentials
|
||||
*/
|
||||
trait MockTrait
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private static $mockQueue = [];
|
||||
|
||||
/**
|
||||
* @var MockHandler
|
||||
*/
|
||||
private static $mock;
|
||||
|
||||
/**
|
||||
* @param integer $status
|
||||
* @param array $headers
|
||||
* @param array|string|object $body
|
||||
*/
|
||||
public static function mockResponse($status = 200, array $headers = [], $body = null)
|
||||
{
|
||||
if (is_array($body) || is_object($body)) {
|
||||
$body = json_encode($body);
|
||||
}
|
||||
|
||||
self::$mockQueue[] = new Response($status, $headers, $body);
|
||||
self::createHandlerStack();
|
||||
}
|
||||
|
||||
private static function createHandlerStack()
|
||||
{
|
||||
self::$mock = new MockHandler(self::$mockQueue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
* @param RequestInterface $request
|
||||
* @param ResponseInterface|null $response
|
||||
* @param Exception|null $previous
|
||||
* @param array $handlerContext
|
||||
*/
|
||||
public static function mockRequestException(
|
||||
$message,
|
||||
RequestInterface $request,
|
||||
ResponseInterface $response = null,
|
||||
Exception $previous = null,
|
||||
array $handlerContext = []
|
||||
) {
|
||||
self::$mockQueue[] = new RequestException(
|
||||
$message,
|
||||
$request,
|
||||
$response,
|
||||
$previous,
|
||||
$handlerContext
|
||||
);
|
||||
|
||||
self::createHandlerStack();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public static function cancelMock()
|
||||
{
|
||||
self::$mockQueue = [];
|
||||
self::$mock = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public static function hasMock()
|
||||
{
|
||||
return (bool)self::$mockQueue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MockHandler
|
||||
*/
|
||||
public static function getMock()
|
||||
{
|
||||
return self::$mock;
|
||||
}
|
||||
}
|
||||
187
Server/vendor/alibabacloud/credentials/src/Providers/ChainProvider.php
vendored
Executable file
187
Server/vendor/alibabacloud/credentials/src/Providers/ChainProvider.php
vendored
Executable file
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Providers;
|
||||
|
||||
use AlibabaCloud\Credentials\Credentials;
|
||||
use AlibabaCloud\Credentials\Helper;
|
||||
use Closure;
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Class ChainProvider
|
||||
*
|
||||
* @package AlibabaCloud\Credentials\Providers
|
||||
*/
|
||||
class ChainProvider
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private static $customChains;
|
||||
|
||||
/**
|
||||
* @param callable ...$providers
|
||||
*/
|
||||
public static function set(...$providers)
|
||||
{
|
||||
if (empty($providers)) {
|
||||
throw new InvalidArgumentException('No providers in chain');
|
||||
}
|
||||
|
||||
foreach ($providers as $provider) {
|
||||
if (!$provider instanceof Closure) {
|
||||
throw new InvalidArgumentException('Providers must all be Closures');
|
||||
}
|
||||
}
|
||||
|
||||
self::$customChains = $providers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public static function hasCustomChain()
|
||||
{
|
||||
return (bool)self::$customChains;
|
||||
}
|
||||
|
||||
public static function flush()
|
||||
{
|
||||
self::$customChains = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public static function customProvider($name)
|
||||
{
|
||||
foreach (self::$customChains as $provider) {
|
||||
$provider();
|
||||
|
||||
if (Credentials::has($name)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public static function defaultProvider($name)
|
||||
{
|
||||
$providers = [
|
||||
self::env(),
|
||||
self::ini(),
|
||||
self::instance(),
|
||||
];
|
||||
|
||||
foreach ($providers as $provider) {
|
||||
$provider();
|
||||
|
||||
if (Credentials::has($name)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Closure
|
||||
*/
|
||||
public static function env()
|
||||
{
|
||||
return static function () {
|
||||
$accessKeyId = Helper::envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_ID');
|
||||
$accessKeySecret = Helper::envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_SECRET');
|
||||
|
||||
if ($accessKeyId && $accessKeySecret) {
|
||||
Credentials::set(
|
||||
self::getDefaultName(),
|
||||
[
|
||||
'type' => 'access_key',
|
||||
'access_key_id' => $accessKeyId,
|
||||
'access_key_secret' => $accessKeySecret,
|
||||
]
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getDefaultName()
|
||||
{
|
||||
$name = Helper::envNotEmpty('ALIBABA_CLOUD_PROFILE');
|
||||
|
||||
if ($name) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
return 'default';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Closure
|
||||
*/
|
||||
public static function ini()
|
||||
{
|
||||
return static function () {
|
||||
$filename = Helper::envNotEmpty('ALIBABA_CLOUD_CREDENTIALS_FILE');
|
||||
if (!$filename) {
|
||||
$filename = self::getDefaultFile();
|
||||
}
|
||||
|
||||
if (!Helper::inOpenBasedir($filename)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($filename !== self::getDefaultFile() && (!\is_readable($filename) || !\is_file($filename))) {
|
||||
throw new RuntimeException(
|
||||
'Credentials file is not readable: ' . $filename
|
||||
);
|
||||
}
|
||||
|
||||
$file_array = \parse_ini_file($filename, true);
|
||||
|
||||
if (\is_array($file_array) && !empty($file_array)) {
|
||||
foreach (\array_change_key_case($file_array) as $name => $configures) {
|
||||
Credentials::set($name, $configures);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default credential file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDefaultFile()
|
||||
{
|
||||
return Helper::getHomeDirectory() .
|
||||
DIRECTORY_SEPARATOR .
|
||||
'.alibabacloud' .
|
||||
DIRECTORY_SEPARATOR .
|
||||
'credentials';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Closure
|
||||
*/
|
||||
public static function instance()
|
||||
{
|
||||
return static function () {
|
||||
$instance = Helper::envNotEmpty('ALIBABA_CLOUD_ECS_METADATA');
|
||||
if ($instance) {
|
||||
Credentials::set(
|
||||
self::getDefaultName(),
|
||||
[
|
||||
'type' => 'ecs_ram_role',
|
||||
'role_name' => $instance,
|
||||
]
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
94
Server/vendor/alibabacloud/credentials/src/Providers/EcsRamRoleProvider.php
vendored
Executable file
94
Server/vendor/alibabacloud/credentials/src/Providers/EcsRamRoleProvider.php
vendored
Executable 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;
|
||||
}
|
||||
}
|
||||
82
Server/vendor/alibabacloud/credentials/src/Providers/Provider.php
vendored
Executable file
82
Server/vendor/alibabacloud/credentials/src/Providers/Provider.php
vendored
Executable 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;
|
||||
}
|
||||
}
|
||||
49
Server/vendor/alibabacloud/credentials/src/Providers/RamRoleArnProvider.php
vendored
Executable file
49
Server/vendor/alibabacloud/credentials/src/Providers/RamRoleArnProvider.php
vendored
Executable 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']
|
||||
);
|
||||
}
|
||||
}
|
||||
53
Server/vendor/alibabacloud/credentials/src/Providers/RsaKeyPairProvider.php
vendored
Executable file
53
Server/vendor/alibabacloud/credentials/src/Providers/RsaKeyPairProvider.php
vendored
Executable 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'])
|
||||
);
|
||||
}
|
||||
}
|
||||
218
Server/vendor/alibabacloud/credentials/src/RamRoleArnCredential.php
vendored
Executable file
218
Server/vendor/alibabacloud/credentials/src/RamRoleArnCredential.php
vendored
Executable file
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use AlibabaCloud\Credentials\Providers\RamRoleArnProvider;
|
||||
use AlibabaCloud\Credentials\Signature\ShaHmac1Signature;
|
||||
use Exception;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Use the AssumeRole of the RAM account to complete the authentication.
|
||||
*/
|
||||
class RamRoleArnCredential implements CredentialsInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $accessKeyId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $accessKeySecret;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $roleArn;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $roleSessionName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $policy;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* RamRoleArnCredential constructor.
|
||||
*
|
||||
* @param array $credential
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct(array $credential = [], array $config = [])
|
||||
{
|
||||
$this->filterParameters($credential);
|
||||
$this->filterPolicy($credential);
|
||||
|
||||
Filter::accessKey($credential['access_key_id'], $credential['access_key_secret']);
|
||||
|
||||
$this->config = $config;
|
||||
$this->accessKeyId = $credential['access_key_id'];
|
||||
$this->accessKeySecret = $credential['access_key_secret'];
|
||||
$this->roleArn = $credential['role_arn'];
|
||||
$this->roleSessionName = $credential['role_session_name'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $credential
|
||||
*/
|
||||
private function filterParameters(array $credential)
|
||||
{
|
||||
if (!isset($credential['access_key_id'])) {
|
||||
throw new InvalidArgumentException('Missing required access_key_id option in config for ram_role_arn');
|
||||
}
|
||||
|
||||
if (!isset($credential['access_key_secret'])) {
|
||||
throw new InvalidArgumentException('Missing required access_key_secret option in config for ram_role_arn');
|
||||
}
|
||||
|
||||
if (!isset($credential['role_arn'])) {
|
||||
throw new InvalidArgumentException('Missing required role_arn option in config for ram_role_arn');
|
||||
}
|
||||
|
||||
if (!isset($credential['role_session_name'])) {
|
||||
throw new InvalidArgumentException('Missing required role_session_name option in config for ram_role_arn');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $credential
|
||||
*/
|
||||
private function filterPolicy(array $credential)
|
||||
{
|
||||
if (isset($credential['policy'])) {
|
||||
if (is_string($credential['policy'])) {
|
||||
$this->policy = $credential['policy'];
|
||||
}
|
||||
|
||||
if (is_array($credential['policy'])) {
|
||||
$this->policy = json_encode($credential['policy']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRoleArn()
|
||||
{
|
||||
return $this->roleArn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRoleSessionName()
|
||||
{
|
||||
return $this->roleSessionName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPolicy()
|
||||
{
|
||||
return $this->policy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "$this->accessKeyId#$this->accessKeySecret#$this->roleArn#$this->roleSessionName";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ShaHmac1Signature
|
||||
*/
|
||||
public function getSignature()
|
||||
{
|
||||
return new ShaHmac1Signature();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOriginalAccessKeyId()
|
||||
{
|
||||
return $this->accessKeyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOriginalAccessKeySecret()
|
||||
{
|
||||
return $this->accessKeySecret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getAccessKeyId()
|
||||
{
|
||||
return $this->getSessionCredential()->getAccessKeyId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return StsCredential
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
protected function getSessionCredential()
|
||||
{
|
||||
return (new RamRoleArnProvider($this))->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getAccessKeySecret()
|
||||
{
|
||||
return $this->getSessionCredential()->getAccessKeySecret();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getSecurityToken()
|
||||
{
|
||||
return $this->getSessionCredential()->getSecurityToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getExpiration()
|
||||
{
|
||||
return $this->getSessionCredential()->getExpiration();
|
||||
}
|
||||
}
|
||||
37
Server/vendor/alibabacloud/credentials/src/Request/AssumeRole.php
vendored
Executable file
37
Server/vendor/alibabacloud/credentials/src/Request/AssumeRole.php
vendored
Executable 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
Executable file
33
Server/vendor/alibabacloud/credentials/src/Request/GenerateSessionAccessKey.php
vendored
Executable 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;
|
||||
}
|
||||
}
|
||||
155
Server/vendor/alibabacloud/credentials/src/Request/Request.php
vendored
Executable file
155
Server/vendor/alibabacloud/credentials/src/Request/Request.php
vendored
Executable file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Request;
|
||||
|
||||
use AlibabaCloud\Credentials\Credentials;
|
||||
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;
|
||||
|
||||
/**
|
||||
* RESTful RPC Request.
|
||||
*/
|
||||
class Request
|
||||
{
|
||||
|
||||
/**
|
||||
* Request Connect Timeout
|
||||
*/
|
||||
const CONNECT_TIMEOUT = 5;
|
||||
|
||||
/**
|
||||
* Request Timeout
|
||||
*/
|
||||
const TIMEOUT = 10;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private static $config = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $options = [];
|
||||
|
||||
/**
|
||||
* @var Uri
|
||||
*/
|
||||
public $uri;
|
||||
|
||||
/**
|
||||
* @var EcsRamRoleCredential|RamRoleArnCredential
|
||||
*/
|
||||
protected $credential;
|
||||
|
||||
/**
|
||||
* @var ShaHmac256WithRsaSignature|ShaHmac1Signature
|
||||
*/
|
||||
protected $signature;
|
||||
|
||||
/**
|
||||
* Request constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$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') {
|
||||
$this->options['debug'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $salt
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function uuid($salt)
|
||||
{
|
||||
return md5($salt . uniqid(md5(microtime(true)), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function signString($method, array $parameters)
|
||||
{
|
||||
ksort($parameters);
|
||||
$canonicalized = '';
|
||||
foreach ($parameters as $key => $value) {
|
||||
$canonicalized .= '&' . self::percentEncode($key) . '=' . self::percentEncode($value);
|
||||
}
|
||||
|
||||
return $method . '&%2F&' . self::percentEncode(substr($canonicalized, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $string
|
||||
*
|
||||
* @return null|string|string[]
|
||||
*/
|
||||
private static function percentEncode($string)
|
||||
{
|
||||
$result = rawurlencode($string);
|
||||
$result = str_replace(['+', '*'], ['%20', '%2A'], $result);
|
||||
$result = preg_replace('/%7E/', '~', $result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Client
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function createClient()
|
||||
{
|
||||
if (Credentials::hasMock()) {
|
||||
$stack = HandlerStack::create(Credentials::getMock());
|
||||
} else {
|
||||
$stack = HandlerStack::create();
|
||||
}
|
||||
|
||||
$stack->push(Middleware::mapResponse(static function (ResponseInterface $response) {
|
||||
return new Response($response);
|
||||
}));
|
||||
|
||||
self::$config['handler'] = $stack;
|
||||
|
||||
return new Client(self::$config);
|
||||
}
|
||||
}
|
||||
158
Server/vendor/alibabacloud/credentials/src/RsaKeyPairCredential.php
vendored
Executable file
158
Server/vendor/alibabacloud/credentials/src/RsaKeyPairCredential.php
vendored
Executable file
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use AlibabaCloud\Credentials\Providers\RsaKeyPairProvider;
|
||||
use AlibabaCloud\Credentials\Signature\ShaHmac1Signature;
|
||||
use Exception;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Use the RSA key pair to complete the authentication (supported only on Japanese site)
|
||||
*/
|
||||
class RsaKeyPairCredential implements CredentialsInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $publicKeyId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $privateKey;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* RsaKeyPairCredential constructor.
|
||||
*
|
||||
* @param string $public_key_id
|
||||
* @param string $private_key_file
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct($public_key_id, $private_key_file, array $config = [])
|
||||
{
|
||||
Filter::publicKeyId($public_key_id);
|
||||
Filter::privateKeyFile($private_key_file);
|
||||
|
||||
$this->publicKeyId = $public_key_id;
|
||||
$this->config = $config;
|
||||
try {
|
||||
$this->privateKey = file_get_contents($private_key_file);
|
||||
} catch (Exception $exception) {
|
||||
throw new InvalidArgumentException($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOriginalAccessKeyId()
|
||||
{
|
||||
return $this->getPublicKeyId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPublicKeyId()
|
||||
{
|
||||
return $this->publicKeyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOriginalAccessKeySecret()
|
||||
{
|
||||
return $this->getPrivateKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPrivateKey()
|
||||
{
|
||||
return $this->privateKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return "publicKeyId#$this->publicKeyId";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ShaHmac1Signature
|
||||
*/
|
||||
public function getSignature()
|
||||
{
|
||||
return new ShaHmac1Signature();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getAccessKeyId()
|
||||
{
|
||||
return $this->getSessionCredential()->getAccessKeyId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return StsCredential
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
protected function getSessionCredential()
|
||||
{
|
||||
return (new RsaKeyPairProvider($this))->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getAccessKeySecret()
|
||||
{
|
||||
return $this->getSessionCredential()->getAccessKeySecret();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getSecurityToken()
|
||||
{
|
||||
return $this->getSessionCredential()->getSecurityToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getExpiration()
|
||||
{
|
||||
return $this->getSessionCredential()->getExpiration();
|
||||
}
|
||||
}
|
||||
47
Server/vendor/alibabacloud/credentials/src/Signature/BearerTokenSignature.php
vendored
Executable file
47
Server/vendor/alibabacloud/credentials/src/Signature/BearerTokenSignature.php
vendored
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Signature;
|
||||
|
||||
/**
|
||||
* Class BearerTokenSignature
|
||||
*
|
||||
* @package AlibabaCloud\Credentials\Signature
|
||||
*/
|
||||
class BearerTokenSignature implements SignatureInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return 'BEARERTOKEN';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getVersion()
|
||||
{
|
||||
return '1.0';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $string
|
||||
* @param string $accessKeySecret
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function sign($string, $accessKeySecret)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
47
Server/vendor/alibabacloud/credentials/src/Signature/ShaHmac1Signature.php
vendored
Executable file
47
Server/vendor/alibabacloud/credentials/src/Signature/ShaHmac1Signature.php
vendored
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Signature;
|
||||
|
||||
/**
|
||||
* Class ShaHmac1Signature
|
||||
*
|
||||
* @package AlibabaCloud\Credentials\Signature
|
||||
*/
|
||||
class ShaHmac1Signature implements SignatureInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
return 'HMAC-SHA1';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getVersion()
|
||||
{
|
||||
return '1.0';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $string
|
||||
* @param string $accessKeySecret
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function sign($string, $accessKeySecret)
|
||||
{
|
||||
return base64_encode(hash_hmac('sha1', $string, $accessKeySecret, true));
|
||||
}
|
||||
}
|
||||
47
Server/vendor/alibabacloud/credentials/src/Signature/ShaHmac256Signature.php
vendored
Executable file
47
Server/vendor/alibabacloud/credentials/src/Signature/ShaHmac256Signature.php
vendored
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Signature;
|
||||
|
||||
/**
|
||||
* Class ShaHmac256Signature
|
||||
*
|
||||
* @package AlibabaCloud\Credentials\Signature
|
||||
*/
|
||||
class ShaHmac256Signature implements SignatureInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
return 'HMAC-SHA256';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getVersion()
|
||||
{
|
||||
return '1.0';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $string
|
||||
* @param string $accessKeySecret
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function sign($string, $accessKeySecret)
|
||||
{
|
||||
return base64_encode(hash_hmac('sha256', $string, $accessKeySecret, true));
|
||||
}
|
||||
}
|
||||
64
Server/vendor/alibabacloud/credentials/src/Signature/ShaHmac256WithRsaSignature.php
vendored
Executable file
64
Server/vendor/alibabacloud/credentials/src/Signature/ShaHmac256WithRsaSignature.php
vendored
Executable file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Signature;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Class ShaHmac256WithRsaSignature
|
||||
*
|
||||
* @package AlibabaCloud\Credentials\Signature
|
||||
*/
|
||||
class ShaHmac256WithRsaSignature implements SignatureInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
return 'SHA256withRSA';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return 'PRIVATEKEY';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getVersion()
|
||||
{
|
||||
return '1.0';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $string
|
||||
* @param string $privateKey
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function sign($string, $privateKey)
|
||||
{
|
||||
$binarySignature = '';
|
||||
try {
|
||||
openssl_sign(
|
||||
$string,
|
||||
$binarySignature,
|
||||
$privateKey,
|
||||
\OPENSSL_ALGO_SHA256
|
||||
);
|
||||
} catch (Exception $exception) {
|
||||
throw new InvalidArgumentException(
|
||||
$exception->getMessage()
|
||||
);
|
||||
}
|
||||
|
||||
return base64_encode($binarySignature);
|
||||
}
|
||||
}
|
||||
34
Server/vendor/alibabacloud/credentials/src/Signature/SignatureInterface.php
vendored
Executable file
34
Server/vendor/alibabacloud/credentials/src/Signature/SignatureInterface.php
vendored
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials\Signature;
|
||||
|
||||
/**
|
||||
* Interface SignatureInterface
|
||||
*
|
||||
* @package AlibabaCloud\Credentials\Signature
|
||||
*/
|
||||
interface SignatureInterface
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMethod();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getVersion();
|
||||
|
||||
/**
|
||||
* @param string $string
|
||||
* @param string $accessKeySecret
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function sign($string, $accessKeySecret);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType();
|
||||
}
|
||||
98
Server/vendor/alibabacloud/credentials/src/StsCredential.php
vendored
Executable file
98
Server/vendor/alibabacloud/credentials/src/StsCredential.php
vendored
Executable file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace AlibabaCloud\Credentials;
|
||||
|
||||
use AlibabaCloud\Credentials\Signature\ShaHmac1Signature;
|
||||
|
||||
/**
|
||||
* Use the STS Token to complete the authentication.
|
||||
*/
|
||||
class StsCredential implements CredentialsInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $accessKeyId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $accessKeySecret;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $securityToken;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $expiration;
|
||||
|
||||
/**
|
||||
* StsCredential constructor.
|
||||
*
|
||||
* @param string $access_key_id Access key ID
|
||||
* @param string $access_key_secret Access Key Secret
|
||||
* @param int $expiration
|
||||
* @param string $security_token Security Token
|
||||
*/
|
||||
public function __construct($access_key_id, $access_key_secret, $expiration, $security_token = '')
|
||||
{
|
||||
Filter::accessKey($access_key_id, $access_key_secret);
|
||||
Filter::expiration($expiration);
|
||||
$this->accessKeyId = $access_key_id;
|
||||
$this->accessKeySecret = $access_key_secret;
|
||||
$this->expiration = $expiration;
|
||||
$this->securityToken = $security_token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getExpiration()
|
||||
{
|
||||
return $this->expiration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 __toString()
|
||||
{
|
||||
return "$this->accessKeyId#$this->accessKeySecret#$this->securityToken";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ShaHmac1Signature
|
||||
*/
|
||||
public function getSignature()
|
||||
{
|
||||
return new ShaHmac1Signature();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user