Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(experimentalIdentityAndAuth): release phase for services without customizations #5787

Merged
merged 5 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions clients/client-accessanalyzer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@
"@aws-sdk/middleware-host-header": "*",
"@aws-sdk/middleware-logger": "*",
"@aws-sdk/middleware-recursion-detection": "*",
"@aws-sdk/middleware-signing": "*",
"@aws-sdk/middleware-user-agent": "*",
"@aws-sdk/region-config-resolver": "*",
"@aws-sdk/types": "*",
"@aws-sdk/util-endpoints": "*",
"@aws-sdk/util-user-agent-browser": "*",
"@aws-sdk/util-user-agent-node": "*",
"@smithy/config-resolver": "^2.1.1",
"@smithy/core": "^1.3.1",
"@smithy/core": "^1.3.2",
"@smithy/fetch-http-handler": "^2.4.1",
"@smithy/hash-node": "^2.1.1",
"@smithy/invalid-dependency": "^2.1.1",
Expand All @@ -53,8 +52,9 @@
"@smithy/util-body-length-browser": "^2.1.1",
"@smithy/util-body-length-node": "^2.2.1",
"@smithy/util-defaults-mode-browser": "^2.1.1",
"@smithy/util-defaults-mode-node": "^2.1.1",
"@smithy/util-defaults-mode-node": "^2.2.0",
"@smithy/util-endpoints": "^1.1.1",
"@smithy/util-middleware": "^2.1.1",
"@smithy/util-retry": "^2.1.1",
"@smithy/util-utf8": "^2.1.1",
"tslib": "^2.5.0",
Expand Down
59 changes: 40 additions & 19 deletions clients/client-accessanalyzer/src/AccessAnalyzerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@ import {
} from "@aws-sdk/middleware-host-header";
import { getLoggerPlugin } from "@aws-sdk/middleware-logger";
import { getRecursionDetectionPlugin } from "@aws-sdk/middleware-recursion-detection";
import {
AwsAuthInputConfig,
AwsAuthResolvedConfig,
getAwsAuthPlugin,
resolveAwsAuthConfig,
} from "@aws-sdk/middleware-signing";
import {
getUserAgentPlugin,
resolveUserAgentConfig,
UserAgentInputConfig,
UserAgentResolvedConfig,
} from "@aws-sdk/middleware-user-agent";
import { Credentials as __Credentials } from "@aws-sdk/types";
import { RegionInputConfig, RegionResolvedConfig, resolveRegionConfig } from "@smithy/config-resolver";
import {
DefaultIdentityProviderConfig,
getHttpAuthSchemeEndpointRuleSetPlugin,
getHttpSigningPlugin,
} from "@smithy/core";
import { getContentLengthPlugin } from "@smithy/middleware-content-length";
import { EndpointInputConfig, EndpointResolvedConfig, resolveEndpointConfig } from "@smithy/middleware-endpoint";
import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry";
Expand All @@ -32,6 +30,7 @@ import {
SmithyResolvedConfiguration as __SmithyResolvedConfiguration,
} from "@smithy/smithy-client";
import {
AwsCredentialIdentityProvider,
BodyLengthCalculator as __BodyLengthCalculator,
CheckOptionalClientConfig as __CheckOptionalClientConfig,
ChecksumConstructor as __ChecksumConstructor,
Expand All @@ -48,6 +47,12 @@ import {
UserAgent as __UserAgent,
} from "@smithy/types";

import {
defaultAccessAnalyzerHttpAuthSchemeParametersProvider,
HttpAuthSchemeInputConfig,
HttpAuthSchemeResolvedConfig,
resolveHttpAuthSchemeConfig,
} from "./auth/httpAuthSchemeProvider";
import { ApplyArchiveRuleCommandInput, ApplyArchiveRuleCommandOutput } from "./commands/ApplyArchiveRuleCommand";
import {
CancelPolicyGenerationCommandInput,
Expand Down Expand Up @@ -279,21 +284,22 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__
useFipsEndpoint?: boolean | __Provider<boolean>;

/**
* The AWS region to which this client will send requests
* The provider populating default tracking information to be sent with `user-agent`, `x-amz-user-agent` header
* @internal
*/
region?: string | __Provider<string>;
defaultUserAgentProvider?: Provider<__UserAgent>;

/**
* Default credentials provider; Not available in browser runtime.
* @internal
* The AWS region to which this client will send requests
*/
credentialDefaultProvider?: (input: any) => __Provider<__Credentials>;
region?: string | __Provider<string>;

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

/**
* Value for how many times a request will be made at most in case of retry.
Expand Down Expand Up @@ -332,8 +338,8 @@ export type AccessAnalyzerClientConfigType = Partial<__SmithyConfiguration<__Htt
EndpointInputConfig<EndpointParameters> &
RetryInputConfig &
HostHeaderInputConfig &
AwsAuthInputConfig &
UserAgentInputConfig &
HttpAuthSchemeInputConfig &
ClientInputEndpointParameters;
/**
* @public
Expand All @@ -352,8 +358,8 @@ export type AccessAnalyzerClientResolvedConfigType = __SmithyResolvedConfigurati
EndpointResolvedConfig<EndpointParameters> &
RetryResolvedConfig &
HostHeaderResolvedConfig &
AwsAuthResolvedConfig &
UserAgentResolvedConfig &
HttpAuthSchemeResolvedConfig &
ClientResolvedEndpointParameters;
/**
* @public
Expand Down Expand Up @@ -407,8 +413,8 @@ export class AccessAnalyzerClient extends __Client<
const _config_3 = resolveEndpointConfig(_config_2);
const _config_4 = resolveRetryConfig(_config_3);
const _config_5 = resolveHostHeaderConfig(_config_4);
const _config_6 = resolveAwsAuthConfig(_config_5);
const _config_7 = resolveUserAgentConfig(_config_6);
const _config_6 = resolveUserAgentConfig(_config_5);
const _config_7 = resolveHttpAuthSchemeConfig(_config_6);
const _config_8 = resolveRuntimeExtensions(_config_7, configuration?.extensions || []);
super(_config_8);
this.config = _config_8;
Expand All @@ -417,8 +423,14 @@ export class AccessAnalyzerClient extends __Client<
this.middlewareStack.use(getHostHeaderPlugin(this.config));
this.middlewareStack.use(getLoggerPlugin(this.config));
this.middlewareStack.use(getRecursionDetectionPlugin(this.config));
this.middlewareStack.use(getAwsAuthPlugin(this.config));
this.middlewareStack.use(getUserAgentPlugin(this.config));
this.middlewareStack.use(
getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
httpAuthSchemeParametersProvider: this.getDefaultHttpAuthSchemeParametersProvider(),
identityProviderConfigProvider: this.getIdentityProviderConfigProvider(),
})
);
this.middlewareStack.use(getHttpSigningPlugin(this.config));
}

/**
Expand All @@ -429,4 +441,13 @@ export class AccessAnalyzerClient extends __Client<
destroy(): void {
super.destroy();
}
private getDefaultHttpAuthSchemeParametersProvider() {
return defaultAccessAnalyzerHttpAuthSchemeParametersProvider;
}
private getIdentityProviderConfigProvider() {
return async (config: AccessAnalyzerClientResolvedConfig) =>
new DefaultIdentityProviderConfig({
"aws.auth#sigv4": config.credentials,
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// smithy-typescript generated code
import { AwsCredentialIdentity, AwsCredentialIdentityProvider, HttpAuthScheme } from "@smithy/types";

import { AccessAnalyzerHttpAuthSchemeProvider } from "./httpAuthSchemeProvider";

/**
* @internal
*/
export interface HttpAuthExtensionConfiguration {
setHttpAuthScheme(httpAuthScheme: HttpAuthScheme): void;
httpAuthSchemes(): HttpAuthScheme[];
setHttpAuthSchemeProvider(httpAuthSchemeProvider: AccessAnalyzerHttpAuthSchemeProvider): void;
httpAuthSchemeProvider(): AccessAnalyzerHttpAuthSchemeProvider;
setCredentials(credentials: AwsCredentialIdentity | AwsCredentialIdentityProvider): void;
credentials(): AwsCredentialIdentity | AwsCredentialIdentityProvider | undefined;
}

/**
* @internal
*/
export type HttpAuthRuntimeConfig = Partial<{
httpAuthSchemes: HttpAuthScheme[];
httpAuthSchemeProvider: AccessAnalyzerHttpAuthSchemeProvider;
credentials: AwsCredentialIdentity | AwsCredentialIdentityProvider;
}>;

/**
* @internal
*/
export const getHttpAuthExtensionConfiguration = (
runtimeConfig: HttpAuthRuntimeConfig
): HttpAuthExtensionConfiguration => {
const _httpAuthSchemes = runtimeConfig.httpAuthSchemes!;
let _httpAuthSchemeProvider = runtimeConfig.httpAuthSchemeProvider!;
let _credentials = runtimeConfig.credentials;
return {
setHttpAuthScheme(httpAuthScheme: HttpAuthScheme): void {
const index = _httpAuthSchemes.findIndex((scheme) => scheme.schemeId === httpAuthScheme.schemeId);
if (index === -1) {
_httpAuthSchemes.push(httpAuthScheme);
} else {
_httpAuthSchemes.splice(index, 1, httpAuthScheme);
}
},
httpAuthSchemes(): HttpAuthScheme[] {
return _httpAuthSchemes;
},
setHttpAuthSchemeProvider(httpAuthSchemeProvider: AccessAnalyzerHttpAuthSchemeProvider): void {
_httpAuthSchemeProvider = httpAuthSchemeProvider;
},
httpAuthSchemeProvider(): AccessAnalyzerHttpAuthSchemeProvider {
return _httpAuthSchemeProvider;
},
setCredentials(credentials: AwsCredentialIdentity | AwsCredentialIdentityProvider): void {
_credentials = credentials;
},
credentials(): AwsCredentialIdentity | AwsCredentialIdentityProvider | undefined {
return _credentials;
},
};
};

/**
* @internal
*/
export const resolveHttpAuthRuntimeConfig = (config: HttpAuthExtensionConfiguration): HttpAuthRuntimeConfig => {
return {
httpAuthSchemes: config.httpAuthSchemes(),
httpAuthSchemeProvider: config.httpAuthSchemeProvider(),
credentials: config.credentials(),
};
};
138 changes: 138 additions & 0 deletions clients/client-accessanalyzer/src/auth/httpAuthSchemeProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
// smithy-typescript generated code
import {
AwsSdkSigV4AuthInputConfig,
AwsSdkSigV4AuthResolvedConfig,
AwsSdkSigV4PreviouslyResolved,
resolveAwsSdkSigV4Config,
} from "@aws-sdk/core";
import {
HandlerExecutionContext,
HttpAuthOption,
HttpAuthScheme,
HttpAuthSchemeParameters,
HttpAuthSchemeParametersProvider,
HttpAuthSchemeProvider,
} from "@smithy/types";
import { getSmithyContext, normalizeProvider } from "@smithy/util-middleware";

import { AccessAnalyzerClientConfig, AccessAnalyzerClientResolvedConfig } from "../AccessAnalyzerClient";

/**
* @internal
*/
export interface AccessAnalyzerHttpAuthSchemeParameters extends HttpAuthSchemeParameters {
region?: string;
}

/**
* @internal
*/
export interface AccessAnalyzerHttpAuthSchemeParametersProvider
extends HttpAuthSchemeParametersProvider<
AccessAnalyzerClientResolvedConfig,
HandlerExecutionContext,
AccessAnalyzerHttpAuthSchemeParameters,
object
> {}

/**
* @internal
*/
export const defaultAccessAnalyzerHttpAuthSchemeParametersProvider = async (
config: AccessAnalyzerClientResolvedConfig,
context: HandlerExecutionContext,
input: object
): Promise<AccessAnalyzerHttpAuthSchemeParameters> => {
return {
operation: getSmithyContext(context).operation as string,
region:
(await normalizeProvider(config.region)()) ||
(() => {
throw new Error("expected `region` to be configured for `aws.auth#sigv4`");
})(),
};
};

function createAwsAuthSigv4HttpAuthOption(authParameters: AccessAnalyzerHttpAuthSchemeParameters): HttpAuthOption {
return {
schemeId: "aws.auth#sigv4",
signingProperties: {
name: "access-analyzer",
region: authParameters.region,
},
propertiesExtractor: (config: AccessAnalyzerClientConfig, context) => ({
/**
* @internal
*/
signingProperties: {
config,
context,
},
}),
};
}

/**
* @internal
*/
export interface AccessAnalyzerHttpAuthSchemeProvider
extends HttpAuthSchemeProvider<AccessAnalyzerHttpAuthSchemeParameters> {}

/**
* @internal
*/
export const defaultAccessAnalyzerHttpAuthSchemeProvider: AccessAnalyzerHttpAuthSchemeProvider = (authParameters) => {
const options: HttpAuthOption[] = [];
switch (authParameters.operation) {
default: {
options.push(createAwsAuthSigv4HttpAuthOption(authParameters));
}
}
return options;
};

/**
* @internal
*/
export interface HttpAuthSchemeInputConfig extends AwsSdkSigV4AuthInputConfig {
/**
* experimentalIdentityAndAuth: Configuration of HttpAuthSchemes for a client which provides default identity providers and signers per auth scheme.
* @internal
*/
httpAuthSchemes?: HttpAuthScheme[];

/**
* experimentalIdentityAndAuth: Configuration of an HttpAuthSchemeProvider for a client which resolves which HttpAuthScheme to use.
* @internal
*/
httpAuthSchemeProvider?: AccessAnalyzerHttpAuthSchemeProvider;
}

/**
* @internal
*/
export interface HttpAuthSchemeResolvedConfig extends AwsSdkSigV4AuthResolvedConfig {
/**
* experimentalIdentityAndAuth: Configuration of HttpAuthSchemes for a client which provides default identity providers and signers per auth scheme.
* @internal
*/
readonly httpAuthSchemes: HttpAuthScheme[];

/**
* experimentalIdentityAndAuth: Configuration of an HttpAuthSchemeProvider for a client which resolves which HttpAuthScheme to use.
* @internal
*/
readonly httpAuthSchemeProvider: AccessAnalyzerHttpAuthSchemeProvider;
}

/**
* @internal
*/
export const resolveHttpAuthSchemeConfig = <T>(
config: T & HttpAuthSchemeInputConfig & AwsSdkSigV4PreviouslyResolved
): T & HttpAuthSchemeResolvedConfig => {
const config_0 = resolveAwsSdkSigV4Config(config);
return {
...config_0,
} as T & HttpAuthSchemeResolvedConfig;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import { AwsRegionExtensionConfiguration } from "@aws-sdk/types";
import { HttpHandlerExtensionConfiguration } from "@smithy/protocol-http";
import { DefaultExtensionConfiguration } from "@smithy/types";

import { HttpAuthExtensionConfiguration } from "./auth/httpAuthExtensionConfiguration";

/**
* @internal
*/
export interface AccessAnalyzerExtensionConfiguration
extends HttpHandlerExtensionConfiguration,
DefaultExtensionConfiguration,
AwsRegionExtensionConfiguration {}
AwsRegionExtensionConfiguration,
HttpAuthExtensionConfiguration {}
Loading
Loading