feat(storage-s3): add support for encrypted s3 uploads #13125
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.
feat(storage-s3): add support for encrypted s3 uploads
What?
This PR adds server-side encryption support for S3 uploads in the
@payloadcms/storage-s3plugin. The enhancement allows users to configure AWS KMS encryption for their S3 objects, providing an additional layer of security for uploaded files.Why?
S3 server-side encryption is a critical security feature for applications that handle sensitive data. Many enterprise applications require encryption at rest to comply with security policies and regulations. Previously, the S3 storage plugin didn't support configuring encryption parameters, forcing users to rely on bucket-level defaults or manual S3 configuration.
This feature addresses the need for:
How?
The implementation adds an optional
encryptionconfiguration object to the S3StorageOptions interface with the following properties:serverSideEncryption: Specifies the encryption algorithm (supports all AWS ServerSideEncryption options)kmsKeyId: Optional KMS key identifier (required for KMS encryption types)Key Changes:
Type Definitions (
src/index.ts):encryptionoption toS3StorageOptionsinterfaceServerSideEncryptiontype from AWS SDKUpload Handler (
src/handleUpload.ts):getHandleUploadto accept encryption parametersputObjectand multipart upload operationsSigned URL Generation (
src/generateSignedURL.ts):Documentation (
README.md):Usage Example:
The implementation is backward compatible - existing configurations continue to work without any changes, and encryption is only applied when explicitly configured.
Fixes #5596