@@ -308,6 +308,36 @@ impl fmt::Debug for AzureStorageConfig {
308308 }
309309}
310310
311+ #[ derive( Clone , Eq , PartialEq , Serialize , Deserialize ) ]
312+ #[ serde( tag = "type" , rename_all = "snake_case" ) ]
313+ pub enum S3EncryptionConfig {
314+ /// This is the standard AES256 SSE-C header config. Key is expected to be a
315+ /// 256bit base64-encoded string, and key_md5 is expected to be the
316+ /// base64-encoded MD5 digest of the (binary) key. Akamai gen1 buckets don't
317+ /// respect this (only the a 32 hex char key is expected).
318+ SseC {
319+ key : String ,
320+ key_md5 : String ,
321+ read_only : bool ,
322+ } ,
323+ }
324+
325+ impl fmt:: Debug for S3EncryptionConfig {
326+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
327+ match self {
328+ S3EncryptionConfig :: SseC {
329+ key_md5, read_only, ..
330+ } => f
331+ . debug_struct ( "S3EncryptionConfig" )
332+ . field ( "type" , & "sse_c" )
333+ . field ( "key" , & "***redacted***" )
334+ . field ( "key_md5" , key_md5)
335+ . field ( "read_only" , read_only)
336+ . finish ( ) ,
337+ }
338+ }
339+ }
340+
311341#[ derive( Clone , Default , Eq , PartialEq , Serialize , Deserialize ) ]
312342#[ serde( deny_unknown_fields) ]
313343pub struct S3StorageConfig {
@@ -329,6 +359,8 @@ pub struct S3StorageConfig {
329359 pub disable_multi_object_delete : bool ,
330360 #[ serde( default ) ]
331361 pub disable_multipart_upload : bool ,
362+ #[ serde( default ) ]
363+ pub encryption : Option < S3EncryptionConfig > ,
332364}
333365
334366impl S3StorageConfig {
@@ -685,4 +717,31 @@ mod tests {
685717 assert_eq ! ( s3_storage_config. flavor, Some ( StorageBackendFlavor :: MinIO ) ) ;
686718 }
687719 }
720+
721+ #[ test]
722+ fn test_storage_s3_config_encryption_serde ( ) {
723+ {
724+ let s3_storage_config_yaml = r#"
725+ endpoint: http://localhost:4566
726+ encryption:
727+ type: sse_c
728+ key: test-customer-key
729+ key_md5: test-customer-key-md5
730+ read_only: true
731+ "# ;
732+ let s3_storage_config: S3StorageConfig =
733+ serde_yaml:: from_str ( s3_storage_config_yaml) . unwrap ( ) ;
734+
735+ let expected_s3_config = S3StorageConfig {
736+ endpoint : Some ( "http://localhost:4566" . to_string ( ) ) ,
737+ encryption : Some ( S3EncryptionConfig :: SseC {
738+ key : "test-customer-key" . to_string ( ) ,
739+ key_md5 : "test-customer-key-md5" . to_string ( ) ,
740+ read_only : true ,
741+ } ) ,
742+ ..Default :: default ( )
743+ } ;
744+ assert_eq ! ( s3_storage_config, expected_s3_config) ;
745+ }
746+ }
688747}
0 commit comments