Skip to content

feat: define credential validity contracts#787

Open
Xuanwo wants to merge 2 commits into
mainfrom
xuanwo/credential-validity-contract
Open

feat: define credential validity contracts#787
Xuanwo wants to merge 2 commits into
mainfrom
xuanwo/credential-validity-contract

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Jul 22, 2026

Copy link
Copy Markdown
Member

Summary

SigningCredential::is_valid() currently mixes cache freshness with exact operation usability. This can make a successful refresh return the same still-live token inside its proactive refresh window, only for the request signer to reject it. Core also interprets expires_in as a universal credential lifetime even though service authentication paths have different requirements.

This change defines is_valid() as cache freshness and is_valid_at() as exact timestamp usability. It adds SignRequest::required_valid_until() so each service owns its signing clock, interpretation of expires_in, and explicit operation headroom. The new hook has a default implementation, so normal downstream implementations remain source-compatible while adopting the new documented semantics.

Cached credentials must be both fresh and usable for the operation. Refreshed credentials only need to satisfy the exact operation deadline and are cached even when they remain inside the refresh window. Provider errors and None remain visible to the caller; Signer performs no internal retry or stale-cache fallback. Individual provider-chain fallback policies are unchanged.

The built-in credential types and signers now implement these contracts for AWS, Azure, Google, Aliyun, Huawei, Oracle, Tencent, and Volcengine, including direct-call validation and request failure atomicity.

Closes #786.

@Xuanwo
Xuanwo marked this pull request as ready for review July 22, 2026 09:02
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.

Define credential freshness and operation validity contracts

1 participant