summaryrefslogtreecommitdiff
path: root/vendor/aws/aws-sdk-php/src/EndpointV2/EndpointV2SerializerTrait.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2023-10-20 16:44:35 +0300
committerAndrew Dolgov <[email protected]>2023-10-20 16:44:35 +0300
commit8bec661288b276c98bdb0e773e5f4d5275dc4c87 (patch)
tree8617ebe581c62fc46a7881aa61801ebce9d3c603 /vendor/aws/aws-sdk-php/src/EndpointV2/EndpointV2SerializerTrait.php
parent540438c2eb5452bacad30c247906bfa287f2da1d (diff)
update AWK SDKHEADmaster
Diffstat (limited to 'vendor/aws/aws-sdk-php/src/EndpointV2/EndpointV2SerializerTrait.php')
-rw-r--r--vendor/aws/aws-sdk-php/src/EndpointV2/EndpointV2SerializerTrait.php40
1 files changed, 34 insertions, 6 deletions
diff --git a/vendor/aws/aws-sdk-php/src/EndpointV2/EndpointV2SerializerTrait.php b/vendor/aws/aws-sdk-php/src/EndpointV2/EndpointV2SerializerTrait.php
index b4dcf5a..922ec18 100644
--- a/vendor/aws/aws-sdk-php/src/EndpointV2/EndpointV2SerializerTrait.php
+++ b/vendor/aws/aws-sdk-php/src/EndpointV2/EndpointV2SerializerTrait.php
@@ -39,8 +39,10 @@ trait EndpointV2SerializerTrait
$clientArgs
);
$endpoint = $endpointProvider->resolveEndpoint($providerArgs);
+ $resolvedUrl = $endpoint->getUrl();
- $this->endpoint = $endpoint->getUrl();
+ $this->applyScheme($resolvedUrl);
+ $this->endpoint = $resolvedUrl;
$this->applyAuthSchemeToCommand($endpoint, $command);
$this->applyHeaders($endpoint, $headers);
}
@@ -171,19 +173,22 @@ trait EndpointV2SerializerTrait
private function selectAuthScheme($authSchemes)
{
- $validAuthSchemes = ['sigv4', 'sigv4a' ];
+ $validAuthSchemes = ['sigv4', 'sigv4a', 'none', 'bearer'];
+ $invalidAuthSchemes = [];
foreach($authSchemes as $authScheme) {
if (in_array($authScheme['name'], $validAuthSchemes)) {
return $this->normalizeAuthScheme($authScheme);
} else {
- $unsupportedScheme = $authScheme['name'];
+ $invalidAuthSchemes[] = "`{$authScheme['name']}`";
}
}
+ $invalidAuthSchemesString = implode(', ', $invalidAuthSchemes);
+ $validAuthSchemesString = '`' . implode('`, `', $validAuthSchemes) . '`';
throw new \InvalidArgumentException(
- "This operation requests {$unsupportedScheme}
- . but the client only supports sigv4 and sigv4a"
+ "This operation requests {$invalidAuthSchemesString}"
+ . " auth schemes, but the client only supports {$validAuthSchemesString}."
);
}
@@ -198,18 +203,41 @@ trait EndpointV2SerializerTrait
if (isset($authScheme['disableDoubleEncoding'])
&& $authScheme['disableDoubleEncoding'] === true
+ && $authScheme['name'] !== 'sigv4a'
) {
$normalizedAuthScheme['version'] = 's3v4';
- } else {
+ } elseif ($authScheme['name'] === 'none') {
+ $normalizedAuthScheme['version'] = 'anonymous';
+ }
+ else {
$normalizedAuthScheme['version'] = str_replace(
'sig', '', $authScheme['name']
);
}
+
$normalizedAuthScheme['name'] = isset($authScheme['signingName']) ?
$authScheme['signingName'] : null;
$normalizedAuthScheme['region'] = isset($authScheme['signingRegion']) ?
$authScheme['signingRegion'] : null;
+ $normalizedAuthScheme['signingRegionSet'] = isset($authScheme['signingRegionSet']) ?
+ $authScheme['signingRegionSet'] : null;
return $normalizedAuthScheme;
}
+
+ private function applyScheme(&$resolvedUrl)
+ {
+ $resolvedEndpointScheme = parse_url($resolvedUrl, PHP_URL_SCHEME);
+ $scheme = $this->endpoint instanceof Uri
+ ? $this->endpoint->getScheme()
+ : parse_url($this->endpoint, PHP_URL_SCHEME);
+
+ if (!empty($scheme) && $scheme !== $resolvedEndpointScheme) {
+ $resolvedUrl = str_replace(
+ $resolvedEndpointScheme,
+ $scheme,
+ $resolvedUrl
+ );
+ }
+ }
}