From 72a288f73f7654273f2a71e1c5d5671aeca547a6 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 31 Aug 2021 17:18:13 -0700 Subject: [PATCH] fix: add x-amz-server-side-encryption header in ListObjectsM (#13122) fixes #13046 --- cmd/api-response.go | 9 +++++++++ cmd/bucket-listobjects-handlers.go | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cmd/api-response.go b/cmd/api-response.go index 0bbeeb5d6..dd329a3b4 100644 --- a/cmd/api-response.go +++ b/cmd/api-response.go @@ -29,6 +29,7 @@ import ( "strings" "time" + "github.com/minio/minio/internal/crypto" "github.com/minio/minio/internal/handlers" xhttp "github.com/minio/minio/internal/http" "github.com/minio/minio/internal/logger" @@ -570,6 +571,14 @@ func generateListObjectsV2Response(bucket, prefix, token, nextToken, startAfter, content.Owner = owner if metadata { content.UserMetadata = make(StringMap) + switch kind, _ := crypto.IsEncrypted(object.UserDefined); kind { + case crypto.S3: + content.UserMetadata[xhttp.AmzServerSideEncryption] = xhttp.AmzEncryptionAES + case crypto.S3KMS: + content.UserMetadata[xhttp.AmzServerSideEncryption] = xhttp.AmzEncryptionKMS + case crypto.SSEC: + content.UserMetadata[xhttp.AmzServerSideEncryptionCustomerAlgorithm] = xhttp.AmzEncryptionAES + } for k, v := range CleanMinioInternalMetadataKeys(object.UserDefined) { if strings.HasPrefix(strings.ToLower(k), ReservedMetadataPrefixLower) { // Do not need to send any internal metadata diff --git a/cmd/bucket-listobjects-handlers.go b/cmd/bucket-listobjects-handlers.go index 5fa687dd4..cddcef755 100644 --- a/cmd/bucket-listobjects-handlers.go +++ b/cmd/bucket-listobjects-handlers.go @@ -128,7 +128,7 @@ func (api objectAPIHandlers) ListObjectVersionsHandler(w http.ResponseWriter, r // ListObjectsV2MHandler - GET Bucket (List Objects) Version 2 with metadata. // -------------------------- -// This implementation of the GET operation returns some or all (up to 10000) +// This implementation of the GET operation returns some or all (up to 1000) // of the objects in a bucket. You can use the request parameters as selection // criteria to return a subset of the objects in a bucket. // @@ -195,7 +195,7 @@ func (api objectAPIHandlers) ListObjectsV2MHandler(w http.ResponseWriter, r *htt // ListObjectsV2Handler - GET Bucket (List Objects) Version 2. // -------------------------- -// This implementation of the GET operation returns some or all (up to 10000) +// This implementation of the GET operation returns some or all (up to 1000) // of the objects in a bucket. You can use the request parameters as selection // criteria to return a subset of the objects in a bucket. // @@ -305,7 +305,7 @@ func proxyRequestByNodeIndex(ctx context.Context, w http.ResponseWriter, r *http // ListObjectsV1Handler - GET Bucket (List Objects) Version 1. // -------------------------- -// This implementation of the GET operation returns some or all (up to 10000) +// This implementation of the GET operation returns some or all (up to 1000) // of the objects in a bucket. You can use the request parameters as selection // criteria to return a subset of the objects in a bucket. //