-
Notifications
You must be signed in to change notification settings - Fork 53.3k
fix(AWS): Fix SigV4 authentication for Bedrock, IoT Data, and other AWS services #24005
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
base: master
Are you sure you want to change the base?
fix(AWS): Fix SigV4 authentication for Bedrock, IoT Data, and other AWS services #24005
Conversation
Fixes authentication failures for AWS services where the endpoint hostname differs from the SigV4 signing service name (IoT, Bedrock). Key changes: - Add AWS_SERVICE_NAME_MAPPING for known service name mismatches: * iot-data → iotdevicegateway (IoT Data Plane) * bedrock-runtime → bedrock (Bedrock Runtime) * bedrock-agent-runtime → bedrock (Bedrock Agents) * bedrock-data-automation-runtime → bedrock (Bedrock Data Automation) - Add normalizeServiceName() function with explicit mapping + pattern fallback for future bedrock-* runtime services - Update parseAwsUrl() to normalize service names from URL hostnames - Centralize normalization in awsGetSignInOptionsAndUpdateRequest(): * Normalize all services (URL-parsed AND explicitly-provided) * Preserve explicit service parameters when provided * Single normalization point prevents inconsistencies This ensures correct SigV4 signatures for: - Direct HTTP Request nodes with AWS credentials - Custom endpoints passing service via query parameter - All current and future bedrock-*-runtime services Fixes: IoT and Bedrock HTTP requests failing with SignatureDoesNotMatch
Automatically adds Content-Type and Accept headers for Bedrock API calls when not already present, improving user experience. Bedrock APIs require application/json headers. This change prevents authentication errors caused by missing headers in HTTP Request nodes using AWS credentials with Bedrock endpoints. Only injects headers if: - Service name starts with 'bedrock' - Headers are not already set (case-insensitive check) This is a convenience feature that doesn't change existing behavior when headers are explicitly provided.
Adds 17 new test cases covering: Service normalization: - Explicit mappings (iot-data, bedrock-runtime, bedrock-agent-runtime) - Pattern matching (future bedrock-*-runtime services) - Edge cases (non-runtime bedrock services, unmapped services) - Passthrough behavior (s3, lambda, etc.) URL parsing: - Regional endpoints (bedrock-runtime, iot-data) - Global services (iam, cloudfront) - Multi-label hostnames (execute-api with API IDs) - China region domains (.amazonaws.com.cn) Integration tests: - Bedrock credential authentication flow - Service parameter preservation - Region resolution from URLs All 47 tests pass, ensuring robust handling of: - Current AWS services (IoT, Bedrock, S3, Lambda, etc.) - Future bedrock-*-runtime services - Edge cases and regional variations
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.
No issues found across 5 files
|
Hey @pvass24, Thank you for your contribution. We appreciate the time and effort you’ve taken to submit this pull request. Before we can proceed, please ensure the following: Regarding new nodes: If your node integrates with an AI service that you own or represent, please email [email protected] and we will be happy to discuss the best approach. About review timelines: Thank you again for contributing to n8n. |
…Sent operations
- Add Archive operation to archive invoices
- Add Download operation to download invoices as PDF
- Add Mark Paid operation to mark invoices as paid
- Add Mark Sent operation to mark invoices as sent
- Fix Email operation for Invoice Ninja v5 API (changed from GET /invoices/{id}/email to POST /emails endpoint)
- Update Quote email operation for v5 API compatibility
All operations support both v4 and v5 API versions.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Summary
Fixes critical AWS SigV4 authentication failures affecting Bedrock, IoT Data, and other AWS services. The root cause was a missing
serviceproperty in the signing options passed to aws4, which caused requests to sign incorrectly.This PR adds:
serviceproperty in signOptsTechnical Details
Root Cause - Missing Service Property
The Bug (utils.ts:267):
Without the
serviceproperty, the aws4 library couldn't properly calculate SigV4 signatures, resulting in 403 Forbidden errors with messages like "Credential should be scoped to correct service".Service Name Normalization
AWS services often have different names in hostnames vs. SigV4 signing:
bedrock-runtime.us-east-1.amazonaws.com→ SigV4:bedrockiot-data.us-east-1.amazonaws.com→ SigV4:iotdevicegatewaySolution: Added
AWS_SERVICE_NAME_MAPPINGandnormalizeServiceName()function with:bedrock-*-runtime)Bedrock UX Improvement
Bedrock services require
Content-Type: application/jsonandAccept: application/jsonheaders. These are now automatically injected (non-invasively) when service starts with "bedrock", eliminating manual configuration.Edge Case: IoT Data
IoT Data uses non-standard endpoints (
{account-id}-ats.iot.{region}.amazonaws.com) that can't be parsed. Users setservice=iot-dataexplicitly, which is now:iotdevicegatewayfor SigV4 signingTesting
Unit Tests (60 new tests)
Manual Testing
service=iot-data: 403 → 404 (auth success, resource not found)Test Evidence - IoT Data
Before fix:
403 - {"message":"Forbidden"}After fix:
404 - {"message":"No shadow exists with name: 'n8n-test-device'"}The 404 proves authentication succeeded (AWS accepted the signature and processed the request).
Related Linear tickets, Github issues, and Community forum posts
Directly Fixed:
Follow-up Needed:
(Lambda Function URLs use
.on.awsdomain format - needs separate enhancement)Changes
packages/nodes-base/credentials/Aws.credentials.ts
packages/nodes-base/credentials/common/aws/types.ts
AWS_SERVICE_NAME_MAPPINGconstant with explicit service mappings (lines 249-254)packages/nodes-base/credentials/common/aws/utils.ts
serviceproperty to signOpts (line 267)normalizeServiceName()function with explicit mappings + pattern matching (lines 68-82)parseAwsUrl()to normalize extracted service names (line 104)packages/nodes-base/credentials/common/aws/utils.test.ts
packages/nodes-base/credentials/test/Aws.credentials.test.ts
servicepropertyReview / Merge checklist
release/backportlabel if urgent fix neededImpact
This PR fixes 6 community-reported issues affecting Bedrock, IoT Data, Textract, and potentially other AWS services. The root cause (missing service property) affected ALL AWS SigV4 authentication when using:
Breaking Changes
None. This is a pure bug fix with backward-compatible enhancements:
Reviewer Notes
Key areas to review:
serviceproperty)Why this approach: