-
Notifications
You must be signed in to change notification settings - Fork 600
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(experimentalIdentityAndAuth): release phase for services with cu…
…stomizations (#5288) * chore(codegen): update smithy-typescript commit * feat(experimentalIdentityAndAuth): release phase for services with customizations Services: - API Gateway - Glacier - Machine Learning - Route 53 - S3 Control * chore(codegen): generate clients
- Loading branch information
Steven Yuan
authored
Jan 11, 2024
1 parent
9c3e91a
commit ddc477c
Showing
52 changed files
with
1,744 additions
and
520 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
clients/client-api-gateway/src/auth/httpAuthExtensionConfiguration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { APIGatewayHttpAuthSchemeProvider } from "./httpAuthSchemeProvider"; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export interface HttpAuthExtensionConfiguration { | ||
setHttpAuthScheme(httpAuthScheme: HttpAuthScheme): void; | ||
httpAuthSchemes(): HttpAuthScheme[]; | ||
setHttpAuthSchemeProvider(httpAuthSchemeProvider: APIGatewayHttpAuthSchemeProvider): void; | ||
httpAuthSchemeProvider(): APIGatewayHttpAuthSchemeProvider; | ||
setCredentials(credentials: AwsCredentialIdentity | AwsCredentialIdentityProvider): void; | ||
credentials(): AwsCredentialIdentity | AwsCredentialIdentityProvider | undefined; | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export type HttpAuthRuntimeConfig = Partial<{ | ||
httpAuthSchemes: HttpAuthScheme[]; | ||
httpAuthSchemeProvider: APIGatewayHttpAuthSchemeProvider; | ||
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: APIGatewayHttpAuthSchemeProvider): void { | ||
_httpAuthSchemeProvider = httpAuthSchemeProvider; | ||
}, | ||
httpAuthSchemeProvider(): APIGatewayHttpAuthSchemeProvider { | ||
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(), | ||
}; | ||
}; |
137 changes: 137 additions & 0 deletions
137
clients/client-api-gateway/src/auth/httpAuthSchemeProvider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
// 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 { APIGatewayClientConfig, APIGatewayClientResolvedConfig } from "../APIGatewayClient"; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export interface APIGatewayHttpAuthSchemeParameters extends HttpAuthSchemeParameters { | ||
region?: string; | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export interface APIGatewayHttpAuthSchemeParametersProvider | ||
extends HttpAuthSchemeParametersProvider< | ||
APIGatewayClientResolvedConfig, | ||
HandlerExecutionContext, | ||
APIGatewayHttpAuthSchemeParameters, | ||
object | ||
> {} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const defaultAPIGatewayHttpAuthSchemeParametersProvider = async ( | ||
config: APIGatewayClientResolvedConfig, | ||
context: HandlerExecutionContext, | ||
input: object | ||
): Promise<APIGatewayHttpAuthSchemeParameters> => { | ||
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: APIGatewayHttpAuthSchemeParameters): HttpAuthOption { | ||
return { | ||
schemeId: "aws.auth#sigv4", | ||
signingProperties: { | ||
name: "apigateway", | ||
region: authParameters.region, | ||
}, | ||
propertiesExtractor: (config: APIGatewayClientConfig, context) => ({ | ||
/** | ||
* @internal | ||
*/ | ||
signingProperties: { | ||
config, | ||
context, | ||
}, | ||
}), | ||
}; | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export interface APIGatewayHttpAuthSchemeProvider extends HttpAuthSchemeProvider<APIGatewayHttpAuthSchemeParameters> {} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const defaultAPIGatewayHttpAuthSchemeProvider: APIGatewayHttpAuthSchemeProvider = (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?: APIGatewayHttpAuthSchemeProvider; | ||
} | ||
|
||
/** | ||
* @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: APIGatewayHttpAuthSchemeProvider; | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const resolveHttpAuthSchemeConfig = <T>( | ||
config: T & HttpAuthSchemeInputConfig & AwsSdkSigV4PreviouslyResolved | ||
): T & HttpAuthSchemeResolvedConfig => { | ||
const config_0 = resolveAwsSdkSigV4Config(config); | ||
return { | ||
...config_0, | ||
} as T & HttpAuthSchemeResolvedConfig; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.