Documentation

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

$key  : string
$secret  : string
$token  : string
$ttd  : int

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_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

$secret

protected string $secret

AWS Secret Access Key

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
throws
InvalidArgumentException

If the caching options are invalid

throws
RuntimeException

If using the default cache and APC is disabled

Return values
CredentialsInterface

fromIni()

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
throws
RuntimeException

if the file cannot be found, if the file is invalid, or if the profile is invalid.

Return values
CredentialsInterface

getAccessKeyId()

Returns the AWS access key ID for this credentials object.

public getAccessKeyId() : string
Return values
string

getConfigDefaults()

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|null

getSecretKey()

Returns the AWS secret access key for this credentials object.

public getSecretKey() : string
Return values
string

getSecurityToken()

Get the associated security token if available

public getSecurityToken() : string|null
Return values
string|null

isExpired()

Check if the credentials are expired

public isExpired() : bool
Return values
bool

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
self

setExpiration()

Set the UNIX timestamp in which the credentials will expire

public setExpiration(mixed $timestamp) : self
Parameters
$timestamp : mixed

UNIX timestamp expiration

Return values
self

setSecurityToken()

Set the security token to use with this credentials object

public setSecurityToken(mixed $token) : self
Parameters
$token : mixed

Security token

Return values
self

unserialize()

public unserialize(mixed $serialized) : mixed
Parameters
$serialized : mixed

createFromCache()

private static createFromCache(CacheAdapterInterface $cache, mixed $cacheKey) : mixed
Parameters
$cache : CacheAdapterInterface
$cacheKey : mixed

getEnvVar()

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|null

        
On this page

Search results