From 0ddb4f07a2a9c5141f7adae5593e827ba006edeb Mon Sep 17 00:00:00 2001 From: Shubhendu Ram Tripathi Date: Thu, 22 Feb 2024 10:46:19 +0530 Subject: [PATCH] Added valid allowed internal headers Needed for replication of SSE-C objects to other sites while site replication. Signed-off-by: Shubhendu Ram Tripathi --- api-compose-object.go | 2 +- api-put-object.go | 4 ++-- utils.go | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/api-compose-object.go b/api-compose-object.go index e64a24458..df730d7af 100644 --- a/api-compose-object.go +++ b/api-compose-object.go @@ -119,7 +119,7 @@ func (opts CopyDestOptions) Marshal(header http.Header) { if opts.ReplaceMetadata { header.Set("x-amz-metadata-directive", replaceDirective) for k, v := range filterCustomMeta(opts.UserMetadata) { - if isAmzHeader(k) || isStandardHeader(k) || isStorageClassHeader(k) { + if isAmzHeader(k) || isStandardHeader(k) || isStorageClassHeader(k) || isValidInternalHeader(k) { header.Set(k, v) } else { header.Set("x-amz-meta-"+k, v) diff --git a/api-put-object.go b/api-put-object.go index bbd8924e2..efb050758 100644 --- a/api-put-object.go +++ b/api-put-object.go @@ -212,7 +212,7 @@ func (opts PutObjectOptions) Header() (header http.Header) { } for k, v := range opts.UserMetadata { - if isAmzHeader(k) || isStandardHeader(k) || isStorageClassHeader(k) { + if isAmzHeader(k) || isStandardHeader(k) || isStorageClassHeader(k) || isValidInternalHeader(k) { header.Set(k, v) } else { header.Set("x-amz-meta-"+k, v) @@ -230,7 +230,7 @@ func (opts PutObjectOptions) Header() (header http.Header) { // validate() checks if the UserMetadata map has standard headers or and raises an error if so. func (opts PutObjectOptions) validate() (err error) { for k, v := range opts.UserMetadata { - if !httpguts.ValidHeaderFieldName(k) || isStandardHeader(k) || isSSEHeader(k) || isStorageClassHeader(k) { + if !httpguts.ValidHeaderFieldName(k) || isStandardHeader(k) || isSSEHeader(k) || isStorageClassHeader(k) || isValidInternalHeader(k) { return errInvalidArgument(k + " unsupported user defined metadata name") } if !httpguts.ValidHeaderFieldValue(v) { diff --git a/utils.go b/utils.go index 94c19b2a5..0f3f91fc3 100644 --- a/utils.go +++ b/utils.go @@ -512,6 +512,20 @@ func isAmzHeader(headerKey string) bool { return strings.HasPrefix(key, "x-amz-meta-") || strings.HasPrefix(key, "x-amz-grant-") || key == "x-amz-acl" || isSSEHeader(headerKey) || strings.HasPrefix(key, "x-amz-checksum-") } +var supportedInternalHeaders = map[string]bool{ + "x-minio-internal-server-side-encryption-sealed-key": true, + "x-minio-internal-inline-data": true, + "x-minio-internal-server-side-encryption-seal-algorithm": true, + "x-minio-internal-server-side-encryption-iv": true, + // Add more supported headers here. + // Must be lower case. +} + +// isValidInternalHeader returns true if header is one of valid internal headers +func isValidInternalHeader(headerKey string) bool { + return supportedInternalHeaders[strings.ToLower(headerKey)] +} + // supportedQueryValues is a list of query strings that can be passed in when using GetObject. var supportedQueryValues = map[string]bool{ "attributes": true,