Credentials
in package
implements
CredentialsInterface, FromConfigInterface
Basic implementation of the AWSCredentials interface that allows callers to pass in the AWS access key and secret access in the constructor.
Table of Contents
Interfaces
- CredentialsInterface
- Provides access to the AWS credentials used for accessing AWS services: AWS access key ID, secret access key, and security token. These credentials are used to securely sign requests to AWS services.
- FromConfigInterface
- Interfaces that adds a factory method which is used to instantiate a class from an array of configuration options.
Constants
- ENV_KEY = 'AWS_ACCESS_KEY_ID'
- ENV_PROFILE = 'AWS_PROFILE'
- ENV_SECRET = 'AWS_SECRET_KEY'
- ENV_SECRET_ACCESS_KEY = 'AWS_SECRET_ACCESS_KEY'
Properties
Methods
- __construct() : mixed
- Constructs a new BasicAWSCredentials object, with the specified AWS access key and AWS secret key
- __serialize() : mixed
- to fix php 8.1 compatibility
- __unserialize() : mixed
- to fix php 8.1 compatibility
- factory() : CredentialsInterface
- Factory method for creating new credentials. This factory method will create the appropriate credentials object with appropriate decorators based on the passed configuration options.
- fromIni() : CredentialsInterface
- Create credentials from the credentials ini file in the HOME directory.
- getAccessKeyId() : string
- Returns the AWS access key ID for this credentials object.
- getConfigDefaults() : array<string|int, mixed>
- Get the available keys for the factory method
- getExpiration() : int|null
- Get the UNIX timestamp in which the credentials will expire
- getSecretKey() : string
- Returns the AWS secret access key for this credentials object.
- getSecurityToken() : string|null
- Get the associated security token if available
- isExpired() : bool
- Check if the credentials are expired
- serialize() : mixed
- setAccessKeyId() : self
- Set the AWS access key ID for this credentials object.
- setExpiration() : self
- Set the UNIX timestamp in which the credentials will expire
- setSecretKey() : CredentialsInterface
- Set the AWS secret access key for this credentials object.
- setSecurityToken() : self
- Set the security token to use with this credentials object
- unserialize() : mixed
- createCache() : mixed
- createFromCache() : mixed
- createFromEnvironment() : CredentialsInterface
- When no keys are provided, attempt to create them based on the environment or instance profile credentials.
- getEnvVar() : mixed|null
- Fetches the value of an environment variable by checking $_SERVER and getenv().
- getHomeDir() : mixed
Constants
ENV_KEY
public
mixed
ENV_KEY
= 'AWS_ACCESS_KEY_ID'
ENV_PROFILE
public
mixed
ENV_PROFILE
= 'AWS_PROFILE'
ENV_SECRET
public
mixed
ENV_SECRET
= 'AWS_SECRET_KEY'
ENV_SECRET_ACCESS_KEY
public
mixed
ENV_SECRET_ACCESS_KEY
= 'AWS_SECRET_ACCESS_KEY'
Properties
$key
protected
string
$key
AWS Access Key ID
$secret
protected
string
$secret
AWS Secret Access Key
$token
protected
string
$token
AWS Security Token
$ttd
protected
int
$ttd
Time to die of token
Methods
__construct()
Constructs a new BasicAWSCredentials object, with the specified AWS access key and AWS secret key
public
__construct(string $accessKeyId, string $secretAccessKey[, string $token = null ][, int $expiration = null ]) : mixed
Parameters
- $accessKeyId : string
-
AWS access key ID
- $secretAccessKey : string
-
AWS secret access key
- $token : string = null
-
Security token to use
- $expiration : int = null
-
UNIX timestamp for when credentials expire
__serialize()
to fix php 8.1 compatibility
public
__serialize() : mixed
__unserialize()
to fix php 8.1 compatibility
public
__unserialize(mixed $serialized) : mixed
Parameters
- $serialized : mixed
factory()
Factory method for creating new credentials. This factory method will create the appropriate credentials object with appropriate decorators based on the passed configuration options.
public
static factory([array<string|int, mixed> $config = array() ]) : CredentialsInterface
Parameters
- $config : array<string|int, mixed> = array()
-
Options to use when instantiating the credentials
Tags
Return values
CredentialsInterfacefromIni()
Create credentials from the credentials ini file in the HOME directory.
public
static fromIni([string|null $profile = null ][, string|null $filename = null ]) : CredentialsInterface
Parameters
- $profile : string|null = null
-
Pass a specific profile to use. If no profile is specified we will attempt to use the value specified in the AWS_PROFILE environment variable. If AWS_PROFILE is not set, the "default" profile is used.
- $filename : string|null = null
-
Pass a string to specify the location of the credentials files. If null is passed, the SDK will attempt to find the configuration file at in your HOME directory at ~/.aws/credentials.
Tags
Return values
CredentialsInterfacegetAccessKeyId()
Returns the AWS access key ID for this credentials object.
public
getAccessKeyId() : string
Return values
stringgetConfigDefaults()
Get the available keys for the factory method
public
static getConfigDefaults() : array<string|int, mixed>
Return values
array<string|int, mixed>getExpiration()
Get the UNIX timestamp in which the credentials will expire
public
getExpiration() : int|null
Return values
int|nullgetSecretKey()
Returns the AWS secret access key for this credentials object.
public
getSecretKey() : string
Return values
stringgetSecurityToken()
Get the associated security token if available
public
getSecurityToken() : string|null
Return values
string|nullisExpired()
Check if the credentials are expired
public
isExpired() : bool
Return values
boolserialize()
public
serialize() : mixed
setAccessKeyId()
Set the AWS access key ID for this credentials object.
public
setAccessKeyId(mixed $key) : self
Parameters
- $key : mixed
-
AWS access key ID
Return values
selfsetExpiration()
Set the UNIX timestamp in which the credentials will expire
public
setExpiration(mixed $timestamp) : self
Parameters
- $timestamp : mixed
-
UNIX timestamp expiration
Return values
selfsetSecretKey()
Set the AWS secret access key for this credentials object.
public
setSecretKey(mixed $secret) : CredentialsInterface
Parameters
- $secret : mixed
-
AWS secret access key
Return values
CredentialsInterfacesetSecurityToken()
Set the security token to use with this credentials object
public
setSecurityToken(mixed $token) : self
Parameters
- $token : mixed
-
Security token
Return values
selfunserialize()
public
unserialize(mixed $serialized) : mixed
Parameters
- $serialized : mixed
createCache()
private
static createCache(CredentialsInterface $credentials, mixed $cache, mixed $cacheKey) : mixed
Parameters
- $credentials : CredentialsInterface
- $cache : mixed
- $cacheKey : mixed
createFromCache()
private
static createFromCache(CacheAdapterInterface $cache, mixed $cacheKey) : mixed
Parameters
- $cache : CacheAdapterInterface
- $cacheKey : mixed
createFromEnvironment()
When no keys are provided, attempt to create them based on the environment or instance profile credentials.
private
static createFromEnvironment(array<string|int, mixed>|Collection $config) : CredentialsInterface
Parameters
- $config : array<string|int, mixed>|Collection
Return values
CredentialsInterfacegetEnvVar()
Fetches the value of an environment variable by checking $_SERVER and getenv().
private
static getEnvVar(string $var) : mixed|null
Parameters
- $var : string
-
Name of the environment variable
Return values
mixed|nullgetHomeDir()
private
static getHomeDir() : mixed