Skip to content

Commit

Permalink
store the token for temporary credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
benwilson512 committed Jun 29, 2015
1 parent cc0ac7f commit 956e778
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/ex_aws/auth.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ defmodule ExAws.Auth do
import ExAws.Auth.Utils
alias Timex.DateFormat

@moduledoc false

def headers(http_method, url, service, config, headers, body) do
now = %{Timex.Date.now | ms: 0}
headers = [
Expand All @@ -22,7 +24,13 @@ defmodule ExAws.Auth do
now)

[{"Authorization", auth_header} | headers ]
|> handle_temp_credentials(config)
end

def handle_temp_credentials(headers, %{token: token}) do
[{"X-Amz-Security-Token", token} | headers]
end
def handle_temp_credentials(headers, _), do: headers

def auth_header(access_key, secret_key, http_method, url, region, service, headers, body, now) do
date = DateFormat.format!(now, "%Y%m%d", :strftime)
Expand Down
1 change: 1 addition & 0 deletions lib/ex_aws/instance_meta.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ defmodule ExAws.InstanceMeta do
%{
access_key_id: result["AccessKeyId"],
secret_access_key: result["SecretAccessKey"],
token: result["Token"],
expiration: result["Expiration"]
}
end
Expand Down

0 comments on commit 956e778

Please sign in to comment.