feat: add support for S3 SSE-C (customer-provided encryption keys)#284
Open
schaurian wants to merge 1 commit into
Open
feat: add support for S3 SSE-C (customer-provided encryption keys)#284schaurian wants to merge 1 commit into
schaurian wants to merge 1 commit into
Conversation
Add an `sseCustomerKey` field to the S3 credentials that references a secret holding a base64-encoded 256-bit AES key. When set, the key is materialized to a file and passed to every barman-cloud command through the `--sse-customer-key file://` option, enabling Server-Side Encryption with Customer-provided keys (SSE-C). This is required by S3-compatible providers that only support SSE-C for encryption at rest (e.g. Hetzner Object Storage). The option is injected in the shared `appendCloudProviderOptions` chokepoint, so it applies to all barman-cloud-* commands (backup, wal-archive, wal-restore, restore, backup-list, backup-delete, check-wal-archive), and is orthogonal to the existing bucket-managed `encryption` (SSE-S3/SSE-KMS) option. The key is materialized before the auth-method branching so it works with every authentication method, including inheritFromIAMRole. Requires a barman release that ships the `--sse-customer-key` option (EnterpriseDB/barman#973). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Florian Schauer <florian@schauer.to>
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
Adds support for S3 Server-Side Encryption with Customer-provided keys (SSE-C) to the barman-cloud library.
A new optional
sseCustomerKeyfield onS3Credentialsreferences a secret holding a base64-encoded 256-bit AES key. When set, the key is materialized to a file and passed to every barman-cloud command via the--sse-customer-key file://option.This is the library-side change needed to close cloudnative-pg/plugin-barman-cloud#646 — S3-compatible providers such as Hetzner Object Storage only support SSE-C for encryption at rest, so the existing bucket-managed
encryptionfield (SSE-S3 / SSE-KMS) cannot be used with them.What changed
pkg/api/config.goSSECustomerKey *SecretKeySelectorfield onS3Credentials(+ generated deepcopy)pkg/utils/constants.goSSECustomerKeyFileLocation— the on-disk path for the materialized keypkg/credentials/env.gopkg/command/commandbuilder.go--sse-customer-key file://…in the sharedappendCloudProviderOptionspkg/command/commandbuilder_test.goDesign notes
appendCloudProviderOptions, through which every command builder already routes (barman-cloud-backup,-wal-archive,-wal-restore,-restore,-backup-list,-backup-delete,-check-wal-archive). SSE-C requires the key on every read and write, so covering the shared chokepoint avoids the classic "backups succeed but restores fail because a read path was missed" footgun.reconcileGoogleCredentials→ a/controller/...file written atomically with0600), so no new volume-mount plumbing is needed in consumers; the same code path serves both the operator and the plugin sidecar.encryption. SSE-C (customer key) and SSE-S3/SSE-KMS (bucket-managed) are independent mechanisms; this field does not touch the existingencryptionoption.envSetAWSCredentials, so it works with explicit keys, session tokens, andinheritFromIAMRole.Dependency / rollout
Runtime use requires a barman release that ships the
--sse-customer-keyoption (EnterpriseDB/barman#973, merged tomaster). This Go change is valid and tested independently of that release; the plugin can adopt it once both are released. A follow-up PR wires the field intoplugin-barman-cloud.Testing
go build ./...,go vet ./pkg/...— cleango test ./pkg/...— passing (new AWS SSE-C option specs added)gofmt/gofumpt/gci— clean🤖 Generated with Claude Code