Download the PHP package alibabacloud/credentials without Composer
On this page you can find all versions of the php package alibabacloud/credentials. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alibabacloud/credentials
More information about alibabacloud/credentials
Files in alibabacloud/credentials
Package credentials
Short Description Alibaba Cloud Credentials for PHP
License Apache-2.0
Homepage https://www.alibabacloud.com/
Informations about the package credentials
English | 简体中文
Alibaba Cloud Credentials for PHP
Alibaba Cloud Credentials for PHP is a tool that helps PHP developers manage their credentials.
Prerequisites
Your system needs to meet Prerequisites, 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 on your system, install Alibaba Cloud Credentials for PHP as a dependency by running the following directly in the project directory:
Some users may not be able to install due to network problems, you can switch to the Alibaba Cloud Composer Mirror.
See Installation 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.
Credential Type
Default credential provider chain
If you do not specify a method to initialize a Credentials client, the default credential provider chain is used. For more information, see the Default credential provider chain section of this topic.
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.
STS
Create a temporary security credential by applying Temporary Security Credentials (TSC) through the Security Token Service (STS).
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
.
EcsRamRole
Both ECS and ECI instances support binding instance RAM roles. When the Credentials tool is used in an instance, the RAM role bound to the instance will be automatically obtained, and the STS Token of the RAM role will be obtained by accessing the metadata service to complete the initialization of the credential client.
The instance metadata server supports two access modes: hardened mode and normal mode. The Credentials tool uses hardened mode (IMDSv2) by default to obtain access credentials. If an exception occurs when using hardened mode, you can set disableIMDSv1 to perform different exception handling logic:
-
When the value is false (default value), the normal mode will continue to be used to obtain access credentials.
- When the value is true, it means that only hardened mode can be used to obtain access credentials, and an exception will be thrown.
Whether the server supports IMDSv2 depends on your configuration on the server.
OIDCRoleArn
After you attach a RAM role to a worker node in an Container Service for Kubernetes, applications in the pods on the worker node can use the metadata server to obtain an STS token the same way in which applications on ECS instances do. However, if an untrusted application is deployed on the worker node, such as an application that is submitted by your customer and whose code is unavailable to you, you may not want the application to use the metadata server to obtain an STS token of the RAM role attached to the worker node. To ensure the security of cloud resources and enable untrusted applications to securely obtain required STS tokens, you can use the RAM Roles for Service Accounts (RRSA) feature to grant minimum necessary permissions to an application. In this case, the ACK cluster creates a service account OpenID Connect (OIDC) token file, associates the token file with a pod, and then injects relevant environment variables into the pod. Then, the Credentials tool uses the environment variables to call the AssumeRoleWithOIDC operation of STS and obtains an STS token of the RAM role. For more information about the RRSA feature, see Use RRSA to authorize different pods to access different cloud services.
Credentials URI
By specifying the url, the credential will be able to automatically request maintenance of STS Token.
Bearer Token
If credential is required by the Cloud Call Centre (CCC), please apply for Bearer Token maintenance by yourself.
Default credential provider chain
If you want to use different types of credentials in the development and production environments of your application, you generally need to obtain the environment information from the code and write code branches to obtain different credentials for the development and production environments. The default credential provider chain of the Credentials tool allows you to use the same code to obtain credentials for different environments based on configurations independent of the application. If you use $credential = new Credential(); to initialize a Credentials client without specifying an initialization method, the Credentials tool obtains the credential information in the following order:
1. Environmental certificate
Look for environment credentials in environment variable.
- If the
ALIBABA_CLOUD_ACCESS_KEY_ID
andALIBABA_CLOUD_ACCESS_KEY_SECRET
environment variables are defined and are not empty, the program will use them to create default credentials. - If the
ALIBABA_CLOUD_ACCESS_KEY_ID
,ALIBABA_CLOUD_ACCESS_KEY_SECRET
andALIBABA_CLOUD_SECURITY_TOKEN
environment variables are defined and are not empty, the program will use them to create temporary security credentials(STS). Note: This token has an expiration time, it is recommended to use it in a temporary environment.
2. The RAM role of an OIDC IdP
If no credentials are found in the previous step, the Credentials tool obtains the values of the following environment variables:
ALIBABA_CLOUD_ROLE_ARN
: the ARN of the RAM role.
ALIBABA_CLOUD_OIDC_PROVIDER_ARN
: the ARN of the OIDC IdP.
ALIBABA_CLOUD_OIDC_TOKEN_FILE
: the path of the OIDC token file.
If the preceding three environment variables are specified, the Credentials tool uses the environment variables to call the AssumeRoleWithOIDC operation of STS to obtain an STS token as the default credential.
3. Using the config.json Configuration File of Aliyun CLI Tool
If there is no higher-priority credential information, the Credentials tool will first check the following locations to see if the config.json file exists:
Linux system: ~/.aliyun/config.json
Windows system: C:\Users\USER_NAME\.aliyun\config.json
If the file exists, the program will use the credential information specified by current
in the configuration file to initialize the credentials client. Of course, you can also use the environment variable ALIBABA_CLOUD_PROFILE
to specify the credential information, for example by setting the value of ALIBABA_CLOUD_PROFILE
to AK
.
In the config.json configuration file, the value of each module represents different ways to obtain credential information:
- AK: Use the Access Key of the user as credential information;
- RamRoleArn: Use the ARN of the RAM role to obtain credential information;
- EcsRamRole: Use the RAM role bound to the ECS to obtain credential information;
- OIDC: Obtain credential information through OIDC ARN and OIDC Token;
- ChainableRamRoleArn: Use the role chaining method to obtain new credential information by specifying other credentials in the JSON file.
The configuration example information is as follows:
4. Configuration file
If the user's home directory has the default file
~/.alibabacloud/credentials
(Windows isC:\Users\USER_NAME\.alibabacloud\credentials
), the program will automatically create credentials with the specified type and name. You can also specify the configuration file path by configuring theALIBABA_CLOUD_CREDENTIALS_FILE
environment variable. If the configuration file exists, the application initializes a Credentials client by using the credential information that is specified by default in the configuration file. You can also configure theALIBABA_CLOUD_PROFILE
environment variable to modify the default credential information that is read.
Configuration example:
5. Instance RAM role
If there is no credential information with a higher priority, the Credentials tool will obtain the value of ALIBABA_CLOUD_ECS_METADATA (ECS instance RAM role name) through the environment variable. If the value of this variable exists, the program will use the hardened mode (IMDSv2) to access the metadata service (Meta Data Server) of ECS to obtain the STS Token of the ECS instance RAM role as the default credential information. If an exception occurs when using the hardened mode, the normal mode will be used as a fallback to obtain access credentials. You can also set the environment variable ALIBABA_CLOUD_IMDSV1_DISABLED to perform different exception handling logic:
-
When the value is false, the normal mode will continue to obtain access credentials.
- When the value is true, it means that only the hardened mode can be used to obtain access credentials, and an exception will be thrown.
Whether the server supports IMDSv2 depends on your configuration on the server.
6. Using External Service Credentials URI
If there are no higher-priority credential information, the Credentials tool will obtain the ALIBABA_CLOUD_CREDENTIALS_URI
from the environment variables. If it exists, the program will request the URI address to obtain temporary security credentials as the default credential information.
The external service response structure should be as follows:
Documentation
- Prerequisites
- Installation
Issue
Submit Issue, Problems that do not meet the guidelines may close immediately.
Release notes
Detailed changes for each version are recorded in the Release Notes.
Contribution
Please read the Contribution Guide before submitting a Pull Request.
Related
License
Apache-2.0
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
All versions of credentials with dependencies
ext-curl Version *
ext-json Version *
ext-libxml Version *
ext-openssl Version *
ext-mbstring Version *
ext-simplexml Version *
ext-xmlwriter Version *
guzzlehttp/guzzle Version ^6.3|^7.0
adbario/php-dot-notation Version ^2.2
alibabacloud/tea Version ^3.0