Skip to content

Comments

feat: add KMS-backed master key encryption at rest#57

Merged
allisson merged 1 commit intomainfrom
kms
Feb 19, 2026
Merged

feat: add KMS-backed master key encryption at rest#57
allisson merged 1 commit intomainfrom
kms

Conversation

@allisson
Copy link
Owner

Introduces Key Management Service (KMS) integration for encrypting master keys at rest using external providers. Implements interface segregation pattern with domain-layer minimal interfaces and service-layer gocloud.dev integration. Supported providers: localsecrets (testing), Google Cloud KMS, AWS KMS, Azure Key Vault, and HashiCorp Vault. Master key decryption happens once at startup with no per-operation KMS calls for optimal performance.

Key changes:

  • Add KMSService and KMSKeeper interfaces to domain layer (minimal dependencies)
  • Add gocloud.dev/secrets-based KMS service with all provider drivers
  • Add KMS_PROVIDER and KMS_KEY_URI environment variables for mode selection
  • Add auto-detection logic to distinguish KMS vs legacy plaintext mode
  • Add rotate-master-key CLI command for staged master key rotation workflow
  • Add KMS flags to create-master-key (--kms-provider, --kms-key-uri)
  • Add URI masking helper to redact sensitive KMS key identifiers from logs
  • Add error validation for inconsistent KMS configuration at startup
  • Add comprehensive test coverage using localsecrets provider
  • Add KMS setup guide (docs/operations/kms-setup.md)
  • Add KMS migration checklist (docs/operations/kms-migration-checklist.md)
  • Update all docs and examples to v0.6.0 with KMS references

Security improvements:

  • Master keys now encrypted at rest when using KMS mode
  • Startup validation ensures KMS configuration consistency
  • Explicit error paths for KMS decryption failures
  • Preserved memory zeroing for decrypted master key material

Breaking changes: none (backward compatible with legacy plaintext mode) Closes enhancement for production-grade master key protection.

Introduces Key Management Service (KMS) integration for encrypting master keys
at rest using external providers. Implements interface segregation pattern with
domain-layer minimal interfaces and service-layer gocloud.dev integration.
Supported providers: localsecrets (testing), Google Cloud KMS, AWS KMS, Azure
Key Vault, and HashiCorp Vault. Master key decryption happens once at startup
with no per-operation KMS calls for optimal performance.

Key changes:
- Add KMSService and KMSKeeper interfaces to domain layer (minimal dependencies)
- Add gocloud.dev/secrets-based KMS service with all provider drivers
- Add KMS_PROVIDER and KMS_KEY_URI environment variables for mode selection
- Add auto-detection logic to distinguish KMS vs legacy plaintext mode
- Add rotate-master-key CLI command for staged master key rotation workflow
- Add KMS flags to create-master-key (--kms-provider, --kms-key-uri)
- Add URI masking helper to redact sensitive KMS key identifiers from logs
- Add error validation for inconsistent KMS configuration at startup
- Add comprehensive test coverage using localsecrets provider
- Add KMS setup guide (docs/operations/kms-setup.md)
- Add KMS migration checklist (docs/operations/kms-migration-checklist.md)
- Update all docs and examples to v0.6.0 with KMS references

Security improvements:
- Master keys now encrypted at rest when using KMS mode
- Startup validation ensures KMS configuration consistency
- Explicit error paths for KMS decryption failures
- Preserved memory zeroing for decrypted master key material

Breaking changes: none (backward compatible with legacy plaintext mode)
Closes enhancement for production-grade master key protection.
@allisson allisson merged commit e4b1924 into main Feb 19, 2026
2 checks passed
@allisson allisson deleted the kms branch February 19, 2026 21:20
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.

1 participant