Skip to content

feat(rest): add a SigV4 auth manager over a delegate session - #3092

Draft
plusplusjiajia wants to merge 7 commits into
apache:mainfrom
plusplusjiajia:feat/rest-sigv4-session
Draft

feat(rest): add a SigV4 auth manager over a delegate session#3092
plusplusjiajia wants to merge 7 commits into
apache:mainfrom
plusplusjiajia:feat/rest-sigv4-session

Conversation

@plusplusjiajia

Copy link
Copy Markdown
Member

Which issue does this PR close?

Split out of #2660, stacked on #3082 — the first five commits are that PR and drop out once it merges.

What changes are included in this PR?

SigV4AuthManager wires the signer into AuthManager/AuthSession, following Java's RESTSigV4AuthManager:

  • one credential-free signer serves every session, as Java's single Aws4Signer.create() does;
  • the session holds the credentials provider and resolves it per request, like Java's resolveCredentials() inside sign, leaving caching to the provider;
  • the delegate authenticates first, so a bearer token is relocated to Original-Authorization and signed over;
  • every session method rebuilds from the properties it is given, as Java builds a fresh AwsProperties in each.

Properties use Java's names: rest.signing-region, rest.signing-name (default execute-api), rest.access-key-id, rest.secret-access-key, `rest.session-toke

The crate traces the request it signs, and its redaction list covers
`authorization` but not the `Original-` copy we make, so a delegate's
bearer token could reach trace logs. Also reject non-UTF-8 headers
rather than leave them unsigned, and hash a present-but-empty body as
Java does.
Java holds one `Aws4Signer` across sessions and resolves credentials from
an `AwsCredentialsProvider` per request, so the signer itself carries no
credential state. Follow that: drop `AwsCredentials`, take the AWS
crate's `Credentials` as a `sign` argument, and leave the provider to the
auth session.

Also sign `HttpRequest` rather than the concrete request type, name the
amz headers, split `convert_headers`/`update_request_headers` after their
Java counterparts, collapse the one-file `sigv4` module, and put the AWS
dependencies behind a `sigv4` feature.
Follows Java's `RESTSigV4AuthManager`: the manager holds one credential-free
signer for every session, while the session holds the credentials provider
and resolves it per request. The delegate authenticates first, so its bearer
token is relocated and signed over.

Static credentials come from the same properties Java reads. Anything else —
a role, a refreshing provider — is passed to `SigV4AuthManager::new`, which
takes any `SharedCredentialsProvider`.
Java builds a fresh `AwsProperties` in every session method, so a
property-built manager has to follow the merged properties in
`init_session` as well, not only in `catalog_session`.

The manager had no tests at all: nine mutations of it survived, including
inverting the rebuild condition and swapping the delegate method. Cover it
with a recording delegate, and assert the region and service through the
credential scope of a real signature rather than private fields.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant