[WIP] Fix pre-signed URL bug by implementing STS credentials #20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🚧 Work In Progress - Do Not Merge
This PR implements AWS STS temporary credentials to fix a fundamental bug in the current pre-signed URL approach.
The Problem
The current implementation has a critical bug:
This modifies the path of a pre-signed PUT URL, which invalidates the signature because:
The Solution: STS Credentials
Instead of pre-signed URLs, clients now:
Benefits
✅ Fixes the signature invalidation bug
✅ Works for any number of pages (no pre-signing each file)
✅ Client maintains access control (they scope IAM permissions)
✅ Time-limited credentials (15 minutes)
✅ Preflight validation ensures credentials work before processing
What's Implemented ✅
Phase 1: IAM Infrastructure
scripts/setup_iam_role.rb- Creates IAM role with proper trust policyPhase 2: Request Validation
source{bucket,key},destination{bucket,prefix},credentials{}Phase 3: Core Components (Partial)
HEADobject (validates access before download)Still TODO 🚧
Phase 3 Completion
ImageUploaderto use S3 SDK (upload_images_to_s3 method)app.rbmain handler to wire new componentsGemfileto addaws-sdk-s3gemPhase 4: Testing Scripts
scripts/generate_sts_credentials.rbPhase 5: Documentation
Phase 6: Testing
Phase 7: Cleanup
url_validator.rb(no longer needed)retry_handler.rb(S3 SDK has built-in retries)New API Request Format
{ "source": { "bucket": "my-input-bucket", "key": "pdfs/document.pdf" }, "destination": { "bucket": "my-output-bucket", "prefix": "converted/project-123/" }, "credentials": { "accessKeyId": "ASIAIOSFODNN7EXAMPLE", "secretAccessKey": "wJalrXUtnFEMI/K7MDENG/...", "sessionToken": "FQoGZXIvYXdzEPT//////////..." }, "unique_id": "client-123", "webhook": "https://example.com/webhook" }Client Workflow
Setup (one-time):
Each request:
Security Enhancements
Implementation Plan
See full plan:
.agent-os/specs/2025-11-11-sts-credentials/plan.mdEstimated remaining time: 10-12 hours
Review Checklist
Before marking ready for review:
🤖 Generated with Claude Code