Skip to content

Commit

Permalink
Merge pull request #41 from y2k2mt/amz-security-token
Browse files Browse the repository at this point in the history
Add X-Amz-Security-Token header
  • Loading branch information
taylorfinnell authored Jul 22, 2019
2 parents ea87ee3 + 87cba4a commit 418954f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/awscr-signer/signers/v4.cr
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Awscr
class V4
include Interface

def initialize(@service : String, @region : String, @aws_access_key : String, @aws_secret_key : String)
def initialize(@service : String, @region : String, @aws_access_key : String, @aws_secret_key : String, @amz_security_token : String? = nil)
@credentials = Signer::Credentials.new(aws_access_key, aws_secret_key)
end

Expand Down Expand Up @@ -59,6 +59,10 @@ module Awscr

private def header_impl(request, add_sha)
scope = Signer::Scope.new(@region, @service)

@amz_security_token.try do |token|
request.headers["X-Amz-Security-Token"] = token
end
# Replace "Date" with X-Amz-Date.
# Only if X-Amz-Date is not already set. AWS prefers
# X-Amz-Date
Expand Down

0 comments on commit 418954f

Please sign in to comment.