4
4
use Aws \Credentials \CredentialsInterface ;
5
5
use AWS \CRT \Auth \Signable ;
6
6
use AWS \CRT \Auth \SignatureType ;
7
+ use AWS \CRT \Auth \SignedBodyHeaderType ;
7
8
use AWS \CRT \Auth \Signing ;
8
9
use AWS \CRT \Auth \SigningAlgorithm ;
9
10
use AWS \CRT \Auth \SigningConfigAWS ;
@@ -446,7 +447,7 @@ private function buildRequest(array $req)
446
447
);
447
448
}
448
449
449
- private function verifyCRTLoaded ()
450
+ protected function verifyCRTLoaded ()
450
451
{
451
452
if (!extension_loaded ('awscrt ' )) {
452
453
throw new CommonRuntimeException (
@@ -457,7 +458,7 @@ private function verifyCRTLoaded()
457
458
}
458
459
}
459
460
460
- private function createCRTStaticCredentialsProvider ($ credentials )
461
+ protected function createCRTStaticCredentialsProvider ($ credentials )
461
462
{
462
463
return new StaticCredentialsProvider ([
463
464
'access_key_id ' => $ credentials ->getAccessKeyId (),
@@ -472,7 +473,7 @@ private function removeIllegalV4aHeaders(&$request)
472
473
self ::AMZ_CONTENT_SHA256_HEADER ,
473
474
"aws-sdk-invocation-id " ,
474
475
"aws-sdk-retry " ,
475
- 'x-amz-region-set '
476
+ 'x-amz-region-set ' ,
476
477
];
477
478
$ storedHeaders = [];
478
479
@@ -500,17 +501,23 @@ private function CRTRequestFromGuzzleRequest($request)
500
501
* @param CredentialsInterface $credentials
501
502
* @param RequestInterface $request
502
503
* @param $signingService
504
+ * @param SigningConfigAWS|null $signingConfig
503
505
* @return RequestInterface
504
506
*/
505
- protected function signWithV4a (CredentialsInterface $ credentials , RequestInterface $ request , $ signingService )
506
- {
507
+ protected function signWithV4a (
508
+ CredentialsInterface $ credentials ,
509
+ RequestInterface $ request ,
510
+ $ signingService ,
511
+ SigningConfigAWS $ signingConfig = null
512
+ ){
507
513
$ this ->verifyCRTLoaded ();
508
- $ credentials_provider = $ this ->createCRTStaticCredentialsProvider ($ credentials );
509
- $ signingConfig = new SigningConfigAWS ([
514
+ $ signingConfig = $ signingConfig ?? new SigningConfigAWS ([
510
515
'algorithm ' => SigningAlgorithm::SIGv4_ASYMMETRIC,
511
516
'signature_type ' => SignatureType::HTTP_REQUEST_HEADERS ,
512
- 'credentials_provider ' => $ credentials_provider ,
517
+ 'credentials_provider ' => $ this -> createCRTStaticCredentialsProvider ( $ credentials ) ,
513
518
'signed_body_value ' => $ this ->getPayload ($ request ),
519
+ 'should_normalize_uri_path ' => true ,
520
+ 'use_double_uri_encode ' => true ,
514
521
'region ' => "* " ,
515
522
'service ' => $ signingService ,
516
523
'date ' => time (),
0 commit comments