Skip to content

Commit 0a09bd0

Browse files
authored
feat: apply clock skew interceptor (#1065)
1 parent b5936d1 commit 0a09bd0

File tree

5 files changed

+34
-7
lines changed

5 files changed

+34
-7
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"id": "8665c18c-d742-4212-b920-6fea43f70c2c",
3+
"type": "feature",
4+
"description": "Detect and automatically correct clock skew to prevent signing errors"
5+
}

codegen/smithy-aws-kotlin-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/ServiceClientCompanionObjectWriter.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
*/
55
package aws.sdk.kotlin.codegen
66

7-
import software.amazon.smithy.kotlin.codegen.core.KotlinWriter
8-
import software.amazon.smithy.kotlin.codegen.core.RuntimeTypes
9-
import software.amazon.smithy.kotlin.codegen.core.getContextValue
10-
import software.amazon.smithy.kotlin.codegen.core.withBlock
7+
import software.amazon.smithy.kotlin.codegen.core.*
118
import software.amazon.smithy.kotlin.codegen.integration.SectionWriter
129
import software.amazon.smithy.kotlin.codegen.lang.KotlinTypes
1310
import software.amazon.smithy.kotlin.codegen.rendering.ServiceClientGenerator
@@ -49,8 +46,8 @@ class ServiceClientCompanionObjectWriter(
4946
RuntimeTypes.Core.Utils.LazyAsyncValue,
5047
AwsRuntimeTypes.Config.Profile.AwsSharedConfig,
5148
) {
49+
declareSection(ServiceClientGenerator.Sections.FinalizeConfig)
5250
writeResolveEndpointUrl()
53-
5451
extendFinalizeConfig?.let {
5552
write("")
5653
it()
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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.codegen.customization
6+
7+
import software.amazon.smithy.kotlin.codegen.core.RuntimeTypes
8+
import software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration
9+
import software.amazon.smithy.kotlin.codegen.integration.SectionWriter
10+
import software.amazon.smithy.kotlin.codegen.integration.SectionWriterBinding
11+
import software.amazon.smithy.kotlin.codegen.rendering.ServiceClientGenerator
12+
13+
/**
14+
* Adds a section writer which applies an interceptor that detects and corrects clock skew
15+
*/
16+
class ClockSkew : KotlinIntegration {
17+
override val sectionWriters: List<SectionWriterBinding>
18+
get() = listOf(SectionWriterBinding(ServiceClientGenerator.Sections.FinalizeConfig, clockSkewSectionWriter))
19+
20+
private val clockSkewSectionWriter = SectionWriter { writer, _ ->
21+
val interceptorSymbol = RuntimeTypes.AwsProtocolCore.ClockSkewInterceptor
22+
writer.write("builder.config.interceptors.add(0, #T())", interceptorSymbol)
23+
}
24+
}

codegen/smithy-aws-kotlin-codegen/src/main/resources/META-INF/services/software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ aws.sdk.kotlin.codegen.customization.s3control.HostPrefixFilter
2929
aws.sdk.kotlin.codegen.customization.s3control.ClientConfigIntegration
3030
aws.sdk.kotlin.codegen.protocols.endpoints.BindAwsEndpointBuiltins
3131
aws.sdk.kotlin.codegen.customization.s3.HostPrefixRequestRouteFilter
32-
aws.sdk.kotlin.codegen.customization.s3.UnwrappedXmlOutputIntegration
32+
aws.sdk.kotlin.codegen.customization.s3.UnwrappedXmlOutputIntegration
33+
aws.sdk.kotlin.codegen.customization.ClockSkew

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ coroutines-version = "1.7.3"
77
atomicfu-version = "0.19.0"
88

99
# smithy-kotlin codegen and runtime are versioned together
10-
smithy-kotlin-version = "0.27.7"
10+
smithy-kotlin-version = "0.27.8-SNAPSHOT"
1111

1212
# codegen
1313
smithy-version = "1.39.0"

0 commit comments

Comments
 (0)