Skip to content

Commit efbe3c9

Browse files
committed
Add session token to canonical query
1 parent 38f85c3 commit efbe3c9

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

lib/kafka/sasl/awsmskiam.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def digest
6262
end
6363

6464
def authentication_payload(host:, time_now:)
65-
payload = {
65+
{
6666
'version': "2020_10_22",
6767
'host': host,
6868
'user-agent': "ruby-kafka",
@@ -72,12 +72,9 @@ def authentication_payload(host:, time_now:)
7272
'x-amz-date': time_now.strftime("%Y%m%dT%H%M%SZ"),
7373
'x-amz-signedheaders': "host",
7474
'x-amz-expires': "900",
75+
'x-amz-security-token': @session_token,
7576
'x-amz-signature': signature(host: host, time_now: time_now)
76-
}
77-
78-
payload['x-amz-security-token'] = @session_token unless @session_token.nil?
79-
80-
payload.to_json
77+
}.to_json
8178
end
8279

8380
def canonical_request(host:, time_now:)
@@ -96,6 +93,7 @@ def canonical_query_string(time_now:)
9693
"X-Amz-Credential" => @access_key_id + "/" + time_now.strftime("%Y%m%d") + "/" + @aws_region + "/kafka-cluster/aws4_request",
9794
"X-Amz-Date" => time_now.strftime("%Y%m%dT%H%M%SZ"),
9895
"X-Amz-Expires" => "900",
96+
"X-Amz-Security-Token" => @session_token,
9997
"X-Amz-SignedHeaders" => "host"
10098
)
10199
end

lib/kafka/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module Kafka
4-
VERSION = "1.4.0"
4+
VERSION = "1.4.4"
55
end

0 commit comments

Comments
 (0)