Skip to content
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

feat: switch default signer implementation to standard (from CRT) #600

Merged
merged 2 commits into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions aws-runtime/aws-config/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ kotlin {
implementation(project(":aws-runtime:protocols:aws-xml-protocols"))
implementation(project(":aws-runtime:aws-endpoint"))
implementation("aws.smithy.kotlin:aws-signing-common:$smithyKotlinVersion")

// TODO -- replace this once CRT is no longer the default signer
implementation("aws.smithy.kotlin:aws-signing-crt:$smithyKotlinVersion")
implementation("aws.smithy.kotlin:aws-signing-default:$smithyKotlinVersion")

// additional dependencies required by generated sso provider
implementation(project(":aws-runtime:protocols:aws-json-protocols"))
Expand Down
4 changes: 1 addition & 3 deletions aws-runtime/protocols/aws-event-stream/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ kotlin {
dependencies {
implementation(project(":aws-runtime:testing"))
api("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion")

// TODO -- replace this once CRT is no longer the default signer
api("aws.smithy.kotlin:aws-signing-crt:$smithyKotlinVersion")
implementation("aws.smithy.kotlin:aws-signing-default:$smithyKotlinVersion")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import aws.smithy.kotlin.runtime.auth.awscredentials.Credentials
import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProvider
import aws.smithy.kotlin.runtime.auth.awssigning.AwsSignatureType
import aws.smithy.kotlin.runtime.auth.awssigning.AwsSigningConfig
import aws.smithy.kotlin.runtime.auth.awssigning.crt.CrtAwsSigner
import aws.smithy.kotlin.runtime.auth.awssigning.DefaultAwsSigner
import aws.smithy.kotlin.runtime.hashing.sha256
import aws.smithy.kotlin.runtime.io.SdkByteBuffer
import aws.smithy.kotlin.runtime.io.bytes
Expand Down Expand Up @@ -50,7 +50,7 @@ class EventStreamSigningTest {
val buffer = SdkByteBuffer(0U)
messageToSign.encode(buffer)
val messagePayload = buffer.bytes()
val result = CrtAwsSigner.signPayload(signingConfig, prevSignature, messagePayload, testClock)
val result = DefaultAwsSigner.signPayload(signingConfig, prevSignature, messagePayload, testClock)
assertEquals(":date", result.output.headers[0].name)

val dateHeader = result.output.headers[0].value.expectTimestamp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,9 @@ class PresignerGenerator : KotlinIntegration {
name = "signer"
documentation = "The implementation of AWS signer to use for signing requests"
baseClass = RuntimeTypes.Auth.Signing.AwsSigningCommon.ServicePresignConfig
propertyType = ClientConfigPropertyType.RequiredWithDefault("CrtAwsSigner")
propertyType = ClientConfigPropertyType.RequiredWithDefault("DefaultAwsSigner")
additionalImports = listOf(
RuntimeTypes.Auth.Signing.AwsSigningCrt.CrtAwsSigner,
RuntimeTypes.Auth.Signing.AwsSigningStandard.DefaultAwsSigner,
)
},
ClientConfigProperty {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class EventStreamSerializerGenerator(
writer.write("val signingConfig = context.#T()", AwsRuntimeTypes.AwsEventStream.newEventStreamSigningConfig)
// FIXME - needs to be set on the operation for initial request
// context[AwsSigningAttributes.SignedBodyHeader] = AwsSignedBodyHeader.X_AMZ_CONTENT_SHA256.name
// context[AwsSigningAttributes.BodyHash] = BodyHash.StreamingAws4HmacSha256Events
// context[AwsSigningAttributes.HashSpecification] = HashSpecification.StreamingAws4HmacSha256Events

val encodeFn = encodeEventStreamMessage(ctx, op, streamShape)
writer.withBlock("val messages = stream", "") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ class PresignerGeneratorTest {
import aws.sdk.kotlin.runtime.endpoint.asSigningEndpointProvider
import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProvider
import aws.smithy.kotlin.runtime.auth.awssigning.AwsSigner
import aws.smithy.kotlin.runtime.auth.awssigning.DefaultAwsSigner
import aws.smithy.kotlin.runtime.auth.awssigning.PresignedRequestConfig
import aws.smithy.kotlin.runtime.auth.awssigning.PresigningLocation
import aws.smithy.kotlin.runtime.auth.awssigning.ServicePresignConfig
import aws.smithy.kotlin.runtime.auth.awssigning.SigningEndpointProvider
import aws.smithy.kotlin.runtime.auth.awssigning.createPresignedRequest
import aws.smithy.kotlin.runtime.auth.awssigning.crt.CrtAwsSigner
import aws.smithy.kotlin.runtime.client.ExecutionContext
import aws.smithy.kotlin.runtime.http.QueryParameters
import aws.smithy.kotlin.runtime.http.request.HttpRequest
Expand Down Expand Up @@ -238,7 +238,7 @@ class PresignerGeneratorTest {
override val normalizeUriPath: Boolean = true
override val region: String = requireNotNull(builder.region) { "region is a required configuration property" }
override val serviceId: String = "example"
override val signer: AwsSigner = builder.signer ?: CrtAwsSigner
override val signer: AwsSigner = builder.signer ?: DefaultAwsSigner
override val signingName: String = "example-signing-name"
override val useDoubleUriEncode: Boolean = true
companion object {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sdkVersion=0.15.2-SNAPSHOT
smithyVersion=1.17.0
smithyGradleVersion=0.5.3
# smithy-kotlin codegen and runtime are versioned together
smithyKotlinVersion=0.9.0
smithyKotlinVersion=0.9.1-SNAPSHOT

# kotlin
kotlinVersion=1.6.10
Expand Down
4 changes: 1 addition & 3 deletions tests/codegen/event-stream/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,7 @@ dependencies {
testImplementation(kotlin("test-junit5"))
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion")
testImplementation("aws.smithy.kotlin:smithy-test:$smithyKotlinVersion")

// TODO -- replace this once CRT is no longer the default signer
testImplementation("aws.smithy.kotlin:aws-signing-crt:$smithyKotlinVersion")
testImplementation("aws.smithy.kotlin:aws-signing-default:$smithyKotlinVersion")

// have to manually add all the dependencies of the generated client(s)
// doing it this way (as opposed to doing what we do for protocol-tests) allows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import aws.sdk.kotlin.test.eventstream.restjson1.transform.deserializeTestStream
import aws.sdk.kotlin.test.eventstream.restjson1.transform.serializeTestStreamOpOperationBody
import aws.smithy.kotlin.runtime.auth.awscredentials.Credentials
import aws.smithy.kotlin.runtime.auth.awssigning.AwsSigningAttributes
import aws.smithy.kotlin.runtime.auth.awssigning.BodyHash
import aws.smithy.kotlin.runtime.auth.awssigning.crt.CrtAwsSigner
import aws.smithy.kotlin.runtime.auth.awssigning.DefaultAwsSigner
import aws.smithy.kotlin.runtime.auth.awssigning.HashSpecification
import aws.smithy.kotlin.runtime.client.ExecutionContext
import aws.smithy.kotlin.runtime.http.HttpBody
import aws.smithy.kotlin.runtime.http.content.ByteArrayContent
Expand Down Expand Up @@ -46,8 +46,8 @@ class EventStreamTests {
attributes[AwsSigningAttributes.CredentialsProvider] = StaticCredentialsProvider(
Credentials("fake-access-key", "fake-secret-key")
)
attributes[AwsSigningAttributes.RequestSignature] = BodyHash.EmptyBody.hash!!.encodeToByteArray()
attributes[AwsSigningAttributes.Signer] = CrtAwsSigner
attributes[AwsSigningAttributes.RequestSignature] = HashSpecification.EmptyBody.hash.encodeToByteArray()
attributes[AwsSigningAttributes.Signer] = DefaultAwsSigner
}

val body = serializeTestStreamOpOperationBody(testContext, req)
Expand Down