Signature V4 signing utility #4972
Replies: 2 comments
-
|
Hi @zirkelc, I have blocked some time tomorrow to review this - apologies for the delay. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @zirkelc - apologies for the long delay. Thank you for putting this together, I spent some time this morning in doing a proof of concept for this and made some decisions that deviate from the original proposal but that I hope will make sense. In terms of package & layout, I think we should go for Based on the above, I also think we should start with subpath exports from day one, so future signers are pure additions and each one can bring their dependencies:
In terms of coupling, I went back & forth a lot between the proposal of coupling the fetch feature with the signer and not, and I think we should build the utility as two units that can be composed. In practice, this means a standalone This allows using In terms of In terms of dependencies, the biggest departure from the RFC proposal is that we'll lean into the Lambda runtime (and our tenets), which means we'll take a single hard dependency on
For this initial implementation we'll handle only, meaning buffers and hashes bufferable bodies (via |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is this related to an existing feature request or issue?
#2146
Which area does this RFC relate to?
New Feature: Signature V4
Summary
A native AWS SigV4 signing utility for Powertools Lambda that simplifies authenticated requests to AWS services (API Gateway, Lambda URLs, AppSync, etc.). The utility provides a class-based API with two capabilities: signing requests for use with any HTTP library, and a drop-in
fetchreplacement for automatic signing.This proposal is based on my
aws-signature-v4libraries which have been used in production environments.Use case
Lambda functions frequently need to make authenticated HTTP requests to AWS resources:
Currently, developers must:
@smithy/signature-v4This utility abstracts that complexity into a simple, idiomatic API.
Proposal
API Design
Usage Examples
Direct usage of
signer.fetch(URL):Destructure
signer.fetchto pass to libraries requiring fetch :Get signed
Requestobject for use with other libraries:Credential Resolution
In Lambda/Node.js environments, credentials are automatically resolved via the AWS SDK credential provider chain:
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY)Explicit credentials can be provided when needed:
Out of scope
Potential challenges
*.execute-api.*.amazonaws.com,*.lambda-url.*.on.aws), the service could be derived from the hostname automatically. This would makeserviceoptional in those cases. However, auto-detection won't work for custom domains or CloudFront distributions where the underlying AWS service is hidden.Dependencies and Integrations
Dependencies:
@smithy/signature-v4- Core SigV4 signing@aws-crypto/sha256-js- SHA256 hashing@aws-sdk/credential-provider-node- Auto credential resolutionIntegrations:
fetch-compatible libraryAlternative solutions
@smithy/signature-v4directly - more verbose, requires understanding internalsAcknowledgment
Future readers
Please react with 👍 and your use case to help us understand customer demand.
Beta Was this translation helpful? Give feedback.
All reactions