-
Notifications
You must be signed in to change notification settings - Fork 33
feat: S3 Express support #916
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
Changes from all commits
e45be08
0defc56
fa8c6d2
ac0fc16
159ff51
3fb1fdd
adcf54d
34ab12b
12e4048
9a34126
22fe049
3d9bdc9
6f8daba
81f95eb
d6bd2bd
fcf7558
6cdaf0e
224ba4d
76d16da
3cd687d
f3351f1
d2d8e79
1592869
4457293
03a9123
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import class Smithy.Context | ||
import class Smithy.ContextBuilder | ||
import struct Smithy.AttributeKey | ||
|
||
public extension Context { | ||
|
||
var clientConfig: DefaultClientConfiguration? { | ||
get { get(key: clientConfigKey)?.clientConfig } | ||
set { set(key: clientConfigKey, value: ClientConfigurationWrapper(clientConfig: newValue)) } | ||
} | ||
} | ||
|
||
public extension ContextBuilder { | ||
|
||
func withClientConfig(value: DefaultClientConfiguration?) -> Self { | ||
let wrapped = ClientConfigurationWrapper(clientConfig: value) | ||
attributes.set(key: clientConfigKey, value: wrapped) | ||
return self | ||
} | ||
} | ||
|
||
private let clientConfigKey = AttributeKey<ClientConfigurationWrapper>(name: "SmithySwiftClientConfigWrapper") | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The client config is wrapped in a See comment on code immediately below for more details. |
||
/// A wrapper used to allow a client configuration object to be placed in Context, since client config is not Sendable. | ||
/// | ||
/// Placing the client config into Context is safe because the client config is not modified after being placed into Context. | ||
/// Client config is unwrapped, then may be used to create a service client and make calls as part of performing an operation. | ||
/// | ||
/// This type is public so that it may be accessed in other runtime modules. It is protected as SPI because it is a cross-module | ||
/// implementation detail that does not affect customers. | ||
/// | ||
/// `@unchecked Sendable` is used to make the wrapper Sendable even though it is technically not, due to the non-Sendable | ||
/// client config stored within. | ||
@_spi(ClientConfigWrapper) | ||
public final class ClientConfigurationWrapper: @unchecked Sendable { | ||
public let clientConfig: DefaultClientConfiguration | ||
|
||
init?(clientConfig: DefaultClientConfiguration?) { | ||
guard let clientConfig else { return nil } | ||
self.clientConfig = clientConfig | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import struct Smithy.AttributeKey | ||
|
||
public enum IdentityPropertyKeys { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Client config is also wrapped before storing it as an identity property. The wrapper defined immediately above is used. |
||
|
||
/// The service client config to be used in credential resolution. | ||
/// | ||
/// Used only in conjunction with the `awsv4-s3express` auth scheme, which generates bucket-specific credentials | ||
/// for use with the S3 Express service. | ||
@_spi(ClientConfigWrapper) | ||
public static let clientConfigWrapper = | ||
AttributeKey<ClientConfigurationWrapper>(name: "ClientConfigurationWrapperIdentityKey") | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,7 +73,14 @@ extension AuthSchemeMiddleware: SelectAuthScheme { | |
context: attributes | ||
) | ||
// Resolve identity using the resolver from auth scheme | ||
let identity = try await identityResolver.getIdentity(identityProperties: option.identityProperties) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The client config is wrapped, then added to identity properties (if any client config was stored to the context when the operation was started.) The modified identity properties are then passed into the identity resolver. This is used by the S3 Express identity resolver to call S3. |
||
var modifiedIdentityProperties = option.identityProperties | ||
modifiedIdentityProperties.set( | ||
key: IdentityPropertyKeys.clientConfigWrapper, | ||
value: ClientConfigurationWrapper(clientConfig: attributes.clientConfig) | ||
) | ||
let identity = try await identityResolver.getIdentity( | ||
identityProperties: modifiedIdentityProperties | ||
) | ||
// Save selected auth scheme | ||
selectedAuthScheme = SelectedAuthScheme( | ||
schemeID: option.schemeID, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,8 +34,9 @@ public struct SigV4AuthScheme: AuthScheme { | |
value: context.isBidirectionalStreamingEnabled | ||
) | ||
|
||
// Set signing name and signing region flags | ||
updatedSigningProperties.set(key: SigningPropertyKeys.signingName, value: context.signingName) | ||
// Set resolved signing name and signing region flags | ||
let signingName = updatedSigningProperties.get(key: SigningPropertyKeys.signingName) ?? context.signingName | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If signing properties include a signing name, use it, else fall back to the default signing name defined in the model's sigv4 trait. |
||
updatedSigningProperties.set(key: SigningPropertyKeys.signingName, value: signingName) | ||
updatedSigningProperties.set(key: SigningPropertyKeys.signingRegion, value: context.signingRegion) | ||
|
||
// Set expiration flag | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow the client config object to be placed into the context. This allows the client config to be passed to the S3 Express identity resolver, so that it can use the S3 client to obtain S3 Express credentials.