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 httpSigningMiddleware to authorize and sign requests #930

Merged
merged 2 commits into from
Sep 18, 2023

Conversation

syall
Copy link
Contributor

@syall syall commented Sep 13, 2023

Issue #, if available:

N/A.

Description of changes:

Add httpSigningMiddleware to authorize and sign requests.

Dependent on: #927, #928

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-httpSigningMiddleware branch 7 times, most recently from 7a3e922 to e519bad Compare September 15, 2023 23:16
@syall syall force-pushed the add-httpSigningMiddleware branch from e519bad to 8b31b57 Compare September 15, 2023 23:25
@syall syall marked this pull request as ready for review September 15, 2023 23:26
@syall syall requested review from a team as code owners September 15, 2023 23:26
const smithyContext: HttpSigningMiddlewareSmithyContext = getSmithyContext(context);
const scheme = smithyContext.selectedHttpAuthScheme;
if (!scheme) {
throw new Error(`No HttpAuthScheme was selected: unable to sign request`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what should someone encountering this error actually do to fix it?

Copy link
Contributor Author

@syall syall Sep 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this is all under the experimental flag experimentalIdentityAndAuth

This error is more as a precaution if the middleware was somehow used without httpAuthSchemeMiddleware.

httpAuthSchemeMiddleware (#929) should always be code-generated along-side with httpSigningMiddleware. httpAuthSchemeMiddleware throws an error if a HttpAuthScheme could not be selected.


There should always be at least 1 valid option if codegen-supported auth schemes in smithy-typescript are used, e.g. @httpBearerAuth, @httpApiKeyAuth, generic @aws.auth#sigv4. Other custom codegen-supported auth scheme implementations can also be provided (currently through the internal HttpAuthTypeScriptIntegration interface, which is subject to change).

If an auth scheme was not selected, it's likely:

  • At codegen time, an codegen-unsupported auth scheme (e.g. a custom auth trait) was used, or
  • The client was configured with httpAuthSchemes or httpAuthSchemeProvider values that didn't provide a valid selected HttpAuthScheme.

These cases should be very rare as they both require customization from either the customer codegen'ing the clients, or customizing client configs different from the default values.

Customers should probably not add custom auth traits or customize the client config values for httpAuthSchemes or httpAuthSchemeProvider without thorough testing.

@syall syall merged commit e250a10 into smithy-lang:main Sep 18, 2023
@syall syall deleted the add-httpSigningMiddleware branch September 18, 2023 20:58
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