Repository navigation
feat(db): AWS typed credentials, regional endpoints and a request signer - #2307
Merged
Merged
Conversation
Add the AWS pieces a JSON or Query API provider needs, with no consumer yet: parseAwsRegion and awsServiceOrigin for the commercial partition, resolveAwsCredentials and awsCredentialSecrets for typed keys with an optional session token, and createAwsSigner, the text-transport signing policy. The SigV4 core gains payloadSha256 and sigV4Headers. The signer is held by the nine in-policy POST vectors of the AWS SigV4 suite and by a loopback test through the real text transport.
…e region docs The signer signs the query as sent, so it now refuses one that is not RFC 3986-encoded instead of signing a canonical form AWS does not compute. The endpoints docblock and DB_AUTH.md no longer claim the European Sovereign Cloud's region is quoted, the regionRegex provenance no longer points at a transitive bun.lock entry, and ARCHITECTURE.md describes the whole aws/ folder. Tests pin the provider label on both region refusals, the region-quoting edges and the frozen pair-only credentials.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
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.



Adds the AWS pieces a provider needs to call an AWS JSON or Query API (DynamoDB, Athena, Redshift's credential calls) under
src/lib/db/auth/aws/, so the first AWS provider wires tested code instead of writing its own region, key and signing rules.Nothing calls it yet: no provider, route or setting changes.
What changes
aws/endpoints.tsis new:parseAwsRegionadmits a region of the commercialawspartition by AWS's ownregionRegex(source pinned in the docblock), refuses a blank value, quotes a refused value only when it is shaped as a region name (cn-north-1,us-gov-west-1), and never quotes any other value, such as a secret pasted into the wrong field.awsServiceOrigin(service, region)giveshttps://<service>.<region>.amazonaws.com:443, refusing a malformed service name and a regionparseAwsRegiondid not return.AWS_SIGNING_REGIONis the scope rule an emulator region must meet.aws/credentials.tsis new:resolveAwsCredentialstakes typed keys only, with an optional session token, and refuses an empty pair, a token without a pair, half a pair and every value outside its format rule, with sentences that quote no value.It reads no environment variable, file, profile or instance metadata.
awsCredentialSecretslists the secret, the token and the key ID forsecretForms.aws/signer.tsis new:createAwsSigneris a text-transportRequestSignerthat signs host, content-type, everyx-amz-*header,x-amz-date, the session token and the SHA-256 of the body, reads the credentials getter and the clock at send time, and refuses a path other than/and a query that is not already RFC 3986-encoded (aURLSearchParamsquery fromendpointUrlis form-encoded, so its canonical form is not the one AWS computes).aws/sigv4.tsgainsAwsCredentials,payloadSha256andsigV4Headers, which buildsauthorization,x-amz-dateandx-amz-security-token.The existing functions and S3's signer are unchanged.
docs/ARCHITECTURE.mddescribesaws/as the SigV4 core, regions and endpoints, typed credentials and the request signer.docs/DB_AUTH.mddescribes regions and endpoints, typed credentials, the request signer, and what is designed but not yet built (a refreshing source, AssumeRole, the server's own identity).docs/SECURITY.mdrow 3.40, the shared auth layer's control, gains the AWS part: typed keys only with no ambient source, endpoints only for the commercialawspartition, a refused region quoted only when shaped as a region name, the signer's refusal of a path other than/and of a query that is not RFC 3986-encoded, and refusals that quote no key, secret or token.Its Enforced in and Verified by columns list the four
aws/files and their tests.User-visible change
None.
Test plan
Each new test file was run red against the missing module first.
The signer test feeds the nine POST vectors of the AWS SigV4 suite whose signed set is the signer's policy to
sign()directly and reproduces eachAuthorization; the three outside the policy are named with their reasons.A loopback test sends JSON and form requests through a real text transport and checks the
Authorizationreceived against one recomputed withsignatureV4from what the listener received.A signer test signs the suite's
get-vanilla-query-unreservedvector from an RFC 3986 query, and a loopback test shows a query with~,*and a space signs when built withrfc3986Queryand is refused, with nothing sent, when built byendpointUrlfromURLSearchParams.The four new and changed
aws/files are fully line-covered by their own tests.The full test, coverage, build,
build:lib,attwand extension gates run in CI.