feat: add GCP Cloud KMS backend, make secrets backend a runtime toggle - #83
Open
itsharshvb wants to merge 5 commits into
Open
feat: add GCP Cloud KMS backend, make secrets backend a runtime toggle#83itsharshvb wants to merge 5 commits into
itsharshvb wants to merge 5 commits into
Conversation
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
src/crypto/gcp.rsimplements theCryptotrait directly against thegoogle-cloud-kmsSDK, mirroringsrc/crypto/aws.rs's shape exactly (inline SDK calls, no intermediate abstraction) —src/services/gcp/config.rsis a thin config + client holder, same role assrc/services/aws/config.rs.cfg!()precedence chain to a config-driven runtime toggle:secrets.manager = "aws_kms" | "gcp_kms" | "hashicorp_vault" | "aes_local"in TOML, mirroringhyperswitch/hyperswitch-card-vault'sSecretsManagementConfigpattern.aws/vault/gcpare now real optional-dependency feature gates, so any combination can ship in one binary and config decides which backend runs at startup.Secrets::create_keymanager_clientnow returns aResultand propagates client-construction failure with?, instead of panicking internally — matching hyperswitch's ownget_encryption_management_client(crates/external_services/src/managers/encryption_management.rs). The panic boundary moved to the actual boot call site inSessionState::from_config(src/app.rs), which already panicked there for thread-pool build failures.src/crypto/kms.rsrenamed tosrc/crypto/aws.rs— "kms" was ambiguous once GCP KMS existed too; matchessrc/crypto/gcp.rs's naming.docs/encryption-key-management-flow.md: the two-layer architecture (bootstrap secrets vs. live DEK management), why cripta uses one trait pair instead of hyperswitch's two, the envelope-encryption data flow, a backend comparison table, and an extension checklist for adding a future backend.config/development.tomlcurrently pointssecrets.managerat a real AWS KMS key (account143555788000, regionap-south-1) with the DB password re-encrypted as AWS KMS ciphertext;aes_localis left commented as a credential-free fallback. A GCP KMS dev key was also configured and fully verified earlier in development before switching the committed example to AWS.config/development.tomlandconfig/config.example.tomlboth document (commented out by default) afiltering_directiverequired whenmanager = "aws_kms"— see "Notes for reviewers" below.Test Plan
cargo hack check --each-feature --all-targets— clean on stable and MSRV 1.92.0cargo clippy --all-features --all-targets -- -D warnings— cleancargo test --all-features— passescargo +nightly fmt --all --check— cleanPOST /key/create→POST /data/encrypt→POST /data/decrypt, confirmeddata_key_store.source = GcpKmsdata_key_store.source = KMSfor aws
for Gcp