feat: define credential validity contracts#787
Open
Xuanwo wants to merge 2 commits into
Open
Conversation
Xuanwo
marked this pull request as ready for review
July 22, 2026 09:02
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
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 interpretsexpires_inas a universal credential lifetime even though service authentication paths have different requirements.This change defines
is_valid()as cache freshness andis_valid_at()as exact timestamp usability. It addsSignRequest::required_valid_until()so each service owns its signing clock, interpretation ofexpires_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
Noneremain visible to the caller;Signerperforms 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.