Skip to content

Commit

Permalink
Adjust for OTP23 (#18)
Browse files Browse the repository at this point in the history
* Adjust for OTP23

* Get rid of encode_hex for good, thanks to @zerth's advice

* Update libs

* Format
  • Loading branch information
Brujo Benavides authored May 27, 2021
1 parent 45a4f46 commit 235747a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{alias, [{test, [format, lint, hank, xref, dialyzer, eunit, cover]}]}.

{project_plugins,
[{rebar3_hex, "~> 6.11.0"},
[{rebar3_hex, "~> 6.11.4"},
{rebar3_format, "~> 1.0.0"},
{rebar3_lint, "~> 0.4.0"},
{rebar3_hank, "~> 0.4.0"}]}.
{rebar3_hank, "~> 1.1.2"}]}.
6 changes: 4 additions & 2 deletions src/awsv4.erl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ headers(#credentials{secret_access_key = SecretAccessKey,
Hash = sha256,
Algorithm = "AWS4-HMAC-SHA256",
SigningKey =
lists:foldl(fun(E, A) -> crypto:hmac(Hash, A, E) end, "AWS4" ++ SecretAccessKey, Scope),
lists:foldl(fun(E, A) -> crypto:mac(hmac, Hash, A, E) end,
"AWS4" ++ SecretAccessKey,
Scope),

Headers =
lists:keysort(1,
Expand Down Expand Up @@ -116,7 +118,7 @@ headers(#credentials{secret_access_key = SecretAccessKey,
CredentialScope,
hexlify(crypto:hash(Hash, CanonicalRequest))]),

Signature = hexlify(crypto:hmac(Hash, SigningKey, StringToSign)),
Signature = hexlify(crypto:mac(hmac, Hash, SigningKey, StringToSign)),

[{"authorization",
[Algorithm,
Expand Down
4 changes: 2 additions & 2 deletions src/imds.erl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public_hostname() ->
get_session_token() ->
case role_name() of
{ok, RoleName} ->
Result = imds_tokens(["iam/security-credentials/", http_uri:encode(RoleName)]),
Result = imds_tokens(["iam/security-credentials/", RoleName]),
awsv4:credentials_from_plist(Result);
Error ->
Error
Expand Down Expand Up @@ -178,7 +178,7 @@ call_with_retry(_, _, _, _, _) ->
{error, retries_exceeded}.

imds_url(Suffix) ->
lists:flatten(["http://", ?IMDS_HOST, "/", ?IMDS_VERSION, "/meta-data/", Suffix]).
uri_string:normalize(["http://", ?IMDS_HOST, "/", ?IMDS_VERSION, "/meta-data/", Suffix]).

imds_text(Suffix) ->
imds_text_response(imds_url(Suffix)).
Expand Down

0 comments on commit 235747a

Please sign in to comment.