S3SignatureV4
extends SignatureV4
in package
Amazon S3 signature version 4 support.
Table of Contents
- AMZ_CONTENT_SHA256_HEADER = 'X-Amz-Content-Sha256'
- ISO8601_BASIC = 'Ymd\THis\Z'
- UNSIGNED_PAYLOAD = 'UNSIGNED-PAYLOAD'
- $cache : array<string|int, mixed>
- $cacheSize : int
- $region : string
- $service : string
- $unsigned : bool
- __construct() : mixed
- convertPostToGet() : RequestInterface
- Converts a POST request to a GET request by moving POST fields into the query string.
- presign() : RequestInterface
- Always add a x-amz-content-sha-256 for data integrity.
- signRequest() : Request|RequestInterface
- S3-specific signing logic
- createCanonicalizedPath() : mixed
- Amazon S3 does not double-encode the path component in the canonical request
- getPayload() : mixed
- getPresignedPayload() : mixed
- Override used to allow pre-signed URLs to be created for an in-determinate request payload.
- buildRequest() : mixed
- convertExpires() : mixed
- convertToTimestamp() : mixed
- createContext() : array<string|int, mixed>
- createPresignedRequest() : mixed
- createScope() : mixed
- createStringToSign() : mixed
- getCanonicalizedQuery() : mixed
- getHeaderBlacklist() : array<string|int, mixed>
- The following headers are not signed because signing these headers would potentially cause a signature mismatch when sending a request through a proxy or if modified at the HTTP client level.
- getPresignHeaders() : array<string|int, mixed>
- Get the headers that were used to pre-sign the request.
- getSigningKey() : mixed
- moveHeadersToQuery() : mixed
- parseRequest() : mixed
Constants
AMZ_CONTENT_SHA256_HEADER
public
mixed
AMZ_CONTENT_SHA256_HEADER
= 'X-Amz-Content-Sha256'
ISO8601_BASIC
public
mixed
ISO8601_BASIC
= 'Ymd\THis\Z'
UNSIGNED_PAYLOAD
public
mixed
UNSIGNED_PAYLOAD
= 'UNSIGNED-PAYLOAD'
Properties
$cache
private
array<string|int, mixed>
$cache
= []
Cache of previously signed values
$cacheSize
private
int
$cacheSize
= 0
Size of the hash cache
$region
private
string
$region
$service
private
string
$service
$unsigned
private
bool
$unsigned
Methods
__construct()
public
__construct(string $service, string $region[, array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $service : string
-
Service name to use when signing
- $region : string
-
Region name to use when signing
- $options : array<string|int, mixed> = []
-
Array of configuration options used when signing
- unsigned-body: Flag to make request have unsigned payload. Unsigned body is used primarily for streaming requests.
Return values
mixed —convertPostToGet()
Converts a POST request to a GET request by moving POST fields into the query string.
public
static convertPostToGet(RequestInterface $request[, mixed $additionalQueryParams = "" ]) : RequestInterface
Useful for pre-signing query protocol requests.
Parameters
- $request : RequestInterface
-
Request to clone
- $additionalQueryParams : mixed = ""
Tags
Return values
RequestInterface —presign()
Always add a x-amz-content-sha-256 for data integrity.
public
presign(RequestInterface $request, CredentialsInterface $credentials, mixed $expires[, array<string|int, mixed> $options = [] ]) : RequestInterface
Parameters
- $request : RequestInterface
-
Request to sign
- $credentials : CredentialsInterface
-
Credentials used to sign
- $expires : mixed
-
The time at which the URL should expire. This can be a Unix timestamp, a PHP DateTime object, or a string that can be evaluated by strtotime.
- $options : array<string|int, mixed> = []
Return values
RequestInterface —signRequest()
S3-specific signing logic
public
signRequest(RequestInterface $request, CredentialsInterface $credentials) : Request|RequestInterface
Parameters
- $request : RequestInterface
- $credentials : CredentialsInterface
Return values
Request|RequestInterface —createCanonicalizedPath()
Amazon S3 does not double-encode the path component in the canonical request
protected
createCanonicalizedPath(mixed $path) : mixed
Parameters
- $path : mixed
Return values
mixed —getPayload()
protected
getPayload(RequestInterface $request) : mixed
Parameters
- $request : RequestInterface
Return values
mixed —getPresignedPayload()
Override used to allow pre-signed URLs to be created for an in-determinate request payload.
protected
getPresignedPayload(RequestInterface $request) : mixed
Parameters
- $request : RequestInterface
Return values
mixed —buildRequest()
private
buildRequest(array<string|int, mixed> $req) : mixed
Parameters
- $req : array<string|int, mixed>
Return values
mixed —convertExpires()
private
convertExpires(mixed $expiresTimestamp, mixed $startTimestamp) : mixed
Parameters
- $expiresTimestamp : mixed
- $startTimestamp : mixed
Return values
mixed —convertToTimestamp()
private
convertToTimestamp(mixed $dateValue[, mixed $relativeTimeBase = null ]) : mixed
Parameters
- $dateValue : mixed
- $relativeTimeBase : mixed = null
Return values
mixed —createContext()
private
createContext(array<string|int, mixed> $parsedRequest, string $payload) : array<string|int, mixed>
Parameters
- $parsedRequest : array<string|int, mixed>
- $payload : string
-
Hash of the request payload
Return values
array<string|int, mixed> —Returns an array of context information
createPresignedRequest()
private
createPresignedRequest(RequestInterface $request, CredentialsInterface $credentials) : mixed
Parameters
- $request : RequestInterface
- $credentials : CredentialsInterface
Return values
mixed —createScope()
private
createScope(mixed $shortDate, mixed $region, mixed $service) : mixed
Parameters
- $shortDate : mixed
- $region : mixed
- $service : mixed
Return values
mixed —createStringToSign()
private
createStringToSign(mixed $longDate, mixed $credentialScope, mixed $creq) : mixed
Parameters
- $longDate : mixed
- $credentialScope : mixed
- $creq : mixed
Return values
mixed —getCanonicalizedQuery()
private
getCanonicalizedQuery(array<string|int, mixed> $query) : mixed
Parameters
- $query : array<string|int, mixed>
Return values
mixed —getHeaderBlacklist()
The following headers are not signed because signing these headers would potentially cause a signature mismatch when sending a request through a proxy or if modified at the HTTP client level.
private
getHeaderBlacklist() : array<string|int, mixed>
Return values
array<string|int, mixed> —getPresignHeaders()
Get the headers that were used to pre-sign the request.
private
getPresignHeaders(array<string|int, mixed> $headers) : array<string|int, mixed>
Used for the X-Amz-SignedHeaders header.
Parameters
- $headers : array<string|int, mixed>
Return values
array<string|int, mixed> —getSigningKey()
private
getSigningKey(mixed $shortDate, mixed $region, mixed $service, mixed $secretKey) : mixed
Parameters
- $shortDate : mixed
- $region : mixed
- $service : mixed
- $secretKey : mixed
Return values
mixed —moveHeadersToQuery()
private
moveHeadersToQuery(array<string|int, mixed> $parsedRequest) : mixed
Parameters
- $parsedRequest : array<string|int, mixed>
Return values
mixed —parseRequest()
private
parseRequest(RequestInterface $request) : mixed
Parameters
- $request : RequestInterface