feat(crypto): GCP / Azure / Vault KMS providers (Step 6.7c) - #157
Merged
officialCodeWork merged 1 commit intoJun 8, 2026
Merged
Conversation
Complete the four-provider BYOK KMS matrix. Each new provider subclasses EnvelopeKeyManager (inheriting the DEK + AES-GCM + tenant-AAD + envelope framing) and only wraps/unwraps the DEK via its KMS API: - GcpKmsKeyManager — google-cloud-kms encrypt/decrypt, shared async client. - AzureKeyVaultKeyManager — azure-keyvault-keys wrap_key/unwrap_key (RSA-OAEP-256); a CryptographyClient per key via a cached factory (Azure binds a client to one key). - VaultKeyManager — HashiCorp Vault Transit encrypt_data/decrypt_data (sync hvac run in a thread, configurable mount_point). Each is behind a [kms-gcp] / [kms-azure] / [kms-vault] extra (SDKs lazy-imported, so the modules import without the SDK and selecting a provider without its extra raises a clear ImportError). An injectable client / client_factory seam makes every provider fully unit-testable with a fake KMS — no cloud creds/network. Connection uses each SDK's standard credential discovery; per-tenant key resolution + sealing (KeyUnavailableError) are uniform with AWS. KmsProvider enum + build_key_manager_from_config factory + KmsConfig.vault_mount extended; mypy overrides added for the three SDK module trees. Scope: providers only — key rotation is 6.7d; wiring EncryptingStorage into the ingest path stays deferred (tiered storage). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
Completes the four-provider BYOK KMS matrix. Each new provider subclasses
EnvelopeKeyManager(inheriting the DEK + AES-256-GCM + tenant-AAD + envelope framing from 6.7a) and only wraps/unwraps the DEK via its KMS API:GcpKmsKeyManager— google-cloud-kmsencrypt/decrypt(shared async client).AzureKeyVaultKeyManager— azure-keyvault-keyswrap_key/unwrap_key(RSA-OAEP-256); aCryptographyClientper key via a cached factory (Azure binds a client to one key).VaultKeyManager— HashiCorp Vault Transitencrypt_data/decrypt_data(synchvacrun in a thread, configurablemount_point).Each is behind a
[kms-gcp]/[kms-azure]/[kms-vault]extra — the SDKs are lazy-imported, so the modules import without the SDK and selecting a provider without its extra raises a clearImportError. An injectableclient/client_factoryseam makes every provider fully unit-testable with a fake KMS — no cloud creds / network. Connection uses each SDK's standard credential discovery (GCP ADC, AzureDefaultAzureCredential, VaultVAULT_ADDR/VAULT_TOKEN); per-tenant key resolution + sealing (KeyUnavailableError) are uniform with AWS.KmsProviderenum +build_key_manager_from_configfactory +KmsConfig.vault_mountextended; mypy overrides added for the three SDK module trees (absent at lint time).Scope / deferred: providers only. 6.7d — zero-downtime key rotation (closes Step 6.7). Wiring
EncryptingStorageinto the ingest path stays deferred (tiered storage).Tests & gates
tests/kms/test_cloud_providers.py— round-trip, per-tenant key-bound cross-tenant block, sealing, SDK-error → KeyUnavailableError); factory cloud-provider-requires-extra contract.tests/ packages/2362 passed, 1 skipped; gateway 290 passed (+1, no regression). Green: ruff,mypy --strict(309 files), RAG001, policy-coverage, log-schema; only the intendeddist/rag.schema.*regen.Documentation
Test plan
uv run pytest tests/ packages/ -m "not integration"— 2362 passed, 1 skippeduv run pytest apps/gateway/tests— 290 passedmypy --strict(309) + RAG001 + policy-coverage + log-schema; config schema-drift regenerated🤖 Generated with Claude Code