Skip to content

Commit 4441129

Browse files
author
Steven Yuan
committed
feat(experimentalIdentityAndAuth): enable identity and auth for all services
1 parent 404a25b commit 4441129

File tree

202 files changed

+3206
-516
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

202 files changed

+3206
-516
lines changed

clients/client-cloudfront-keyvaluestore/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"@aws-sdk/middleware-host-header": "*",
2828
"@aws-sdk/middleware-logger": "*",
2929
"@aws-sdk/middleware-recursion-detection": "*",
30-
"@aws-sdk/middleware-signing": "*",
3130
"@aws-sdk/middleware-user-agent": "*",
3231
"@aws-sdk/region-config-resolver": "*",
3332
"@aws-sdk/signature-v4-multi-region": "*",
@@ -57,6 +56,7 @@
5756
"@smithy/util-defaults-mode-browser": "^3.0.7",
5857
"@smithy/util-defaults-mode-node": "^3.0.7",
5958
"@smithy/util-endpoints": "^2.0.4",
59+
"@smithy/util-middleware": "^3.0.3",
6060
"@smithy/util-retry": "^3.0.3",
6161
"@smithy/util-utf8": "^3.0.0",
6262
"tslib": "^2.6.2"

clients/client-cloudfront-keyvaluestore/src/CloudFrontKeyValueStoreClient.ts

