Skip to content

Commit 2ffa6ea

Browse files
authored
fix(rt): import signing test suite (#451)
1 parent 7a6785a commit 2ffa6ea

File tree

816 files changed

+4571
-12
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

816 files changed

+4571
-12
lines changed

aws-runtime/aws-signing/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ extra["moduleName"] = "aws.sdk.kotlin.runtime.auth.signing"
99

1010
val smithyKotlinVersion: String by project
1111
val kotestVersion: String by project
12+
val ktorVersion: String by project
13+
val kotlinxSerializationVersion: String by project
1214

1315
kotlin {
1416
sourceSets {
@@ -30,6 +32,11 @@ kotlin {
3032
commonTest {
3133
dependencies {
3234
implementation(project(":aws-runtime:testing"))
35+
36+
// sigv4 test suite
37+
implementation("io.ktor:ktor-utils:$ktorVersion")
38+
implementation("io.ktor:ktor-http-cio:$ktorVersion")
39+
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinxSerializationVersion")
3340
}
3441
}
3542

aws-runtime/aws-signing/common/src/aws/sdk/kotlin/runtime/auth/signing/AwsSigV4SigningMiddleware.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@ import aws.smithy.kotlin.runtime.http.operation.SdkHttpOperation
1818
import aws.smithy.kotlin.runtime.http.operation.withContext
1919
import aws.smithy.kotlin.runtime.logging.Logger
2020
import aws.smithy.kotlin.runtime.util.get
21+
import kotlin.time.Duration
22+
import kotlin.time.ExperimentalTime
2123

2224
/**
2325
* HTTP request pipeline middleware that signs outgoing requests
2426
*/
2527
@InternalSdkApi
28+
@OptIn(ExperimentalTime::class)
2629
public class AwsSigV4SigningMiddleware internal constructor(private val config: Config) : Feature {
2730

2831
public class Config {
@@ -71,6 +74,13 @@ public class AwsSigV4SigningMiddleware internal constructor(private val config:
7174
* Most services do not require this additional header.
7275
*/
7376
public var signedBodyHeaderType: AwsSignedBodyHeaderType = AwsSignedBodyHeaderType.NONE
77+
78+
/**
79+
* If non-zero and the signing transform is query param, then signing will add X-Amz-Expires to the query
80+
* string, equal to the value specified here. If this value is zero or if header signing is being used then
81+
* this parameter has no effect.
82+
*/
83+
public var expiresAfter: Duration? = null
7484
}
7585

7686
public companion object Feature : HttpClientFeatureFactory<Config, AwsSigV4SigningMiddleware> {
@@ -132,6 +142,7 @@ public class AwsSigV4SigningMiddleware internal constructor(private val config:
132142
omitSessionToken = config.omitSessionToken
133143
normalizeUriPath = config.normalizeUriPath
134144
useDoubleUriEncode = config.useDoubleUriEncode
145+
expiresAfter = config.expiresAfter
135146

136147
signedBodyHeader = config.signedBodyHeaderType
137148
signedBodyValue = when {
Lines changed: 38 additions & 0 deletions
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"credentials": {
3+
"access_key_id": "AKIDEXAMPLE",
4+
"secret_access_key": "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY"
5+
},
6+
"expiration_in_seconds": 3600,
7+
"normalize": true,
8+
"region": "us-east-1",
9+
"service": "service",
10+
"sign_body": false,
11+
"timestamp": "2015-08-30T12:36:00Z"
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
GET
2+
/
3+
4+
host:example.amazonaws.com
5+
my-header1:value2,value2,value1
6+
x-amz-date:20150830T123600Z
7+
8+
host;my-header1;x-amz-date
9+
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
c9d5ea9f3f72853aea855b47ea873832890dbdd183b4468f858259531a5138ea
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
GET / HTTP/1.1
2+
Host:example.amazonaws.com
3+
My-Header1:value2
4+
My-Header1:value2
5+
My-Header1:value1
6+
X-Amz-Date:20150830T123600Z
7+
Authorization:AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, SignedHeaders=host;my-header1;x-amz-date, Signature=c9d5ea9f3f72853aea855b47ea873832890dbdd183b4468f858259531a5138ea
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
AWS4-HMAC-SHA256
2+
20150830T123600Z
3+
20150830/us-east-1/service/aws4_request
4+
dc7f04a3abfde8d472b0ab1a418b741b7c67174dad1551b4117b15527fbe966c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
GET
2+
/
3+
X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIDEXAMPLE%2F20150830%2Fus-east-1%2Fservice%2Faws4_request&X-Amz-Date=20150830T123600Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host%3Bmy-header1
4+
host:example.amazonaws.com
5+
my-header1:value2,value2,value1
6+
7+
host;my-header1
8+
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3349ee0b81b4b589da0ff28a395c3591e04de515651dd74f298fa992d1507a97

0 commit comments

Comments
 (0)