feat(aws/sts): extract STS into a dedicated route and harden AssumeRole - #169
Open
andthezhang wants to merge 1 commit into
Open
feat(aws/sts): extract STS into a dedicated route and harden AssumeRole#169andthezhang wants to merge 1 commit into
andthezhang wants to merge 1 commit into
Conversation
Moves the inline STS stub out of iam.ts into its own routes/sts.ts and expands it for AWS SDK compatibility: - Dispatches the AWS SDK wire format: STS targets `POST /` with a form-encoded body. We claim it only when the body is a urlencoded STS form (Action=AssumeRole|GetCallerIdentity), leaving S3 wildcards untouched. Legacy `POST /sts/` is still supported. - AssumeRole honors DurationSeconds (default 3600) and validates it against STS limits (900..43200), returning a ValidationError for out-of-range or non-integer values rather than silently clamping. - Mints ASIA-prefixed credentials and reuses the IAM store's role_id / user_id when the principal exists, for stable responses. Known limitations (intentional, matching LocalStack/Moto): credentials are synthetic and not persisted, so issued AssumeRole credentials are not recognized on later requests, and GetCallerIdentity always reports the authenticated bearer user. SigV4 signatures are accepted but not verified. Tests: dedicated sts.test.ts covering AssumeRole/GetCallerIdentity over both `/sts/` and the SDK `POST /` path, DurationSeconds validation, unknown-action handling, and that non-STS `POST /` is not hijacked.
Contributor
|
@andthezhang is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Promotes the inline STS stub (previously buried in
routes/iam.ts) into its ownroutes/sts.ts, and hardens it so the official AWS SDK / boto3 work against it.What changed
POST /with a form-encoded body (not/sts/). This now dispatches STS only when the request is a urlencoded STS form (Action=AssumeRole|GetCallerIdentity), leaving S3's wildcard routes untouched. The legacyPOST /sts/path still works.DurationSecondssupport + validation.AssumeRolehonorsDurationSeconds(default 3600) and validates it against STS limits (900..43200), returning aValidationErrorfor out-of-range or non-integer values instead of silently clamping — matching real STS.ASIA-prefixed credentials and reuses the IAM store'srole_id/user_idwhen the principal already exists.routes/iam.ts.Known limitations (intentional)
Consistent with LocalStack / Moto defaults:
AssumeRoleare not recognized on subsequent requests, andGetCallerIdentityreports the authenticated bearer user rather than an assumed-role principal.These are noted so the auth model is explicit; closing them would require persisting issued credentials and parsing the SigV4 access key — out of scope here.
Tests
New
sts.test.tscoversAssumeRole/GetCallerIdentityover both/sts/and the SDKPOST /path,DurationSecondsvalidation (too low / too high / non-integer / boundary), unknown-action handling, and that a non-STSPOST /is not hijacked.pnpm --filter @emulators/aws test→ all green;type-checkclean. No new dependencies.