-
Notifications
You must be signed in to change notification settings - Fork 32
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
Support Erlang 24 #24
Merged
Merged
Conversation
This file contains 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
For `pbkdf2` users, upgrading to OTP 24 will require them to use a fork to no longer rely on the deprecated hmac functions. I chose to use `miniclip/erlang-pbkdf2` because it seems to be maintained. But users can choose whichever fork they prefer.
This module will only be partially compiled/tested by each build, so it isn't necessary to track its test coverage for now.
danielberkompas
force-pushed
the
cloak-version-1-1-0
branch
from
June 5, 2021 20:49
1a745ce
to
7b77bac
Compare
This was referenced Jun 5, 2021
danielberkompas
added a commit
that referenced
this pull request
Jun 5, 2021
It isn't possible to publish a package to Hex.pm with a dependency on a Github fork which is not also hosted on Hex.pm. The current version of `pbkdf2` is not compatible with Erlang 24. To use it, you'll need a forked version, see #24. For this reason, I needed to make the `pbkdf2` a `:dev, :test` dependency instead of an `:optional` dependency for `cloak_ecto`. If you add it to your mix dependencies in your project, `cloak_ecto` should still detect it; it shouldn't need to be listed as an optional dependency.
danielberkompas
added a commit
that referenced
this pull request
Jun 5, 2021
It isn't possible to publish a package to Hex.pm with a dependency on a Github fork which is not also hosted on Hex.pm. The current version of `pbkdf2` is not compatible with Erlang 24. To use it, you'll need a forked version, see #24. For this reason, I needed to make the `pbkdf2` a `:dev, :test` dependency instead of an `:optional` dependency for `cloak_ecto`. If you add it to your mix dependencies in your project, `cloak_ecto` should still detect it; it shouldn't need to be listed as an optional dependency.
danielberkompas
added a commit
that referenced
this pull request
Jun 5, 2021
It isn't possible to publish a package to Hex.pm with a dependency on a Github fork which is not also hosted on Hex.pm. The current version of `pbkdf2` is not compatible with Erlang 24. To use it, you'll need a forked version, see #24. For this reason, I needed to make the `pbkdf2` a `:dev, :test` dependency instead of an `:optional` dependency for `cloak_ecto`. If you add it to your mix dependencies in your project, `cloak_ecto` should still detect it; it shouldn't need to be listed as an optional dependency.
dimitarvp
reviewed
Jun 5, 2021
Comment on lines
+5
to
+15
if System.otp_release() >= "22" do | ||
@impl Cloak.Ecto.Crypto.Interface | ||
def hmac(algorithm, key, data) do | ||
:crypto.mac(:hmac, algorithm, key, data) | ||
end | ||
else | ||
@impl Cloak.Ecto.Crypto.Interface | ||
def hmac(algorithm, key, data) do | ||
:crypto.hmac(algorithm, key, data) | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR replaces the deprecated crypto hmac functions with modern ones when running on OTP > 22, without dropping support for OTP 21 and below. It also updates the dependency on
cloak
to version1.1.1
, which also supports OTP 24 with a similar strategy. This will allow this change to be a minor release rather than a major (breaking) release.However,
pbkdf2
users will need to use a forked version of that library to upgrade to OTP 24, sincepbkdf2
still uses the deprecated HMAC functions. I made Cloak.Ecto rely on the fork at miniclip/erlang-pbkdf2 for its test suite, but users can select their preferred fork using the hex:override
feature. For more details, see basho/erlang-pbkdf2#12.