Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server-Side Encryption #719

Open
take-five opened this issue May 22, 2023 · 0 comments
Open

Server-Side Encryption #719

take-five opened this issue May 22, 2023 · 0 comments

Comments

@take-five
Copy link

Hi

I'd like to have the library to support SSE: https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/s3-example-server-side-encryption-with-kms.html

As far as I can tell, the way to go would be to add new public fields to the UploadedFileProperties type, like this:

// UploadedFileProperties defines all the set properties applied to future files
type UploadedFileProperties struct {
	ACL          *string // ACL defines the right to apply
	CacheControl *string // CacheControl defines the Cache-Control header
	ContentType  *string // ContentType define the Content-Type header
+	// Parameters below mirror the ones from s3.PutObjectInput type from AWS SDK
+	SSEKMSEncryptionContext *string
+	SSEKMSKeyId *string
+	ServerSideEncryption *string
}

And then copy them to the struct passed to AWS SDK in applyFileCreateProps and in applyFileWriteProps:

func applyFileCreateProps(req *s3.PutObjectInput, p *UploadedFileProperties) {
	if p.ACL != nil {
		req.ACL = p.ACL
	}

	if p.CacheControl != nil {
		req.CacheControl = p.CacheControl
	}

	if p.ContentType != nil {
		req.ContentType = p.ContentType
	}

+	if p.SSEKMSEncryptionContext != nil {
+		req.SSEKMSEncryptionContext = p.SSEKMSEncryptionContext
+	}
+
+	if p.SSEKMSKeyId != nil {
+		req.SSEKMSKeyId = p.SSEKMSKeyId
+	}
+
+	if p.ServerSideEncryption != nil {
+		req.ServerSideEncryption = p.ServerSideEncryption
+	}
}

(same code in the other function)

Couple of questions:

  • Is this approach okay with you? If so, I'd go ahead and create a PR. Although, I'm not sure how to go about testing it. Minio, which you seem to be using to mock the real S3, supports SSE with their own KMS implementation.
  • The seemingly public type seems to be undocumented. IMO, it exposes a very useful functionality. Maybe it's worth putting into examples in README?

Thanks,
Alexei

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

No branches or pull requests

1 participant