From 2c82b91246674d2a59a85862801cc1ab1bc2359d Mon Sep 17 00:00:00 2001 From: Sichan Yoo Date: Tue, 10 Dec 2024 12:02:14 -0800 Subject: [PATCH 1/2] Fix signign region source. Get it from reoslved auth option, instead of getting it from the context. This removes the need to override signing region in the endpoint resolver middleware as well. --- .../Endpoints/EndpointResolverMiddleware.swift | 14 -------------- .../Sources/AWSSDKHTTPAuth/SigV4AAuthScheme.swift | 5 ++++- .../Sources/AWSSDKHTTPAuth/SigV4AuthScheme.swift | 5 ++++- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime/Endpoints/EndpointResolverMiddleware.swift b/Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime/Endpoints/EndpointResolverMiddleware.swift index 670374d8d6f..067c3ef0b16 100644 --- a/Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime/Endpoints/EndpointResolverMiddleware.swift +++ b/Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime/Endpoints/EndpointResolverMiddleware.swift @@ -80,20 +80,6 @@ extension EndpointResolverMiddleware: ApplyEndpoint { builder.withProtocol(protocolType) } - if let signingName = signingName { - attributes.signingName = signingName - attributes.selectedAuthScheme = selectedAuthScheme?.getCopyWithUpdatedSigningProperty( - key: SigningPropertyKeys.signingName, value: signingName - ) - } - - if let signingRegion = signingRegion { - attributes.signingRegion = signingRegion - attributes.selectedAuthScheme = selectedAuthScheme?.getCopyWithUpdatedSigningProperty( - key: SigningPropertyKeys.signingRegion, value: signingRegion - ) - } - if let signingAlgorithm = signingAlgorithm { attributes.signingAlgorithm = SigningAlgorithm(rawValue: signingAlgorithm) } diff --git a/Sources/Core/AWSSDKHTTPAuth/Sources/AWSSDKHTTPAuth/SigV4AAuthScheme.swift b/Sources/Core/AWSSDKHTTPAuth/Sources/AWSSDKHTTPAuth/SigV4AAuthScheme.swift index d92486cf6e3..7e698735336 100644 --- a/Sources/Core/AWSSDKHTTPAuth/Sources/AWSSDKHTTPAuth/SigV4AAuthScheme.swift +++ b/Sources/Core/AWSSDKHTTPAuth/Sources/AWSSDKHTTPAuth/SigV4AAuthScheme.swift @@ -32,7 +32,10 @@ public struct SigV4AAuthScheme: AuthScheme { // Set signing name and signing region flags updatedSigningProperties.set(key: SigningPropertyKeys.signingName, value: context.signingName) - updatedSigningProperties.set(key: SigningPropertyKeys.signingRegion, value: context.signingRegion) + updatedSigningProperties.set( + key: SigningPropertyKeys.signingRegion, + value: signingProperties.get(key: SigningPropertyKeys.signingRegion) + ) // Set expiration flag // diff --git a/Sources/Core/AWSSDKHTTPAuth/Sources/AWSSDKHTTPAuth/SigV4AuthScheme.swift b/Sources/Core/AWSSDKHTTPAuth/Sources/AWSSDKHTTPAuth/SigV4AuthScheme.swift index a7e46087c2d..f7e6b1e1ca8 100644 --- a/Sources/Core/AWSSDKHTTPAuth/Sources/AWSSDKHTTPAuth/SigV4AuthScheme.swift +++ b/Sources/Core/AWSSDKHTTPAuth/Sources/AWSSDKHTTPAuth/SigV4AuthScheme.swift @@ -39,7 +39,10 @@ public struct SigV4AuthScheme: AuthScheme { // Set signing name and signing region flags updatedSigningProperties.set(key: SigningPropertyKeys.signingName, value: context.signingName) - updatedSigningProperties.set(key: SigningPropertyKeys.signingRegion, value: context.signingRegion) + updatedSigningProperties.set( + key: SigningPropertyKeys.signingRegion, + value: signingProperties.get(key: SigningPropertyKeys.signingRegion) + ) // Set expiration flag // From 4539af28a9819480422c25b51a762a8ead82244c Mon Sep 17 00:00:00 2001 From: Sichan Yoo Date: Tue, 10 Dec 2024 12:13:02 -0800 Subject: [PATCH 2/2] The auth scheme property in endpoint rules may be missing signingRegionSet property entirely; in that case, take signingRegion from context. --- .../Sources/AWSSDKHTTPAuth/SigV4AAuthScheme.swift | 2 +- .../AWSSDKHTTPAuth/Sources/AWSSDKHTTPAuth/SigV4AuthScheme.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Core/AWSSDKHTTPAuth/Sources/AWSSDKHTTPAuth/SigV4AAuthScheme.swift b/Sources/Core/AWSSDKHTTPAuth/Sources/AWSSDKHTTPAuth/SigV4AAuthScheme.swift index 7e698735336..194f95c6a62 100644 --- a/Sources/Core/AWSSDKHTTPAuth/Sources/AWSSDKHTTPAuth/SigV4AAuthScheme.swift +++ b/Sources/Core/AWSSDKHTTPAuth/Sources/AWSSDKHTTPAuth/SigV4AAuthScheme.swift @@ -34,7 +34,7 @@ public struct SigV4AAuthScheme: AuthScheme { updatedSigningProperties.set(key: SigningPropertyKeys.signingName, value: context.signingName) updatedSigningProperties.set( key: SigningPropertyKeys.signingRegion, - value: signingProperties.get(key: SigningPropertyKeys.signingRegion) + value: signingProperties.get(key: SigningPropertyKeys.signingRegion) ?? context.signingRegion ) // Set expiration flag diff --git a/Sources/Core/AWSSDKHTTPAuth/Sources/AWSSDKHTTPAuth/SigV4AuthScheme.swift b/Sources/Core/AWSSDKHTTPAuth/Sources/AWSSDKHTTPAuth/SigV4AuthScheme.swift index f7e6b1e1ca8..79d8ea06487 100644 --- a/Sources/Core/AWSSDKHTTPAuth/Sources/AWSSDKHTTPAuth/SigV4AuthScheme.swift +++ b/Sources/Core/AWSSDKHTTPAuth/Sources/AWSSDKHTTPAuth/SigV4AuthScheme.swift @@ -41,7 +41,7 @@ public struct SigV4AuthScheme: AuthScheme { updatedSigningProperties.set(key: SigningPropertyKeys.signingName, value: context.signingName) updatedSigningProperties.set( key: SigningPropertyKeys.signingRegion, - value: signingProperties.get(key: SigningPropertyKeys.signingRegion) + value: signingProperties.get(key: SigningPropertyKeys.signingRegion) ?? context.signingRegion ) // Set expiration flag