Skip to content

feat(tencent-cos): add STS GetFederationToken granter - #955

Merged
Xuanwo merged 2 commits into
mainfrom
xuanwo/tencent-sts-federation-token
Nov 19, 2026
Merged

Xuanwo merged 2 commits into
mainfrom
xuanwo/tencent-sts-federation-token

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Implements the Tencent Cloud STS GetFederationToken item in #807. Part of #807; this does not close the tracker.

GetFederationTokenGrant binds the caller-supplied Name and raw CAM Policy. Name is validated as ASCII letters only. Policy is URL-encoded exactly once in the wire field before the request is serialized and signed. GetFederationTokenGranter consumes the source through Granter, signs the Tencent Cloud API 3.0 request with TC3-HMAC-SHA256, and returns the existing Credential with the response ExpiredTime as an exact epoch expiration. expires_in maps to DurationSeconds; None omits it and uses the service default. The API only accepts permanent keys, so a source with a security token or expiration is rejected before I/O, as is an invalid duration or grant. Granted output is never cached.

The service default of 1800 seconds is shorter than the COS signer's default 3600-second header-signing lifetime. Tests cover that mismatch and a 7200-second grant that the existing signer accepts with its default settings; the signer's lifetime checks and defaults are unchanged. The granter is isolated from AssumeRoleWithWebIdentityCredentialProvider and the default credential chain. No core abstraction, default-provider behavior, or permissions defaults change.

Testing uses a synthetic source credential and a local mock HttpSend: exact request fields and a golden TC3 signature over the encoded policy; literal reserved characters and policy round-trip; source, duration, and name/grant validation before I/O; post-I/O expiration; API and non-200 error redaction; and consumption by the existing COS RequestSigner. Live-service coverage remains separate under #825.

Validation: cargo test -p reqsign-tencent-cos, cargo clippy -p reqsign-tencent-cos --all-targets -- -D warnings, cargo check -p reqsign-tencent-cos --target wasm32-unknown-unknown, and hawkeye check pass locally.

Part of #807.

Adds GetFederationTokenGrant and GetFederationTokenGranter for Tencent Cloud
STS. The granter consumes a permanent source credential, signs a
TC3-HMAC-SHA256 GetFederationToken request with the caller-supplied Name and
CAM Policy, and returns the existing COS Credential with the exact ExpiredTime
epoch expiration. expires_in maps to DurationSeconds; granted output is never
cached.

Tests cover the exact request fields, TC3 signature, permanent-source and
duration validation, post-I/O expiration, error and Debug redaction, and
consumption by the existing COS signer. The granter is isolated from the
web-identity provider and default credential chain.
URL-encode the raw CAM policy exactly once in the Policy wire field and sign
the actual serialized request. Validate the documented ASCII-letter Name
constraint and align the example and tests.

Add offline coverage for literal reserved characters, policy round-trip,
invalid names, and the COS signer lifetime mismatch: the API default
1800-second grant cannot cover the signer's default 3600-second header
lifetime, while a 7200-second grant can and a shorter explicit lifetime
selects query signing.
@Xuanwo
Xuanwo merged commit f5717cc into main Nov 19, 2026
66 checks passed
@Xuanwo
Xuanwo deleted the xuanwo/tencent-sts-federation-token branch November 19, 2026 12:29
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.

2 participants