1+ /* *
2+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+ * SPDX-License-Identifier: Apache-2.0.
4+ */
5+ #pragma once
6+
7+ #include < smithy/identity/auth/AuthSchemeResolverBase.h>
8+ #include < smithy/identity/auth/built-in/SigV4aAuthSchemeOption.h>
9+
10+ // psuedocode draft, must be in S3 package
11+ namespace smithy {
12+ template <>
13+ class S3AuthSchemeResolver : public AuthSchemeResolverBase <DefaultAuthSchemeResolverParameters, Aws::S3::S3ClientConfiguration>
14+ {
15+ public:
16+ using ServiceAuthSchemeParameters = DefaultAuthSchemeResolverParameters;
17+ virtual ~S3AuthSchemeResolver () = default ;
18+
19+ virtual void Init (const Aws::S3::S3ClientConfiguration& config) {
20+ m_endpointProviderForAuth = Aws::MakeShared<S3EndpointProvider>(ALLOCATION_TAG);
21+ m_endpointProviderForAuth->InitBuiltInParameters (config);
22+ AWS_UNREFERENCED_PARAM (config);
23+ };
24+
25+
26+ Aws::Vector<AuthSchemeOption> resolveAuthScheme (const ServiceAuthSchemeParameters& identityProperties) override
27+ {
28+ // design step 2: skip an additional endpoint resolution call if we know the operation is always the same auth
29+ auto operationNameIt = identityProperties.find (" OperationName" );
30+ if (operationNameIt != identityProperties.end ()) {
31+ auto knownStaticAuthSchemeOption = knownStaticOperations.find (*operationNameIt);
32+ if (knownStaticAuthSchemeOption != knownStaticOperations.end ()) {
33+ return {knownStaticAuthSchemeOption.second };
34+ }
35+ }
36+
37+ Aws::Endpoint::EndpointParameters epParams = MapIdentityPropsToEpParams (identityProperties);
38+ auto resolveEpOutcome = m_endpointProviderForAuth->ResolveEndpoint (epParams);
39+ if (!resolveEpOutcome.IsSuccess ()) {
40+ TRACE_ERR ();
41+ return {};
42+ }
43+
44+ Aws::Vector<AuthSchemeOption> authSchemeOptions = BuildAuthSchemeOptionListFromEndpointResolution (resolveEpOutcome.GetResult ());
45+
46+ return authSchemeOptions;
47+ }
48+ };
49+
50+ private:
51+ std::shared_ptr<S3EndpointProviderBase> m_endpointProviderForAuth;
52+
53+ // design step 2: skip an additional endpoint resolution call if we know the operation is always the same auth
54+ UnorderedMap<String, String> knownStaticOperations;
55+
56+ }
0 commit comments