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

Add HttpAuthScheme interfaces for auth scheme resolution #928

Merged
merged 2 commits into from
Sep 14, 2023

Conversation

syall
Copy link
Contributor

@syall syall commented Sep 13, 2023

Issue #, if available:

N/A.

Description of changes:

  • Add additional HttpAuthScheme interfaces for auth scheme resolution
  • Update HttpAuthSchemeProviderGenerator to use new interfaces

Testing:

Expected diff in the codegen changes in smithy-typescript-codegen-test:

diff --color -Nur smithy-typescript-codegen-test/build_old/smithyprojections/smithy-typescript-codegen-test/client-experimental-identity-and-auth/typescript-codegen/src/auth/httpAuthSchemeProvider.ts smithy-typescript-codegen-test/build/smithyprojections/smithy-typescript-codegen-test/client-experimental-identity-and-auth/typescript-codegen/src/auth/httpAuthSchemeProvider.ts
--- smithy-typescript-codegen-test/build_old/smithyprojections/smithy-typescript-codegen-test/client-experimental-identity-and-auth/typescript-codegen/src/auth/httpAuthSchemeProvider.ts	2023-09-13 13:23:54
+++ smithy-typescript-codegen-test/build/smithyprojections/smithy-typescript-codegen-test/client-experimental-identity-and-auth/typescript-codegen/src/auth/httpAuthSchemeProvider.ts	2023-09-13 13:24:10
@@ -3,25 +3,23 @@
 import {
   HttpApiKeyAuthLocation,
   HttpAuthOption,
+  HttpAuthSchemeParameters,
+  HttpAuthSchemeParametersProvider,
+  HttpAuthSchemeProvider,
 } from "@smithy/experimental-identity-and-auth";
-import { HandlerExecutionContext } from "@smithy/types";
 import { normalizeProvider } from "@smithy/util-middleware";
 
 /**
  * @internal
  */
-export interface WeatherHttpAuthSchemeParameters {
-  operation?: string;
+export interface WeatherHttpAuthSchemeParameters extends HttpAuthSchemeParameters {
   region?: string;
 }
 
 /**
  * @internal
  */
-export async function defaultWeatherHttpAuthSchemeParametersProvider(
-    config: WeatherClientResolvedConfig,
-    context: HandlerExecutionContext
-): Promise<WeatherHttpAuthSchemeParameters> {
+export const defaultWeatherHttpAuthSchemeParametersProvider: HttpAuthSchemeParametersProvider<WeatherClientResolvedConfig, WeatherHttpAuthSchemeParameters> = async (config, context) => {
   return {
     operation: context.commandName,
     region: await normalizeProvider(config.region)() || (() => {
@@ -72,14 +70,12 @@
 /**
  * @internal
  */
-export interface WeatherHttpAuthSchemeProvider {
-  (authParameters: WeatherHttpAuthSchemeParameters): HttpAuthOption[];
-}
+export interface WeatherHttpAuthSchemeProvider extends HttpAuthSchemeProvider<WeatherHttpAuthSchemeParameters> {}
 
 /**
  * @internal
  */
-export function defaultWeatherHttpAuthSchemeProvider(authParameters: WeatherHttpAuthSchemeParameters): HttpAuthOption[] {
+export const defaultWeatherHttpAuthSchemeProvider: WeatherHttpAuthSchemeProvider = (authParameters) => {
   const options: HttpAuthOption[] = [];
   switch (authParameters.operation) {
     case "OnlyHttpApiKeyAuth": {

If one or more of the packages in the /packages directory has been modified, be sure yarn changeset add has been run and its output has
been committed and included in this pull request. See CONTRIBUTING.md.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@syall syall force-pushed the add-auth-scheme-resolution-interfaces branch from a268e77 to ca2a77f Compare September 13, 2023 19:33
@syall syall marked this pull request as ready for review September 13, 2023 19:42
@syall syall requested review from a team as code owners September 13, 2023 19:42
@syall syall merged commit aa52d8d into smithy-lang:main Sep 14, 2023
@syall syall deleted the add-auth-scheme-resolution-interfaces branch September 14, 2023 21:26
kstich pushed a commit to kstich/smithy-typescript that referenced this pull request Sep 28, 2023
`x-amz-user-agent` is equivalent to `user-agent` header but used only in browsers. If we don't sign `user-agent`, we shouldn't sign `x-amz-user-agent` either.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants