Skip to content

Commit 225ff31

Browse files
committed
Merge branch 'main' into jbe/sbs
2 parents accd1a6 + ea415de commit 225ff31

File tree

449 files changed

+11301
-1417
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

449 files changed

+11301
-1417
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import PackageDescription
1515

1616
// MARK: - Dynamic Content
1717

18-
let clientRuntimeVersion: Version = "0.111.0"
18+
let clientRuntimeVersion: Version = "0.112.0"
1919
let crtVersion: Version = "0.43.0"
2020

2121
let excludeRuntimeUnitTests = false

Package.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.6
1+
1.2.11

Package.version.next

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.7
1+
1.2.12
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Compatibility with "S3-like" third-party storage services
2+
3+
## Background
4+
5+
Recently, AWS SDK for Swift dropped MD5 for payload checksums, in favor of more
6+
modern and secure algorithms. This has caused problems when accessing certain
7+
operations on "S3-like" third-party cloud storage services that claim to be
8+
API-compatible with AWS S3. To our knowledge, this affects only the S3
9+
`DeleteObjects` operation.
10+
11+
## Example Code
12+
13+
If you are having issues with accessing such third-party services, the following interceptor
14+
code can be used to force the SDK to hash `DeleteObjects` request bodies with MD5:
15+
16+
```swift
17+
class DeleteObjectsMD5InterceptorProvider: HttpInterceptorProvider {
18+
19+
class DeleteObjectsMD5Interceptor<InputType, OutputType>: Interceptor {
20+
typealias RequestType = HTTPRequest
21+
typealias ResponseType = HTTPResponse
22+
23+
let MD5_HEADER = "Content-MD5"
24+
let OTHER_CHECKSUMS_PREFIX = "x-amz-checksum-"
25+
let OTHER_CHECKSUMS_SDK_PREFIX = "x-amz-sdk-checksum-"
26+
27+
func readAfterSerialization(context: some AfterSerialization<InputType, HTTPRequest>) async throws {
28+
let request = context.getRequest()
29+
30+
// Read the request body into memory. Note that this may cause excess memory usage
31+
// when used with large request bodies.
32+
let bodyData: Data?
33+
switch request.body {
34+
case .stream(let stream):
35+
bodyData = try await stream.readToEndAsync()
36+
case .data:
37+
return // body is already in-memory data, no change needed
38+
case .noStream:
39+
bodyData = nil
40+
}
41+
42+
// Re-assign the request body using in-memory data instead of a stream.
43+
request.body = .data(bodyData)
44+
}
45+
46+
func modifyBeforeSigning(context: some MutableRequest<InputType, HTTPRequest>) async throws {
47+
let attributes = context.getAttributes()
48+
let request = context.getRequest()
49+
let body = request.body
50+
51+
// Leave request unmodified if not S3 DeleteObjects
52+
guard attributes.getServiceName() == "S3", attributes.getOperation() == "deleteObjects" else { return }
53+
54+
// Remove all checksum-related headers & trailing headers
55+
let checksumHeaders = request.headers.headers.map { $0.name }.filter { $0.hasPrefix(OTHER_CHECKSUMS_PREFIX) }
56+
checksumHeaders.forEach { request.headers.remove(name: $0) }
57+
let checksumSDKHeaders = request.headers.headers.map { $0.name }.filter { $0.hasPrefix(OTHER_CHECKSUMS_SDK_PREFIX) }
58+
checksumSDKHeaders.forEach { request.headers.remove(name: $0) }
59+
let checksumTrailingHeaders = request.trailingHeaders.headers.map { $0.name }.filter { $0.hasPrefix(OTHER_CHECKSUMS_PREFIX) }
60+
checksumTrailingHeaders.forEach { request.headers.remove(name: $0) }
61+
62+
// If the body is in-memory data, set a MD5 header for the data.
63+
if case .data(let data) = body, let data {
64+
let md5data = try data.computeMD5()
65+
request.headers.add(name: MD5_HEADER, value: md5data.base64EncodedString())
66+
}
67+
}
68+
}
69+
70+
func create<InputType, OutputType>() -> any Interceptor<InputType, OutputType, HTTPRequest, HTTPResponse> {
71+
return DeleteObjectsMD5Interceptor()
72+
}
73+
}
74+
```
75+
76+
Configure your S3 client with the interceptor as follows. Feel free to add any other
77+
needed configuration:
78+
```swift
79+
let config = try await S3Client.Config(
80+
region: "us-east-1", // substitute your region here
81+
httpInterceptorProviders: [DeleteObjectsMD5InterceptorProvider()]
82+
)
83+
let client = S3Client(config: config)
84+
```
85+
86+
## Usage Notes
87+
88+
- This code reads the entire request body into memory to perform the MD5 hashing.
89+
This may cause performance issues when the request is extremely large.
90+
- The interceptor only modifies requests to S3 `DeleteObjects`. All other requests
91+
are sent without modification.
92+
- If your "S3-like" storage service supports the SDK's new checksum options, or adds
93+
support in the future, we recommend not using the interceptor.
94+
- Do not use this interceptor with any AWS service, including AWS S3, or with any
95+
third-party service other than a "S3-like" storage service.

