Repository navigation
refactor(stack-kms-vendor): share one credential cache across vendors - #1557
freshtonic wants to merge 1 commit into
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true |
🦋 Changeset detectedLatest commit: f9b02c1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 19 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Mutation testing (cargo-mutants,
|
d4ca39e to
3f1228c
Compare
8f8929d to
538f2f6
Compare
The AWS, Google Cloud, Azure and Vault crates each had a copy of the same credential cache. Google Cloud and Azure also had the same access token and error types. A fix to one copy did not go to the others. stack-kms-vendor now has one generic CachedToken<P, K>. Each vendor crate declares a marker type that names its credential, its cache key and its error label. The crates keep their public names as type aliases (CachedToken, CachedCredentials, AuthError, CredentialsError) and re-export the shared AccessToken. The cache rules do not change: refresh at min(5 minutes, life / 3) before expiry, one fetch at a time, and a credential that has not expired is kept when a fetch fails. AWS credentials now also use the life / 3 rule. The cache tests are now in stack-kms-vendor, once.
538f2f6 to
f9b02c1
Compare
|
Folded into #1526 ( The plan is |
Summary
The AWS, Google Cloud, Azure and Vault crates each had a copy of the same credential cache. This cache keeps a short-lived credential (an access token, a Vault token or temporary AWS keys) and gets a new one before the old one expires. Google Cloud and Azure also had the same access-token and error types. A fix to one copy did not reach the others. This PR puts one generic cache in
stack-kms-vendorand moves all four crates onto it.Changes
stack-kms-vendor: newcredentialmodule withCachedToken<P, K>, theCredentialKind/FetchCredentialtraits,Expiring/Expiry, the sharedAccessToken, andCredentialError<K>. The generic cache tests are here, once (15 tests).CachedToken,CachedCredentials,AuthError,CredentialsError,AccessToken).futures(all four) andweb-time(Vault) dependencies removed. Both lockfiles updated.@cipherstash/authpatch (the binding compiles the vendor crates in).Behaviour changes (small)
AccessToken::from_env_lookupis gone. Use the newACCESS_TOKEN_VARIABLE(Azure already had one). The one caller, in@cipherstash/auth, is updated. These crates are not yet published.Verification
Run on the top branch of this stack (
james/kms-vendor-dispatch), on macOS:cargo fmt --all --checkandcargo clippy --workspace --all-features --all-targets -- -D warnings: pass.mise x --env test -- cargo nextest run --workspace --all-features: 1401 of 1402 pass. The one failure isstack-encrypt::ui derive_diagnostics(trybuild). It fails on every snapshot because of a local rustc wrapper that changes the paths in the compiler output. This stack does not touchstack-encrypt. CI is the check for it.mise run wasm:guest:test: 80 of 80 pass.go vet ./...andgo test -count=1 ./...inlanguages/golang: pass.pnpm --filter @cipherstash/auth test: 92 pass.pnpm --filter stash test: 1667 pass.cargo checkof the workspace and the guest (native andwasm32-wasip1) on each branch of the stack: pass.mise run wasm:wasi-checkandmise run test:doc: pass (run by the agent that wrote the change).Related
Refs #1541. Code-smell follow-up to the key vendor backend stack.