Created
June 13, 2017 00:17
-
-
Save cdegroot/70582f89fe51043206a1291c360a5c75 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
method = :get | |
url = "http://foo.bar/lol" | |
headers = [host: "foo.bar"] | |
body = "This is some body stuff" | |
access_key_id = "1234" | |
secret_access_key = "abcdef" | |
region = "us-west-2" | |
aws_config = %{} | |
|> Map.put(:access_key_id, access_key_id) | |
|> Map.put(:secret_access_key, secret_access_key) | |
|> Map.put(:region, region) | |
|> Map.put(:enabled, true) | |
Application.put_env(:elastic, :aws, aws_config) | |
IO.inspect Elastic.AWS.sign_authorization_headers(method, url, headers, body) | |
# Under 0.6.4, this results in: | |
# [Authorization: [{"X-Amz-Date", "20170613T001436Z"}, | |
# {"authorization", | |
# "AWS4-HMAC-SHA256 Credential=1234/20170613/us-west-2/es/aws4_request,SignedHeaders=host;x-amz-content-sha256;x-amz-date;x-amz-date,Signature=bbf3e41dd9e89039df8acbb87356310df4ea96b95a92dbdd85482c4a07e2e96b"}, | |
# {"host", "foo.bar"}, | |
# {"x-amz-content-sha256", | |
# "ec3654a7885b4db55f6c475cae673da49e88da7164495e23434e403ef924c0e5"}, | |
# {"x-amz-date", "20170613T001436Z"}], | |
# "x-amz-content-sha256": "ec3654a7885b4db55f6c475cae673da49e88da7164495e23434e403ef924c0e5", | |
# host: "foo.bar", "X-Amz-Date": "20170613T001436Z"] | |
# | |
# While under 0.6.2: | |
# [Authorization: "AWS4-HMAC-SHA256 Credential=1234/20170613/us-west-2/es/aws4_request,SignedHeaders=host;x-amz-content-sha256;x-amz-date,Signature=4696a1f3d5718d5d5cc0547767d2a80fc1fa3ccbccb78f7c555ce67fb6b370d9", | |
# "x-amz-content-sha256": "ec3654a7885b4db55f6c475cae673da49e88da7164495e23434e403ef924c0e5", | |
# host: "foo.bar", "X-Amz-Date": "20170613T001622Z"] | |
# | |
# Needless to say, this is a different API. Sending the 0.6.4 headers straight on to the | |
# http layer results in confusion. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment