-
Notifications
You must be signed in to change notification settings - Fork 583
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Steven Yuan
committed
Feb 13, 2024
1 parent
d60bf6c
commit 1aad8ce
Showing
2,610 changed files
with
97,031 additions
and
7,721 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-accessanalyzer/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 { 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
138
clients/client-accessanalyzer/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,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; | ||
}; |
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.