Skip to content

Commit 235747a

Browse files
author
Brujo Benavides
authored
Adjust for OTP23 (#18)
* Adjust for OTP23 * Get rid of encode_hex for good, thanks to @zerth's advice * Update libs * Format
1 parent 45a4f46 commit 235747a

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

rebar.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
{alias, [{test, [format, lint, hank, xref, dialyzer, eunit, cover]}]}.
4040

4141
{project_plugins,
42-
[{rebar3_hex, "~> 6.11.0"},
42+
[{rebar3_hex, "~> 6.11.4"},
4343
{rebar3_format, "~> 1.0.0"},
4444
{rebar3_lint, "~> 0.4.0"},
45-
{rebar3_hank, "~> 0.4.0"}]}.
45+
{rebar3_hank, "~> 1.1.2"}]}.

src/awsv4.erl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ headers(#credentials{secret_access_key = SecretAccessKey,
7676
Hash = sha256,
7777
Algorithm = "AWS4-HMAC-SHA256",
7878
SigningKey =
79-
lists:foldl(fun(E, A) -> crypto:hmac(Hash, A, E) end, "AWS4" ++ SecretAccessKey, Scope),
79+
lists:foldl(fun(E, A) -> crypto:mac(hmac, Hash, A, E) end,
80+
"AWS4" ++ SecretAccessKey,
81+
Scope),
8082

8183
Headers =
8284
lists:keysort(1,
@@ -116,7 +118,7 @@ headers(#credentials{secret_access_key = SecretAccessKey,
116118
CredentialScope,
117119
hexlify(crypto:hash(Hash, CanonicalRequest))]),
118120

119-
Signature = hexlify(crypto:hmac(Hash, SigningKey, StringToSign)),
121+
Signature = hexlify(crypto:mac(hmac, Hash, SigningKey, StringToSign)),
120122

121123
[{"authorization",
122124
[Algorithm,

src/imds.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public_hostname() ->
4040
get_session_token() ->
4141
case role_name() of
4242
{ok, RoleName} ->
43-
Result = imds_tokens(["iam/security-credentials/", http_uri:encode(RoleName)]),
43+
Result = imds_tokens(["iam/security-credentials/", RoleName]),
4444
awsv4:credentials_from_plist(Result);
4545
Error ->
4646
Error
@@ -178,7 +178,7 @@ call_with_retry(_, _, _, _, _) ->
178178
{error, retries_exceeded}.
179179

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

183183
imds_text(Suffix) ->
184184
imds_text_response(imds_url(Suffix)).

0 commit comments

Comments
 (0)