Skip to content

Commit

Permalink
Make argon2 feature work with argon2 2.1.0+
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyevans committed Oct 5, 2021
1 parent 4d68dcc commit 7a47fdb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
=== master

* Make argon2 feature work with argon2 2.1.0+ (jeremyevans)

=== 2.17.0 (2021-09-24)

* Make jwt_refresh work correctly with verify_account_grace_period (jeremyevans)
Expand Down
14 changes: 13 additions & 1 deletion lib/rodauth/features/argon2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ module Rodauth

private

if Argon2::VERSION >= '2.1'
def argon2_salt_option
:salt_for_testing_purposes_only
end
# :nocov:
else
def argon2_salt_option
:salt_do_not_supply
end
# :nocov:
end

def password_hash_cost
return super unless use_argon2?
argon2_hash_cost
Expand All @@ -35,7 +47,7 @@ def password_hash_using_salt(password, salt)
return super unless argon2_hash_algorithm?(salt)

argon2_params = Hash[extract_password_hash_cost(salt)]
argon2_params[:salt_do_not_supply] = Base64.decode64(salt.split('$').last)
argon2_params[argon2_salt_option] = Base64.decode64(salt.split('$').last)
::Argon2::Password.new(argon2_params).create(password)
end

Expand Down

0 comments on commit 7a47fdb

Please sign in to comment.