Class SignatureProvider
Signature providers.
A signature provider is a function that accepts a version, service, and
region and returns a Aws\Signature\SignatureInterface
object on success or NULL if
no signature can be created from the provided arguments.
You can wrap your calls to a signature provider with the
SignatureProvider::resolve function to ensure that a signature object
is created. If a signature object is not created, then the resolve()
function will throw a Aws\Exception\UnresolvedSignatureException
.
use Aws\Signature\SignatureProvider; $provider = SignatureProvider::defaultProvider(); // Returns a SignatureInterface or NULL. $signer = $provider('v4', 's3', 'us-west-2'); // Returns a SignatureInterface or throws. $signer = SignatureProvider::resolve($provider, 'no', 's3', 'foo');
You can compose multiple providers into a single provider using
Aws\or_chain()
. This function accepts providers as arguments and
returns a new function that will invoke each provider until a non-null value
is returned.
$a = SignatureProvider::defaultProvider(); $b = function ($version, $service, $region) { if ($version === 'foo') { return new MyFooSignature(); } }; $c = \Aws\or_chain($a, $b); $signer = $c('v4', 'abc', '123'); // $a handles this. $signer = $c('foo', 'abc', '123'); // $b handles this. $nullValue = $c('???', 'abc', '123'); // Neither can handle this.
Methods Summary
-
static
resolve ( callable $provider, string $version, string $service, string $region )
Resolves and signature provider and ensures a non-null return value.
-
static
defaultProvider ( )
Default SDK signature provider.
-
static
memoize ( callable $provider )
Creates a signature provider that caches previously created signature objects. The computed cache key is the concatenation of the version, service, and region.
-
static
version ( )
Creates signature objects from known signature versions.
Methods Details
static
Aws\Signature\SignatureInterface
resolve (
callable
$provider,
string
$version,
string
$service,
string
$region
)
Resolves and signature provider and ensures a non-null return value.
Parameters
callable | $provider | Provider function to invoke. |
string | $version | Signature version. |
string | $service | Service name. |
string | $region | Region name. |
Returns
Aws\Signature\SignatureInterface |
Exceptions
Aws\Exception\UnresolvedSignatureException |
static callable defaultProvider ( )
Default SDK signature provider.
Returns
callable |
static callable memoize ( callable $provider )
Creates a signature provider that caches previously created signature objects. The computed cache key is the concatenation of the version, service, and region.
Parameters
callable | $provider | Signature provider to wrap. |
Returns
callable |
static callable version ( )
Creates signature objects from known signature versions.
This provider currently recognizes the following signature versions:
- v4: Signature version 4.
- anonymous: Does not sign requests.
Returns
callable |