-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Kim Pepper <[email protected]>
- Loading branch information
Showing
3 changed files
with
38 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace OpenSearch\Aws; | ||
|
||
use Aws\Credentials\CredentialsInterface; | ||
use Aws\Signature\SignatureInterface; | ||
use Psr\Http\Client\ClientInterface; | ||
use Psr\Http\Message\RequestInterface; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
/** | ||
* A decorator client that signs requests using the provided AWS credentials and signer. | ||
*/ | ||
class SigningClientDecorator implements ClientInterface | ||
{ | ||
public function __construct( | ||
protected ClientInterface $inner, | ||
protected CredentialsInterface $credentials, | ||
protected SignatureInterface $signer, | ||
) { | ||
if (!class_exists(SignatureInterface::class)) { | ||
throw new \RuntimeException( | ||
'The AWS SDK for PHP must be installed in order to use the AWS signing client.' | ||
); | ||
} | ||
} | ||
|
||
public function sendRequest(RequestInterface $request): ResponseInterface | ||
{ | ||
$request = $request->withHeader('x-amz-content-sha256', hash('sha256', (string) $request->getBody())); | ||
$request = $this->signer->signRequest($request, $this->credentials); | ||
return $this->inner->sendRequest($request); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
protected :namespaceNamespace $:var_namespace; | ||
/** | ||
* @var :namespaceNamespace | ||
*/ | ||
protected $:var_namespace; |