Skip to content

Commit

Permalink
Progress on porting the commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
aemous committed Sep 24, 2024
1 parent 8c2d0d9 commit d253841
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
3 changes: 3 additions & 0 deletions awscli/botocore/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ def compute_client_args(self, service_model, client_config,
),
user_agent_extra=client_config.user_agent_extra,
user_agent_appid=client_config.user_agent_appid,
sigv4a_signing_region_set=(
client_config.sigv4a_signing_region_set
),
)
self._compute_retry_config(config_kwargs)
self._compute_request_compression_config(config_kwargs)
Expand Down
27 changes: 26 additions & 1 deletion awscli/botocore/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@
urlsplit,
urlunsplit,
)
from botocore.exceptions import NoAuthTokenError, NoCredentialsError
from botocore.exceptions import (
NoAuthTokenError,
NoCredentialsError,
UnknownSignatureVersionError,
UnsupportedSignatureVersionError,
)
from botocore.utils import (
is_valid_ipv6_endpoint_url,
normalize_url_path,
Expand Down Expand Up @@ -851,6 +856,19 @@ def add_auth(self, request):
# a separate utility module to avoid any potential circular import.
import botocore.crt.auth

def resolve_auth_type(auth_trait):
for auth_type in auth_trait:
if auth_type == 'smithy.api#noAuth':
return AUTH_TYPE_TO_SIGNATURE_VERSION[auth_type]
elif auth_type in AUTH_TYPE_TO_SIGNATURE_VERSION:
signature_version = AUTH_TYPE_TO_SIGNATURE_VERSION[auth_type]
if signature_version in AUTH_TYPE_MAPS:
return signature_version
else:
raise UnknownSignatureVersionError(signature_version=auth_type)
raise UnsupportedSignatureVersionError(signature_version=auth_trait)


# Defined at the bottom instead of the top of the module because the Auth
# classes weren't defined yet.
AUTH_TYPE_MAPS = {
Expand All @@ -870,3 +888,10 @@ def add_auth(self, request):
'v4-s3express-presign-post': S3ExpressPostAuth,
'bearer': BearerAuth,
}

AUTH_TYPE_TO_SIGNATURE_VERSION = {
'aws.auth#sigv4': 'v4',
'aws.auth#sigv4a': 'v4a',
'smithy.api#httpBearerAuth': 'bearer',
'smithy.api#noAuth': 'none',
}
12 changes: 8 additions & 4 deletions awscli/botocore/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from botocore import UNSIGNED, waiter, xform_name
from botocore.args import ClientArgsCreator
from botocore.auth import AUTH_TYPE_MAPS
from botocore.auth import AUTH_TYPE_MAPS, resolve_auth_type
from botocore.awsrequest import prepare_request_dict
from botocore.compress import maybe_compress_request
from botocore.config import Config
Expand Down Expand Up @@ -118,13 +118,17 @@ def create_client(self, service_name, region_name, is_secure=True,
cls = self._create_client_class(service_name, service_model)
region_name, client_config = self._normalize_fips_region(
region_name, client_config)
if auth := service_model.metadata.get('auth'):
service_signature_version = resolve_auth_type(auth)
else:
service_signature_version = service_model.metadata.get(
'signatureVersion'
)
endpoint_bridge = ClientEndpointBridge(
self._endpoint_resolver, scoped_config, client_config,
service_signing_name=service_model.metadata.get('signingName'),
config_store=self._config_store,
service_signature_version=service_model.metadata.get(
'signatureVersion'
),
service_signature_version=service_signature_version,
)
client_args = self._get_client_args(
service_model, region_name, is_secure, endpoint_url,
Expand Down

0 comments on commit d253841

Please sign in to comment.