-
Notifications
You must be signed in to change notification settings - Fork 90
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
Conversation
7a3e922
to
e519bad
Compare
e519bad
to
8b31b57
Compare
const smithyContext: HttpSigningMiddlewareSmithyContext = getSmithyContext(context); | ||
const scheme = smithyContext.selectedHttpAuthScheme; | ||
if (!scheme) { | ||
throw new Error(`No HttpAuthScheme was selected: unable to sign request`); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
orhttpAuthSchemeProvider
values that didn't provide a valid selectedHttpAuthScheme
.
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.
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 sureyarn changeset add
has been run and its output hasbeen 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.