Sources/Services/AWSACM/Sources/AWSACM/ACMClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ import typealias SmithyHTTPAuthAPI.AuthSchemes
6666

6767
public class ACMClient: ClientRuntime.Client {
6868
public static let clientName = "ACMClient"
69-
public static let version = "1.2.6"
69+
public static let version = "1.2.11"
7070
let client: ClientRuntime.SdkHttpClient
7171
let config: ACMClient.ACMClientConfiguration
7272
let serviceName = "ACM"

Sources/Services/AWSACMPCA/Sources/AWSACMPCA/ACMPCAClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ import typealias SmithyHTTPAuthAPI.AuthSchemes
6666

6767
public class ACMPCAClient: ClientRuntime.Client {
6868
public static let clientName = "ACMPCAClient"
69-
public static let version = "1.2.6"
69+
public static let version = "1.2.11"
7070
let client: ClientRuntime.SdkHttpClient
7171
let config: ACMPCAClient.ACMPCAClientConfiguration
7272
let serviceName = "ACM PCA"

Sources/Services/AWSAPIGateway/Sources/AWSAPIGateway/APIGatewayClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ import typealias SmithyHTTPAuthAPI.AuthSchemes
7070

7171
public class APIGatewayClient: ClientRuntime.Client {
7272
public static let clientName = "APIGatewayClient"
73-
public static let version = "1.2.6"
73+
public static let version = "1.2.11"
7474
let client: ClientRuntime.SdkHttpClient
7575
let config: APIGatewayClient.APIGatewayClientConfiguration
7676
let serviceName = "API Gateway"

Sources/Services/AWSARCZonalShift/Sources/AWSARCZonalShift/ARCZonalShiftClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ import typealias SmithyHTTPAuthAPI.AuthSchemes
6666

6767
public class ARCZonalShiftClient: ClientRuntime.Client {
6868
public static let clientName = "ARCZonalShiftClient"
69-
public static let version = "1.2.6"
69+
public static let version = "1.2.11"
7070
let client: ClientRuntime.SdkHttpClient
7171
let config: ARCZonalShiftClient.ARCZonalShiftClientConfiguration
7272
let serviceName = "ARC Zonal Shift"

Sources/Services/AWSAccessAnalyzer/Sources/AWSAccessAnalyzer/AccessAnalyzerClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ import typealias SmithyHTTPAuthAPI.AuthSchemes
6767

6868
public class AccessAnalyzerClient: ClientRuntime.Client {
6969
public static let clientName = "AccessAnalyzerClient"
70-
public static let version = "1.2.6"
70+
public static let version = "1.2.11"
7171
let client: ClientRuntime.SdkHttpClient
7272
let config: AccessAnalyzerClient.AccessAnalyzerClientConfiguration
7373
let serviceName = "AccessAnalyzer"

Sources/Services/AWSAccount/Sources/AWSAccount/AccountClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ import typealias SmithyHTTPAuthAPI.AuthSchemes
6464

6565
public class AccountClient: ClientRuntime.Client {
6666
public static let clientName = "AccountClient"
67-
public static let version = "1.2.6"
67+
public static let version = "1.2.11"
6868
let client: ClientRuntime.SdkHttpClient
6969
let config: AccountClient.AccountClientConfiguration
7070
let serviceName = "Account"

0 commit comments

Comments
 (0)