+48-26
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,18 @@ import {
77
} from "@aws-sdk/middleware-host-header";
88
import { getLoggerPlugin } from "@aws-sdk/middleware-logger";
99
import { getRecursionDetectionPlugin } from "@aws-sdk/middleware-recursion-detection";
10-
import {
11-
AwsAuthInputConfig,
12-
AwsAuthResolvedConfig,
13-
getAwsAuthPlugin,
14-
resolveAwsAuthConfig,
15-
} from "@aws-sdk/middleware-signing";
1610
import {
1711
getUserAgentPlugin,
1812
resolveUserAgentConfig,
1913
UserAgentInputConfig,
2014
UserAgentResolvedConfig,
2115
} from "@aws-sdk/middleware-user-agent";
22-
import { Credentials as __Credentials } from "@aws-sdk/types";
2316
import { RegionInputConfig, RegionResolvedConfig, resolveRegionConfig } from "@smithy/config-resolver";
17+
import {
18+
DefaultIdentityProviderConfig,
19+
getHttpAuthSchemeEndpointRuleSetPlugin,
20+
getHttpSigningPlugin,
21+
} from "@smithy/core";
2422
import { getContentLengthPlugin } from "@smithy/middleware-content-length";
2523
import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint";
2624
import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry";
@@ -32,6 +30,7 @@ import {
3230
SmithyResolvedConfiguration as __SmithyResolvedConfiguration,
3331
} from "@smithy/smithy-client";
3432
import {
33+
AwsCredentialIdentityProvider,
3534
BodyLengthCalculator as __BodyLengthCalculator,
3635
CheckOptionalClientConfig as __CheckOptionalClientConfig,
3736
ChecksumConstructor as __ChecksumConstructor,
@@ -48,6 +47,12 @@ import {
4847
UserAgent as __UserAgent,
4948
} from "@smithy/types";
5049

50+
import {
51+
defaultCloudFrontKeyValueStoreHttpAuthSchemeParametersProvider,
52+
HttpAuthSchemeInputConfig,
53+
HttpAuthSchemeResolvedConfig,
54+
resolveHttpAuthSchemeConfig,
55+
} from "./auth/httpAuthSchemeProvider";
5156
import { DeleteKeyCommandInput, DeleteKeyCommandOutput } from "./commands/DeleteKeyCommand";
5257
import {
5358
DescribeKeyValueStoreCommandInput,
@@ -182,16 +187,17 @@ export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHand
182187
region?: string | __Provider<string>;
183188

184189
/**
185-
* Default credentials provider; Not available in browser runtime.
190+
* The provider populating default tracking information to be sent with `user-agent`, `x-amz-user-agent` header
186191
* @internal
187192
*/
188-
credentialDefaultProvider?: (input: any) => __Provider<__Credentials>;
193+
defaultUserAgentProvider?: Provider<__UserAgent>;
189194

190195
/**
191-
* The provider populating default tracking information to be sent with `user-agent`, `x-amz-user-agent` header
196+
* Default credentials provider; Not available in browser runtime.
197+
* @deprecated
192198
* @internal
193199
*/
194-
defaultUserAgentProvider?: Provider<__UserAgent>;
200+
credentialDefaultProvider?: (input: any) => AwsCredentialIdentityProvider;
195201

196202
/**
197203
* Value for how many times a request will be made at most in case of retry.
@@ -226,12 +232,12 @@ export interface ClientDefaults extends Partial<__SmithyConfiguration<__HttpHand
226232
*/
227233
export type CloudFrontKeyValueStoreClientConfigType = Partial<__SmithyConfiguration<__HttpHandlerOptions>> &
228234
ClientDefaults &
229-
RegionInputConfig &
230-
EndpointInputConfig<EndpointParameters> &
235+
UserAgentInputConfig &
231236
RetryInputConfig &
237+
RegionInputConfig &
232238
HostHeaderInputConfig &
233-
AwsAuthInputConfig &
234-
UserAgentInputConfig &
239+
EndpointInputConfig<EndpointParameters> &
240+
HttpAuthSchemeInputConfig &
235241
ClientInputEndpointParameters;
236242
/**
237243
* @public
@@ -246,12 +252,12 @@ export interface CloudFrontKeyValueStoreClientConfig extends CloudFrontKeyValueS
246252
export type CloudFrontKeyValueStoreClientResolvedConfigType = __SmithyResolvedConfiguration<__HttpHandlerOptions> &
247253
Required<ClientDefaults> &
248254
RuntimeExtensionsConfig &
249-
RegionResolvedConfig &
250-
EndpointResolvedConfig<EndpointParameters> &
255+
UserAgentResolvedConfig &
251256
RetryResolvedConfig &
257+
RegionResolvedConfig &
252258
HostHeaderResolvedConfig &
253-
AwsAuthResolvedConfig &
254-
UserAgentResolvedConfig &
259+
EndpointResolvedConfig<EndpointParameters> &
260+
HttpAuthSchemeResolvedConfig &
255261
ClientResolvedEndpointParameters;
256262
/**
257263
* @public
@@ -278,22 +284,28 @@ export class CloudFrontKeyValueStoreClient extends __Client<
278284
constructor(...[configuration]: __CheckOptionalClientConfig<CloudFrontKeyValueStoreClientConfig>) {
279285
const _config_0 = __getRuntimeConfig(configuration || {});
280286
const _config_1 = resolveClientEndpointParameters(_config_0);
281-
const _config_2 = resolveRegionConfig(_config_1);
282-
const _config_3 = resolveEndpointConfig(_config_2);
283-
const _config_4 = resolveRetryConfig(_config_3);
287+
const _config_2 = resolveUserAgentConfig(_config_1);
288+
const _config_3 = resolveRetryConfig(_config_2);
289+
const _config_4 = resolveRegionConfig(_config_3);
284290
const _config_5 = resolveHostHeaderConfig(_config_4);
285-
const _config_6 = resolveAwsAuthConfig(_config_5);
286-
const _config_7 = resolveUserAgentConfig(_config_6);
291+
const _config_6 = resolveEndpointConfig(_config_5);
292+
const _config_7 = resolveHttpAuthSchemeConfig(_config_6);
287293
const _config_8 = resolveRuntimeExtensions(_config_7, configuration?.extensions || []);
288294
super(_config_8);
289295
this.config = _config_8;
296+
this.middlewareStack.use(getUserAgentPlugin(this.config));
290297
this.middlewareStack.use(getRetryPlugin(this.config));
291298
this.middlewareStack.use(getContentLengthPlugin(this.config));
292299
this.middlewareStack.use(getHostHeaderPlugin(this.config));
293300
this.middlewareStack.use(getLoggerPlugin(this.config));
294301
this.middlewareStack.use(getRecursionDetectionPlugin(this.config));
295-
this.middlewareStack.use(getAwsAuthPlugin(this.config));
296-
this.middlewareStack.use(getUserAgentPlugin(this.config));
302+
this.middlewareStack.use(
303+
getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
304+
httpAuthSchemeParametersProvider: this.getDefaultHttpAuthSchemeParametersProvider(),
305+
identityProviderConfigProvider: this.getIdentityProviderConfigProvider(),
306+
})
307+
);
308+
this.middlewareStack.use(getHttpSigningPlugin(this.config));
297309
}
298310

299311
/**
@@ -304,4 +316,14 @@ export class CloudFrontKeyValueStoreClient extends __Client<
304316
destroy(): void {
305317
super.destroy();
306318
}
319+
private getDefaultHttpAuthSchemeParametersProvider() {
320+
return defaultCloudFrontKeyValueStoreHttpAuthSchemeParametersProvider;
321+
}
322+
private getIdentityProviderConfigProvider() {
323+
return async (config: CloudFrontKeyValueStoreClientResolvedConfig) =>
324+
new DefaultIdentityProviderConfig({
325+
"aws.auth#sigv4": config.credentials,
326+
"aws.auth#sigv4a": config.credentials,
327+
});
328+
}
307329
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// smithy-typescript generated code
2+
import { AwsCredentialIdentity, AwsCredentialIdentityProvider, HttpAuthScheme } from "@smithy/types";
3+
4+
import { CloudFrontKeyValueStoreHttpAuthSchemeProvider } from "./httpAuthSchemeProvider";
5+
6+
/**
7+
* @internal
8+
*/
9+
export interface HttpAuthExtensionConfiguration {
10+
setHttpAuthScheme(httpAuthScheme: HttpAuthScheme): void;
11+
httpAuthSchemes(): HttpAuthScheme[];
12+
setHttpAuthSchemeProvider(httpAuthSchemeProvider: CloudFrontKeyValueStoreHttpAuthSchemeProvider): void;
13+
httpAuthSchemeProvider(): CloudFrontKeyValueStoreHttpAuthSchemeProvider;
14+
setCredentials(credentials: AwsCredentialIdentity | AwsCredentialIdentityProvider): void;
15+
credentials(): AwsCredentialIdentity | AwsCredentialIdentityProvider | undefined;
16+
}
17+
18+
/**
19+
* @internal
20+
*/
21+
export type HttpAuthRuntimeConfig = Partial<{
22+
httpAuthSchemes: HttpAuthScheme[];
23+
httpAuthSchemeProvider: CloudFrontKeyValueStoreHttpAuthSchemeProvider;
24+
credentials: AwsCredentialIdentity | AwsCredentialIdentityProvider;
25+
}>;
26+
27+
/**
28+
* @internal
29+
*/
30+
export const getHttpAuthExtensionConfiguration = (
31+
runtimeConfig: HttpAuthRuntimeConfig
32+
): HttpAuthExtensionConfiguration => {
33+
const _httpAuthSchemes = runtimeConfig.httpAuthSchemes!;
34+
let _httpAuthSchemeProvider = runtimeConfig.httpAuthSchemeProvider!;
35+
let _credentials = runtimeConfig.credentials;
36+
return {
37+
setHttpAuthScheme(httpAuthScheme: HttpAuthScheme): void {
38+
const index = _httpAuthSchemes.findIndex((scheme) => scheme.schemeId === httpAuthScheme.schemeId);
39+
if (index === -1) {
40+
_httpAuthSchemes.push(httpAuthScheme);
41+
} else {
42+
_httpAuthSchemes.splice(index, 1, httpAuthScheme);
43+
}
44+
},
45+
httpAuthSchemes(): HttpAuthScheme[] {
46+
return _httpAuthSchemes;
47+
},
48+
setHttpAuthSchemeProvider(httpAuthSchemeProvider: CloudFrontKeyValueStoreHttpAuthSchemeProvider): void {
49+
_httpAuthSchemeProvider = httpAuthSchemeProvider;
50+
},
51+
httpAuthSchemeProvider(): CloudFrontKeyValueStoreHttpAuthSchemeProvider {
52+
return _httpAuthSchemeProvider;
53+
},
54+
setCredentials(credentials: AwsCredentialIdentity | AwsCredentialIdentityProvider): void {
55+
_credentials = credentials;
56+
},
57+
credentials(): AwsCredentialIdentity | AwsCredentialIdentityProvider | undefined {
58+
return _credentials;
59+
},
60+
};
61+
};
62+
63+
/**
64+
* @internal
65+
*/
66+
export const resolveHttpAuthRuntimeConfig = (config: HttpAuthExtensionConfiguration): HttpAuthRuntimeConfig => {
67+
return {
68+
httpAuthSchemes: config.httpAuthSchemes(),
69+
httpAuthSchemeProvider: config.httpAuthSchemeProvider(),
70+
credentials: config.credentials(),
71+
};
72+
};

0 commit comments

Comments
 (0)