feat(auth): add AWS Bedrock token provider#1854
feat(auth): add AWS Bedrock token provider#1854tbuatois wants to merge 1 commit intoopenai:masterfrom
Conversation
- Add awsBedrockTokenProvider with SigV4 presigned URL token generation - Add AWS SDK packages as optional peer dependencies - Add Bedrock usage example in README with region mismatch warning
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4a682ec2f5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const presigned = await signer.presign(request, { | ||
| expiresIn: tokenDuration, | ||
| }); |
There was a problem hiding this comment.
Validate Bedrock token TTL against service limits
tokenDuration is passed directly to signer.presign without bounds checking, so callers can request values above Bedrock’s short-term bearer-token limit (12 hours) and receive tokens that are later rejected at request time. This creates a runtime auth failure path that is avoidable and hard to diagnose from the caller side; validating/clamping to the accepted range before signing would fail fast with a clear provider error.
Useful? React with 👍 / 👎.
Changes being requested
Add AWS Bedrock support via
awsBedrockTokenProviderin the existingopenai/authmodule.What
src/auth/subject-token-providers.ts— NewawsBedrockTokenProvider()that generates SigV4 presigned URL bearer tokens using the standard AWS credential chainsrc/auth/index.ts— Re-export the new providertests/auth/subject-token-providers.test.ts— Unit tests for token generation, no-region error, missing SDK errorpackage.json— Added@aws-sdk/credential-providers,@smithy/signature-v4, and@aws-crypto/sha256-jsas optional peer dependencies (following the existingws/zodpattern)README.md— Added Bedrock section with usage exampleUsage
Design decisions
Additional context & links