Skip to content

Commit 4c7ad7c

Browse files
committed
Deprecate UnsupportedSigningAlgorithmInterceptor instead of removing it
1 parent ca26fc2 commit 4c7ad7c

File tree

3 files changed

+138
-0
lines changed

3 files changed

+138
-0
lines changed

aws-runtime/aws-http/api/aws-http.api

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,29 @@ public final class aws/sdk/kotlin/runtime/http/interceptors/IgnoreCompositeFlexi
168168
public fun ignoreChecksum (Ljava/lang/String;Laws/smithy/kotlin/runtime/client/ProtocolResponseInterceptorContext;)Z
169169
}
170170

171+
public final class aws/sdk/kotlin/runtime/http/interceptors/UnsupportedSigningAlgorithmInterceptor : aws/smithy/kotlin/runtime/client/Interceptor {
172+
public fun <init> ()V
173+
public fun modifyBeforeAttemptCompletion-gIAlu-s (Laws/smithy/kotlin/runtime/client/ResponseInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
174+
public fun modifyBeforeCompletion-gIAlu-s (Laws/smithy/kotlin/runtime/client/ResponseInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
175+
public fun modifyBeforeDeserialization (Laws/smithy/kotlin/runtime/client/ProtocolResponseInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
176+
public fun modifyBeforeRetryLoop (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
177+
public fun modifyBeforeSerialization (Laws/smithy/kotlin/runtime/client/RequestInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
178+
public fun modifyBeforeSigning (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
179+
public fun modifyBeforeTransmit (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
180+
public fun readAfterAttempt (Laws/smithy/kotlin/runtime/client/ResponseInterceptorContext;)V
181+
public fun readAfterDeserialization (Laws/smithy/kotlin/runtime/client/ResponseInterceptorContext;)V
182+
public fun readAfterExecution (Laws/smithy/kotlin/runtime/client/ResponseInterceptorContext;)V
183+
public fun readAfterSerialization (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;)V
184+
public fun readAfterSigning (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;)V
185+
public fun readAfterTransmit (Laws/smithy/kotlin/runtime/client/ProtocolResponseInterceptorContext;)V
186+
public fun readBeforeAttempt (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;)V
187+
public fun readBeforeDeserialization (Laws/smithy/kotlin/runtime/client/ProtocolResponseInterceptorContext;)V
188+
public fun readBeforeExecution (Laws/smithy/kotlin/runtime/client/RequestInterceptorContext;)V
189+
public fun readBeforeSerialization (Laws/smithy/kotlin/runtime/client/RequestInterceptorContext;)V
190+
public fun readBeforeSigning (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;)V
191+
public fun readBeforeTransmit (Laws/smithy/kotlin/runtime/client/ProtocolRequestInterceptorContext;)V
192+
}
193+
171194
public final class aws/sdk/kotlin/runtime/http/interceptors/businessmetrics/AwsBusinessMetric : java/lang/Enum, aws/smithy/kotlin/runtime/businessmetrics/BusinessMetric {
172195
public static final field DDB_MAPPER Laws/sdk/kotlin/runtime/http/interceptors/businessmetrics/AwsBusinessMetric;
173196
public static final field S3_EXPRESS_BUCKET Laws/sdk/kotlin/runtime/http/interceptors/businessmetrics/AwsBusinessMetric;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
package aws.sdk.kotlin.runtime.http.interceptors
6+
7+
import aws.sdk.kotlin.runtime.InternalSdkApi
8+
import aws.smithy.kotlin.runtime.auth.awssigning.AwsSigningAlgorithm
9+
import aws.smithy.kotlin.runtime.auth.awssigning.UnsupportedSigningAlgorithmException
10+
import aws.smithy.kotlin.runtime.client.ResponseInterceptorContext
11+
import aws.smithy.kotlin.runtime.http.interceptors.HttpInterceptor
12+
import aws.smithy.kotlin.runtime.http.request.HttpRequest
13+
import aws.smithy.kotlin.runtime.http.response.HttpResponse
14+
15+
// FIXME: Remove this once sigV4a is supported by default AWS signer
16+
/**
17+
* Looks for an unsupported signing algorithm error caused by sigV4a.
18+
* If so it sends users to a section in the AWS SDK for Kotlin documentation on how to fix it.
19+
*/
20+
@InternalSdkApi
21+
@Deprecated("This interceptor is no longer used. It will be removed in the next minor version, v1.5.x.")
22+
public class UnsupportedSigningAlgorithmInterceptor : HttpInterceptor {
23+
override suspend fun modifyBeforeCompletion(context: ResponseInterceptorContext<Any, Any, HttpRequest?, HttpResponse?>): Result<Any> {
24+
context.response.exceptionOrNull()?.let {
25+
if (it is UnsupportedSigningAlgorithmException && it.signingAlgorithm == AwsSigningAlgorithm.SIGV4_ASYMMETRIC) {
26+
return Result.failure(
27+
UnsupportedSigningAlgorithmException(
28+
"SIGV4A support is not yet implemented for the default signer. For more information on how to enable it with the CRT signer, please refer to: https://a.co/3sf8533",
29+
it.signingAlgorithm,
30+
it,
31+
),
32+
)
33+
}
34+
}
35+
return super.modifyBeforeCompletion(context)
36+
}
37+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
package aws.sdk.kotlin.runtime.http.interceptors
6+
7+
import aws.smithy.kotlin.runtime.auth.awssigning.AwsSigningAlgorithm
8+
import aws.smithy.kotlin.runtime.auth.awssigning.UnsupportedSigningAlgorithmException
9+
import aws.smithy.kotlin.runtime.client.ResponseInterceptorContext
10+
import aws.smithy.kotlin.runtime.client.SdkClientOption
11+
import aws.smithy.kotlin.runtime.http.request.HttpRequest
12+
import aws.smithy.kotlin.runtime.http.response.HttpResponse
13+
import aws.smithy.kotlin.runtime.operation.ExecutionContext
14+
import kotlinx.coroutines.test.runTest
15+
import kotlin.test.Test
16+
import kotlin.test.assertEquals
17+
import kotlin.test.assertIs
18+
import kotlin.test.assertTrue
19+
20+
class UnsupportedSigningAlgorithmInterceptorTest {
21+
@Test
22+
fun testUnsupportedSigningAlgorithmSigV4a() = runTest {
23+
val result =
24+
UnsupportedSigningAlgorithmInterceptor()
25+
.modifyBeforeCompletion(
26+
context(
27+
Result.failure(
28+
UnsupportedSigningAlgorithmException(
29+
"SIGV4A support is not yet implemented for the default signer.",
30+
AwsSigningAlgorithm.SIGV4_ASYMMETRIC,
31+
),
32+
),
33+
),
34+
)
35+
36+
val exception = result.exceptionOrNull()
37+
38+
assertTrue(result.isFailure)
39+
assertIs<UnsupportedSigningAlgorithmException>(exception)
40+
assertEquals(exception.signingAlgorithm, AwsSigningAlgorithm.SIGV4_ASYMMETRIC)
41+
assertEquals(
42+
"SIGV4A support is not yet implemented for the default signer. For more information on how to enable it with the CRT signer, please refer to: https://a.co/3sf8533",
43+
exception.message,
44+
)
45+
}
46+
47+
@Test
48+
fun testUnsupportedSigningAlgorithmNotSigV4a() = runTest {
49+
val result =
50+
UnsupportedSigningAlgorithmInterceptor()
51+
.modifyBeforeCompletion(
52+
context(
53+
Result.failure(
54+
UnsupportedSigningAlgorithmException(
55+
"SIGV4 support is not yet implemented for the default signer.",
56+
AwsSigningAlgorithm.SIGV4,
57+
),
58+
),
59+
),
60+
)
61+
62+
val exception = result.exceptionOrNull()
63+
64+
assertTrue(result.isFailure)
65+
assertIs<UnsupportedSigningAlgorithmException>(exception)
66+
assertEquals(exception.signingAlgorithm, AwsSigningAlgorithm.SIGV4)
67+
assertEquals("SIGV4 support is not yet implemented for the default signer.", exception.message)
68+
}
69+
}
70+
71+
private fun context(response: Result<Any>) =
72+
object : ResponseInterceptorContext<Any, Any, HttpRequest?, HttpResponse?> {
73+
override val executionContext = ExecutionContext.build { attributes[SdkClientOption.OperationName] = "test" }
74+
override val request = Unit
75+
override val response = response
76+
override val protocolRequest = HttpRequest { }
77+
override val protocolResponse = null
78+
}

0 commit comments

Comments
 (0)