From 8bec661288b276c98bdb0e773e5f4d5275dc4c87 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 20 Oct 2023 16:44:35 +0300 Subject: update AWK SDK --- .../src/EndpointV2/EndpointDefinitionProvider.php | 18 ++++++---- .../src/EndpointV2/EndpointV2SerializerTrait.php | 40 ++++++++++++++++++---- .../EndpointV2/Ruleset/RulesetStandardLibrary.php | 11 +++--- 3 files changed, 52 insertions(+), 17 deletions(-) (limited to 'vendor/aws/aws-sdk-php/src/EndpointV2') diff --git a/vendor/aws/aws-sdk-php/src/EndpointV2/EndpointDefinitionProvider.php b/vendor/aws/aws-sdk-php/src/EndpointV2/EndpointDefinitionProvider.php index aee14b5..6da2685 100644 --- a/vendor/aws/aws-sdk-php/src/EndpointV2/EndpointDefinitionProvider.php +++ b/vendor/aws/aws-sdk-php/src/EndpointV2/EndpointDefinitionProvider.php @@ -8,14 +8,14 @@ namespace Aws\EndpointV2; */ class EndpointDefinitionProvider { - public static function getEndpointRuleset($service, $apiVersion) + public static function getEndpointRuleset($service, $apiVersion, $baseDir = null) { - return self::getData($service, $apiVersion, 'ruleset'); + return self::getData($service, $apiVersion, 'ruleset', $baseDir); } - public static function getEndpointTests($service, $apiVersion) + public static function getEndpointTests($service, $apiVersion, $baseDir = null) { - return self::getData($service, $apiVersion, 'tests'); + return self::getData($service, $apiVersion, 'tests', $baseDir); } public static function getPartitions() @@ -30,9 +30,9 @@ class EndpointDefinitionProvider } } - private static function getData($service, $apiVersion, $type) + private static function getData($service, $apiVersion, $type, $baseDir) { - $basePath = __DIR__ . '/../data'; + $basePath = $baseDir ? $baseDir : __DIR__ . '/../data'; $serviceDir = $basePath . "/{$service}"; if (!is_dir($serviceDir)) { throw new \InvalidArgumentException( @@ -54,8 +54,12 @@ class EndpointDefinitionProvider if (file_exists($rulesetPath . $fileName . '.json.php')) { return require($rulesetPath . $fileName . '.json.php'); - } else { + } elseif (file_exists($rulesetPath . $fileName . '.json')) { return json_decode(file_get_contents($rulesetPath . $fileName . '.json'), true); + } else { + throw new \InvalidArgumentException( + 'Specified ' . $type . ' endpoint file for ' . $service . ' with api version ' . $apiVersion . ' does not exist.' + ); } } 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 + ); + } + } } diff --git a/vendor/aws/aws-sdk-php/src/EndpointV2/Ruleset/RulesetStandardLibrary.php b/vendor/aws/aws-sdk-php/src/EndpointV2/Ruleset/RulesetStandardLibrary.php index 18ec270..2705ff9 100644 --- a/vendor/aws/aws-sdk-php/src/EndpointV2/Ruleset/RulesetStandardLibrary.php +++ b/vendor/aws/aws-sdk-php/src/EndpointV2/Ruleset/RulesetStandardLibrary.php @@ -155,6 +155,10 @@ class RulesetStandardLibrary */ public function parseUrl($url) { + if (is_null($url)) { + return null; + } + $parsed = parse_url($url); if ($parsed === false || !empty($parsed['query'])) { @@ -227,7 +231,7 @@ class RulesetStandardLibrary $arn = []; $parts = explode(':', $arnString, 6); - if (sizeof($parts) > 6) { + if (sizeof($parts) < 6) { return null; } @@ -244,8 +248,7 @@ class RulesetStandardLibrary return null; } $resource = $arn['resourceId']; - $delimiter = strpos($resource, ':') !== false ? ':' : '/'; - $arn['resourceId'] = explode($delimiter, $resource); + $arn['resourceId'] = preg_split("/[:\/]/", $resource); return $arn; } @@ -316,7 +319,7 @@ class RulesetStandardLibrary } $result = call_user_func_array( - ['Aws\EndpointV2\Ruleset\RulesetStandardLibrary', $funcName], + [RulesetStandardLibrary::class, $funcName], $funcArgs ); -- cgit v1.2.3