PHP Класс Aws\Credentials\CredentialProvider

use Aws\Credentials\CredentialProvider; $provider = CredentialProvider::defaultProvider(); Returns a CredentialsInterface or throws. $creds = $provider()->wait(); Credential providers can be composed to create credentials using conditional logic that can create different credentials in different environments. You can compose multiple providers into a single provider using {@see \Aws\Credentials\CredentialProvider::chain}. This function accepts providers as variadic arguments and returns a new function that will invoke each provider until a successful set of credentials is returned. First try an INI file at this location. $a = CredentialProvider::ini(null, '/path/to/file.ini'); Then try an INI file at this location. $b = CredentialProvider::ini(null, '/path/to/other-file.ini'); Then try loading from environment variables. $c = CredentialProvider::env(); Combine the three providers together. $composed = CredentialProvider::chain($a, $b, $c); Returns a promise that is fulfilled with credentials or throws. $promise = $composed(); Wait on the credentials to resolve. $creds = $promise->wait();
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
cache ( callable $provider, Aws\CacheInterface $cache, string | null $cacheKey = null ) : callable Wraps a credential provider and saves provided credentials in an instance of Aws\CacheInterface. Forwards calls when no credentials found in cache and updates cache with the results.
chain ( ) : callable Creates an aggregate credentials provider that invokes the provided variadic providers one after the other until a provider returns credentials.
defaultProvider ( array $config = [] ) : callable Create a default credential provider that first checks for environment variables, then checks for the "default" profile in ~/.aws/credentials, then tries to make GET Request to fetch credentials if Ecs environment variable is presented, and finally checks for EC2 instance profile credentials.
ecsCredentials ( array $config = [] ) : EcsCredentialProvider Credential provider that creates credentials using ecs credentials by a GET request, whose uri is specified by environment variable
env ( ) : callable Provider that creates credentials from environment variables AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_SESSION_TOKEN.
fromCredentials ( Aws\Credentials\CredentialsInterface $creds ) : callable Create a credential provider function from a set of static credentials.
ini ( string | null $profile = null, string | null $filename = null ) : callable Credentials provider that creates credentials using an ini file stored in the current user's home directory.
instanceProfile ( array $config = [] ) : Aws\Credentials\InstanceProfileProvider Credential provider that creates credentials using instance profile credentials.
memoize ( callable $provider ) : callable Wraps a credential provider and caches previously provided credentials.

Приватные методы

Метод Описание
getHomeDir ( ) : null | string Gets the environment's HOME directory if available.
reject ( $msg )

Описание методов

cache() публичный статический метод

Defaults to using a simple file-based cache when none provided.
public static cache ( callable $provider, Aws\CacheInterface $cache, string | null $cacheKey = null ) : callable
$provider callable Credentials provider function to wrap
$cache Aws\CacheInterface Cache to store credentials
$cacheKey string | null (optional) Cache key to use
Результат callable

chain() публичный статический метод

Creates an aggregate credentials provider that invokes the provided variadic providers one after the other until a provider returns credentials.
public static chain ( ) : callable
Результат callable

defaultProvider() публичный статический метод

This provider is automatically wrapped in a memoize function that caches previously provided credentials.
public static defaultProvider ( array $config = [] ) : callable
$config array Optional array of instance profile credentials provider options.
Результат callable

ecsCredentials() публичный статический метод

Credential provider that creates credentials using ecs credentials by a GET request, whose uri is specified by environment variable
См. также: Aws\Credentials\EcsCredentialProvider for $config details.
public static ecsCredentials ( array $config = [] ) : EcsCredentialProvider
$config array Array of configuration data.
Результат EcsCredentialProvider

env() публичный статический метод

Provider that creates credentials from environment variables AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_SESSION_TOKEN.
public static env ( ) : callable
Результат callable

fromCredentials() публичный статический метод

Create a credential provider function from a set of static credentials.
public static fromCredentials ( Aws\Credentials\CredentialsInterface $creds ) : callable
$creds Aws\Credentials\CredentialsInterface
Результат callable

ini() публичный статический метод

Credentials provider that creates credentials using an ini file stored in the current user's home directory.
public static ini ( string | null $profile = null, string | null $filename = null ) : callable
$profile string | null Profile to use. If not specified will use the "default" profile.
$filename string | null If provided, uses a custom filename rather than looking in the home directory for the
Результат callable

instanceProfile() публичный статический метод

Credential provider that creates credentials using instance profile credentials.
См. также: Aws\Credentials\InstanceProfileProvider for $config details.
public static instanceProfile ( array $config = [] ) : Aws\Credentials\InstanceProfileProvider
$config array Array of configuration data.
Результат Aws\Credentials\InstanceProfileProvider

memoize() публичный статический метод

Ensures that cached credentials are refreshed when they expire.
public static memoize ( callable $provider ) : callable
$provider callable Credentials provider function to wrap.
Результат callable