Skip to content

Allows client to send calculated hash payload #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/aws_auth/authorization_header.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ defmodule AWSAuth.AuthorizationHeader do

headers = Map.put_new(headers, "host", uri.host)

payload = AWSAuth.Utils.hash_sha256(payload)
payload = if payload == :hashed do
payload
else
AWSAuth.Utils.hash_sha256(payload)
end

headers = Map.put_new(headers, "x-amz-content-sha256", payload)

Expand Down
8 changes: 5 additions & 3 deletions lib/aws_auth/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ defmodule AWSAuth.Utils do
|> Enum.sort(&(&1 < &2))
|> Enum.join(";")

hashed_payload = if hashed_payload == :unsigned,
do: "UNSIGNED-PAYLOAD",
else: hashed_payload
hashed_payload = case hashed_payload do
:unsigned -> "UNSIGNED-PAYLOAD"
:hashed -> headers["x-amz-content-sha256"]
_ -> hashed_payload
end

encoded_path =
path
Expand Down